Android/Mopub setup

I’m trying to get the mopub unity plugin for android working. And I’m stuck at one point in the instructions provided by mopub.

Hopefully someone can help me out.

Instructions:

  1. Build MoPubPlugin.jar
    a. Clone MoPubSdk b. Copy UnityPlugin’sMoPubUnityPlugin.java to MoPubSdk’ssrc/main/java/com/mopub/mobileads directory
    c. Add UnityPlugin's classes.jar to MoPubSdk's build path(in Eclipse) d. Use Eclipse (or your favorite tool) to build the MoPubSdk library to MoPubPlugin.jar
  2. Import UnityPlugin’s
    MoPubAndroid.unitypackage into your
    Unity Android Project
  3. Copy MoPubPlugin.jar to the Unity
    Project’s Plugins/Android directory
  4. Copy UnityPlugin’s
    android-support-v4.jar to the Unity
    Project’s Plugins/Android directory
  5. (Optional) Add UnityPlugin’s
    Plugins/MoPubAndroid/testSupport/MoPubTestScene
    to the Unity build window (contains
    the MoPubUIManager.cs example)
  6. Build and run your Unity project

I get to step 1d. and I’m unsure on how to generate the the MoPubPlugin.jar file. If i build the project, it creates a mopub-sdk.jar file. Which makes since to me because that’s the project. Do i rename this jar file or is there someother way to get it to create the MoPubPlugin.jar? I’m unfamilar with eclipse and I don’t see anyway to get that file based on the steps. Please help

here is the log file:
[11860-log.txt|11860]

Hi Prak,

Joe from MoPub here. Regarding your questions about MoPubPlugin.jar, yes, you’re right about it being the same as the mopub-sdk.jar. There should’ve been a dialog in Eclipse to generate it as MoPubPlugin.jar, but you can rename it afterwards as well and proceed with the rest of the steps.

Does this help?

Thanks,
Joe

Okay, I got something working. And I’d like to post my process to hopefully help others that get stuck in the instructions. If some of these things are obviously, more power to you because they were not to me.

FYI: I’m working on a 64bit Windows 8 machine.

here we go:

First instruction on mopub is:

In order to properly build the MoPub Unity Plugin you will need to use files from this repository (referred to as UnityPlugin in this document) and the MoPub Android SDK found under the mopub-sdk directory at https://github.com/mopub/mopub-android-sdk (referred to as MoPubSdk in this document).

so I went over to https://github.com/mopub/mopub-android-sdk and downloaded the “MoPub Android Full SDK.zip”

This page lists a whole set of instructions on getting this sdk install too. What I found is that most of the steps are already done in the provided download. The things you still have to do are:

Eclipse Integration Steps 1-4:

  1. Import the mopub-sdk archive into
    your workspace by clicking File >
    Import… and choosing Existing
    Projects into Workspace.
  2. Click the Select Archive File button
    then click Browse…
  3. Select the mopub-sdk archive file.
    Then, click Open.
  4. …then Finish.

Adding the SDK to Your Project Steps 1-2:

  1. Go to the Eclipse Package Explorer, right-click your project folder and select Properties.
  2. Choose Android from the sidebar.
  3. you should find that step 3 cannot be completed

Adding Ad Network Libraries to Your Project: should all be done for you too.

Updating your Android Manifest: needs to be done

.

Now that that’s done, we can go back to the unity plugin stuff:

the first bullet:

  1. Build MoPubPlugin.jar

    a. Clone MoPubSdk

    b. Copy UnityPlugin’s MoPubUnityPlugin.java to MoPubSdk’s src/main/java/com/mopub/mobileads directory

    c. Add UnityPlugin’s classes.jar to MoPubSdk’s build path (in Eclipse)

    d. Use Eclipse (or your favorite tool) to build the MoPubSdk library to MoPubPlugin.jar

This part is where I initially had the trouble.

(a.) is a given, you download the sdk

(b.) for this step, I found, that it’s best to drag and drop the file on top of the “com.mopub.mobileads” object. This makes sure it gets added in all the right ways.

11879-capture1.png

(c.) similar to step (b.) I prefer to drag and drop the file in the lib folder, then make sure to go into the Java Build Path (under properties) and add it (click add Jars… button, and select it)

(d.) this was a confusing step to me, eventually what I found was I could right click the project and select export, which opened a dialog for me to

select Java/JAR file, Next…

select a export destiation, where I could name the jar the appropriate “MoPubPlugin.jar”, Finish.

The next 4 steps are self explanatory.

  1. Import UnityPlugin’s MoPubAndroid.unitypackage into your Unity Android Project
  2. Copy MoPubPlugin.jar to the Unity Project’s Plugins/Android directory
  3. Copy UnityPlugin’s android-support-v4.jar to the Unity Project’s Plugins/Android directory
  4. (Optional) Add UnityPlugin’s Plugins/MoPubAndroid/testSupport/MoPubTestScene to the Unity build window (contains the MoPubUIManager.cs example)
  5. Build and run your Unity project

After that I was able to run the sample project and see the banner ad. That’s as far as I’ve gotten. I hope this helps someone avoid the suffering I’ve faced.

Best
j