Cannot build empty project with MoPub Unity package!

ads
unity

#1

Title says it all. I created a new Unity Project, added the MoPubPlugin.unitypackage (latest version v3.8.0), and tried to build an APK. It says “Failed to re-package resources. See the Console for details.” In the console there are two copies of the same error:

Error building Player: CommandInvokationFailure: Failed to re-package resources. See the Console for details.
C:\Android\sdk\build-tools\23.0.2\aapt.exe package --auto-add-overlay -v -f -m -J gen -M AndroidManifest.xml -S "res" -I "C:/Android/sdk\platforms\android-23\android.jar" -F bin/resources.ap_ --extra-packages com.prime31.NAME

stderr[
AndroidManifest.xml:28: error: Error: No resource found that matches the given name (at 'value' with value '@integer/google_play_services_version').

]
stdout[
Configurations:
 (default)
 xhdpi-v4

Files:
  drawable\app_banner.png
    Src: (xhdpi-v4) res\drawable-xhdpi\app_banner.png
  drawable\app_icon.png
    Src: () res\drawable\app_icon.png
  values\strings.xml
    Src: () res\values\strings.xml
  AndroidManifest.xml
    Src: () AndroidManifest.xml

Resource Dirs:
  Type drawable
    drawable\app_banner.png
      Src: (xhdpi-v4) res\drawable-xhdpi\app_banner.png
    drawable\app_icon.png
      Src: () res\drawable\app_icon.png
  Type values
    values\strings.xml
      Src: () res\values\strings.xml
Including resources from package: C:\Android\sdk\platforms\android-23\android.jar
applyFileOverlay for drawable
applyFileOverlay for layout
applyFileOverlay for anim
applyFileOverlay for animator
applyFileOverlay for interpolator
applyFileOverlay for transition
applyFileOverlay for xml
applyFileOverlay for raw
applyFileOverlay for color
applyFileOverlay for menu
applyFileOverlay for mipmap
Processing image: res\drawable-xhdpi\app_banner.png
Processing image: res\drawable\app_icon.png
    (processed image res\drawable\app_icon.png: 94% size of source)
    (processed image res\drawable-xhdpi\app_banner.png: 93% size of source)
    (new resource id app_banner from xhdpi-v4\drawable\app_banner.png #generated)
    (new resource id app_icon from drawable\app_icon.png #generated)
]

I tried to add the google play services library, but this caused its own issues and according to this quote it sounds like I should NOT need to do this:

The MoPub SDK can mediate most ad networks through our server-to-server integrations, pre-built adapters, and custom events capabilities. A full list of supported networks can be found here.

We offer pre-built adaptors for AdColony, AdMob, Chartboost, Facebook Audience Network, Millennial Media, UnityAds (interstitials only), and Vungle. To set these integrations up, follow the instructions below.

Since I’m just trying to get set up, I’m ok with doing only server-to-server ads, if it would work. I understand that I could probably manually edit the AndroidManifest.xml to include a play-services version number, but since this isn’t mentioned anywhere in the setup guide I’m thinking it isn’t the right way to go.

Also I made sure that my android tools are all up-to-date, and in Android SDK Mgr I added the Google Play Services package which wasnt installed by default. But the results are the same. I cannot build the example scene, nor can I build even an empty scene.

EDIT: Actually I didn’t need to set a GPS version to get it to build, I simply needed to delete this line from Plugins/Android/MoPub_lib/AndroidManifest.xml

<meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version"/>

So it’s compiling now, but it worries me that this will cause issues later… if someone could explain why the package doesn’t compile as downloaded, I’d love to know. Thanks!


#2

Hello!

Sorry that the Google Play Services line in your Android Manifest xml was causing you trouble! We put this line in because we recommend that publishers include the Google Play Services library, so we want to accommodate that scenario. However, it’s totally acceptable not to include it.

Best of luck and let us know if you need anything else!

Laura
Solutions Engineer, Twitter-MoPub


#3

Actually yes I could use some more help. I’ve now gotten things set up properly for MoPub and AdMob, however I’m having trouble with Chartboost and I can’t figure it out. It almost seems like the two sdks are out of sync.

All of this is on Android, btw.

I put the latest (6.3.0) chartboost.jar into my Assets/Plugins/Android/libs folder and when I try to request an interstitial on my device I see an error message like this:

I/MoPub   (31653): Performing custom event.
D/MoPub   (31653): Loading custom event interstitial adapter.
D/MoPub   (31653): Attempting to invoke custom event: com.mopub.mobileads.ChartboostInterstitial
D/AndroidRuntime(31653): Shutting down VM
E/AndroidRuntime(31653): FATAL EXCEPTION: main
E/AndroidRuntime(31653): Process: com.theunallied.adtests, PID: 31653
E/AndroidRuntime(31653): java.lang.Error: FATAL EXCEPTION [main]
E/AndroidRuntime(31653): Unity version     : 5.3.2f1
E/AndroidRuntime(31653): Device model      : BLU BLU STUDIO C
E/AndroidRuntime(31653): Device fingerprint: BLU/STUDIO_C/STUDIO_C:5.0
E/AndroidRuntime(31653):
E/AndroidRuntime(31653): Caused by: java.lang.NoSuchFieldError: No static field CBFrameworkMoPub of type Lcom/chartboost/sdk/Chartboost$CBFramework; in class Lcom/chartboost/sdk/Chartboost$CBFramework; or its superclasses (declaration of 'com.chartboost.sdk.Chartboost$CBFramework' appears in /data/app/com.theunallied.adtests-1/base.apk)
E/AndroidRuntime(31653):        at com.mopub.mobileads.ChartboostShared.initializeSdk(ChartboostShared.java:78)
E/AndroidRuntime(31653):        at com.mopub.mobileads.ChartboostInterstitial.loadInterstitial(ChartboostInterstitial.java:62)
E/AndroidRuntime(31653):        at com.mopub.mobileads.CustomEventInterstitialAdapter.loadInterstitial(CustomEventInterstitialAdapter.java:82)
E/AndroidRuntime(31653):        at com.mopub.mobileads.MoPubInterstitial$MoPubInterstitialView.loadCustomEvent(MoPubInterstitial.java:285)
E/AndroidRuntime(31653):        at com.mopub.mobileads.AdLoader$CustomEventAdLoader.load(AdLoader.java:64)
E/AndroidRuntime(31653):        at com.mopub.mobileads.AdViewController.onAdLoadSuccess(AdViewController.java:147)
E/AndroidRuntime(31653):        at com.mopub.mobileads.AdViewController$1.onSuccess(AdViewController.java:115)
E/AndroidRuntime(31653):        at com.mopub.network.AdRequest.deliverResponse(AdRequest.java:246)
E/AndroidRuntime(31653):        at com.mopub.network.AdRequest.deliverResponse(AdRequest.java:1)
E/AndroidRuntime(31653):        at com.mopub.volley.ExecutorDelivery$ResponseDeliveryRunnable.run(ExecutorDelivery.java:99)
E/AndroidRuntime(31653):        at android.os.Handler.handleCallback(Handler.java:810)
E/AndroidRuntime(31653):        at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime(31653):        at android.os.Looper.loop(Looper.java:189)
E/AndroidRuntime(31653):        at android.app.ActivityThread.main(ActivityThread.java:5532)
E/AndroidRuntime(31653):        at java.lang.reflect.Method.invoke(Native Method)
E/AndroidRuntime(31653):        at java.lang.reflect.Method.invoke(Method.java:372)
E/AndroidRuntime(31653):        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:950)
E/AndroidRuntime(31653):        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:745)
W/ActivityManager(  625):   Force finishing activity com.theunallied.adtests/com.unity3d.player.UnityPlayerActivity

It looks like this issue is caused by the same thing as this SO answer

I’ve tried finding older versions of the Chartboost.jar file but I’m having trouble knowing which version I’m even using, and any of the others I’ve tried create a IncompatibleClassChangeError instead of the NoSuchFieldError.

Any help would be truly appreciated, thanks!


#4

Hi @TheUnallied,

Thanks for bringing this to our attention! Please reach out to our Support Team at support@mopub.com with the following information. I member of the team would be happy to look into the crash for you.

  • Number of observed app crashes/frequency of the crashes: (e.g 5 crashes in 500 ad requests et al)
  • MoPub SDK version:
  • Partner SDK version, if involved:
  • Ad unit ID associated with the crash, if possible:
  • Steps to replicate the crash, if possible:
  • Crashlytics link and/or crash logs:

Thanks!