简体   繁体   中英

Mopub Unity Android crashing on startup

I am trying to integrate Mopub for Android into my Unity project. I've followed the instructions here:

https://github.com/mopub/mopub-unity-android-plugin

building the mopub sdk with Android support and then adding it to my unity project. I've added the appropriate entries to my AndroidManifest.xml as so:

<activity android:name="com.mopub.mobileads.MoPubActivity"
        android:configChanges="keyboardHidden|orientation|screenSize"/>
<activity android:name="com.mopub.mobileads.MraidActivity"
        android:configChanges="keyboardHidden|orientation|screenSize"/>
<activity android:name="com.mopub.common.MoPubBrowser"
        android:configChanges="keyboardHidden|orientation|screenSize"/>
<activity android:name="com.mopub.mobileads.MraidVideoPlayerActivity"
        android:configChanges="keyboardHidden|orientation|screenSize"/>
<activity android:name="com.millennialmedia.android.MMActivity" android:theme="@android:style/Theme.Translucent.NoTitleBar" android:configChanges="keyboardHidden|orientation" />
<activity android:name="com.millennialmedia.android.VideoPlayer" android:theme="@android:style/Theme.NoTitleBar.Fullscreen" android:configChanges="keyboardHidden|orientation|keyboard" />
<activity android:name="com.google.ads.AdActivity" android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize" />
<activity android:name="com.google.android.gms.ads.AdActivity" android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize" />

...

  <uses-permission android:name="android.permission.INTERNET" />
  <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
  <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
  <uses-permission android:name="android.permission.READ_PHONE_STATE" />
  <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

The project builds fine, but when I run it on the device I am getting a crash the moment I request an interstitial or a banner ad. Here's the logcat:

E/AndroidRuntime(15901): FATAL EXCEPTION: main
E/AndroidRuntime(15901): java.lang.Error: FATAL EXCEPTION [main]
E/AndroidRuntime(15901): Unity version     : 4.6.1f1
E/AndroidRuntime(15901): Device model      : samsung GT-I9300
E/AndroidRuntime(15901): Device fingerprint: samsung/m0xx/m0:4.3/JSS15J/I9300XXUGNH4:user/release-keys
E/AndroidRuntime(15901):
E/AndroidRuntime(15901): Caused by: java.lang.Error: Unresolved compilation problem:
E/AndroidRuntime(15901):    NonNull cannot be resolved to a type
E/AndroidRuntime(15901):
E/AndroidRuntime(15901):    at com.mopub.common.util.ManifestUtils.checkWebViewActivitiesDeclared(ManifestUtils.java:51)
E/AndroidRuntime(15901):    at com.mopub.mobileads.MoPubView.<init>(MoPubView.java:64)
E/AndroidRuntime(15901):    at com.mopub.mobileads.MoPubView.<init>(MoPubView.java:58)
E/AndroidRuntime(15901):    at com.mopub.mobileads.MoPubUnityPlugin$1.run(MoPubUnityPlugin.java:43)
E/AndroidRuntime(15901):    at android.os.Handler.handleCallback(Handler.java:730)
E/AndroidRuntime(15901):    at android.os.Handler.dispatchMessage(Handler.java:92)
E/AndroidRuntime(15901):    at android.os.Looper.loop(Looper.java:176)
E/AndroidRuntime(15901):    at android.app.ActivityThread.main(ActivityThread.java:5419)
E/AndroidRuntime(15901):    at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime(15901):    at java.lang.reflect.Method.invoke(Method.java:525)
E/AndroidRuntime(15901):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1046)
E/AndroidRuntime(15901):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:862)
E/AndroidRuntime(15901):    at dalvik.system.NativeStart.main(Native Method)
I/ActivityManager( 2344): Notify an ApplicationCrash

I've tried the sample Unity scene that ships with the mopub Unity plugin, and the exact same thing is happening. Looking at checkWebViewActivitiesDeclared here gives me some clues that my activities may be wrong, but I can't see what error I'm making.

I am not very familiar with Android, but there is a line said:

NonNull cannot be resolved to a type

So, it maybe the source of the crash.

Have you try importing: android-support-annotations.jar ?

Try importing android-support-annotations.jar . It should resolve NonNull .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM