简体   繁体   English

Mopub Unity Android在启动时崩溃

[英]Mopub Unity Android crashing on startup

I am trying to integrate Mopub for Android into my Unity project. 我正在尝试将Mopub Android版集成到我的Unity项目中。 I've followed the instructions here: 我已按照此处的说明进行操作:

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

building the mopub sdk with Android support and then adding it to my unity project. 使用Android支持构建mopub sdk,然后将其添加到我的unity项目中。 I've added the appropriate entries to my AndroidManifest.xml as so: 我已经将适当的条目添加到了AndroidManifest.xml中,如下所示:

<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: 这是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. 我已经尝试了mopub Unity插件附带的示例Unity场景,并且发生了完全相同的事情。 Looking at checkWebViewActivitiesDeclared here gives me some clues that my activities may be wrong, but I can't see what error I'm making. 查看此处声明的checkWebViewActivities可以为我提供一些线索,表明我的活动可能有误,但是我看不到我在犯什么错误。

I am not very familiar with Android, but there is a line said: 我对Android不太熟悉,但是有一行这样写:

NonNull cannot be resolved to a type NonNull无法解析为类型

So, it maybe the source of the crash. 因此,这可能是崩溃的根源。

Have you try importing: android-support-annotations.jar ? 您是否尝试导入: android-support-annotations.jar

Try importing android-support-annotations.jar . 尝试导入android-support-annotations.jar It should resolve NonNull . 它应该解决NonNull。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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