0

我正在尝试在我的游戏中设置广告,但我遇到了问题。它似乎要崩溃了。我在下面包含了 logcat,它似乎与广告有关。

06-07 18:49:54.594: E/dalvikvm(308): Could not find class 'com.google.ads.AdView', referenced from method com.blockyblaine.bobhoil.BlockyBlaine.onCreate
06-07 18:49:54.594: W/dalvikvm(308): VFY: unable to resolve check-cast 17 (Lcom/google/ads/AdView;) in Lcom/blockyblaine/bobhoil/BlockyBlaine;
06-07 18:49:54.603: D/dalvikvm(308): VFY: replacing opcode 0x1f at 0x0011
06-07 18:49:54.603: D/dalvikvm(308): VFY: dead code 0x0013-0069 in Lcom/blockyblaine/bobhoil/BlockyBlaine;.onCreate (Landroid/os/Bundle;)V
06-07 18:49:54.933: D/AndroidRuntime(308): Shutting down VM
06-07 18:49:54.933: W/dalvikvm(308): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
06-07 18:49:55.014: E/AndroidRuntime(308): FATAL EXCEPTION: main
06-07 18:49:55.014: E/AndroidRuntime(308): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.blockyblaine.bobhoil/com.blockyblaine.bobhoil.BlockyBlaine}: android.view.InflateException: Binary XML file line #8: Error inflating class com.google.ads.AdView
06-07 18:49:55.014: E/AndroidRuntime(308):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
06-07 18:49:55.014: E/AndroidRuntime(308):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
06-07 18:49:55.014: E/AndroidRuntime(308):  at android.app.ActivityThread.access$2300(ActivityThread.java:125)
06-07 18:49:55.014: E/AndroidRuntime(308):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
06-07 18:49:55.014: E/AndroidRuntime(308):  at android.os.Handler.dispatchMessage(Handler.java:99)
06-07 18:49:55.014: E/AndroidRuntime(308):  at android.os.Looper.loop(Looper.java:123)
06-07 18:49:55.014: E/AndroidRuntime(308):  at android.app.ActivityThread.main(ActivityThread.java:4627)
06-07 18:49:55.014: E/AndroidRuntime(308):  at java.lang.reflect.Method.invokeNative(Native Method)
06-07 18:49:55.014: E/AndroidRuntime(308):  at java.lang.reflect.Method.invoke(Method.java:521)
06-07 18:49:55.014: E/AndroidRuntime(308):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
06-07 18:49:55.014: E/AndroidRuntime(308):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
06-07 18:49:55.014: E/AndroidRuntime(308):  at dalvik.system.NativeStart.main(Native Method)
06-07 18:49:55.014: E/AndroidRuntime(308): Caused by: android.view.InflateException: Binary XML file line #8: Error inflating class com.google.ads.AdView
06-07 18:49:55.014: E/AndroidRuntime(308):  at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:576)
06-07 18:49:55.014: E/AndroidRuntime(308):  at android.view.LayoutInflater.rInflate(LayoutInflater.java:618)
06-07 18:49:55.014: E/AndroidRuntime(308):  at android.view.LayoutInflater.inflate(LayoutInflater.java:407)
06-07 18:49:55.014: E/AndroidRuntime(308):  at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
06-07 18:49:55.014: E/AndroidRuntime(308):  at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
06-07 18:49:55.014: E/AndroidRuntime(308):  at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:198)
06-07 18:49:55.014: E/AndroidRuntime(308):  at android.app.Activity.setContentView(Activity.java:1647)
06-07 18:49:55.014: E/AndroidRuntime(308):  at com.blockyblaine.bobhoil.BlockyBlaine.onCreate(BlockyBlaine.java:27)
06-07 18:49:55.014: E/AndroidRuntime(308):  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
06-07 18:49:55.014: E/AndroidRuntime(308):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
06-07 18:49:55.014: E/AndroidRuntime(308):  ... 11 more
06-07 18:49:55.014: E/AndroidRuntime(308): Caused by: java.lang.ClassNotFoundException: com.google.ads.AdView in loader dalvik.system.PathClassLoader[/data/app/com.blockyblaine.bobhoil-2.apk]
06-07 18:49:55.014: E/AndroidRuntime(308):  at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:243)
06-07 18:49:55.014: E/AndroidRuntime(308):  at java.lang.ClassLoader.loadClass(ClassLoader.java:573)
06-07 18:49:55.014: E/AndroidRuntime(308):  at java.lang.ClassLoader.loadClass(ClassLoader.java:532)
06-07 18:49:55.014: E/AndroidRuntime(308):  at android.view.LayoutInflater.createView(LayoutInflater.java:466)
06-07 18:49:55.014: E/AndroidRuntime(308):  at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:565)
06-07 18:49:55.014: E/AndroidRuntime(308):  ... 20 more
06-07 18:50:01.593: I/Process(308): Sending signal. PID: 308 SIG: 9
4

1 回答 1

0

此链接将带您访问 admob 开发人员文档。您需要确保按照说明将 admob JAR 包含在您的项目中。

我发现了一些与其他 google api 相关的其他提及。那里的问题(给出类似的 logcat)是错过了这一步:

2. Declare com.google.ads.AdActivity in AndroidManifest.xml.

<activity android:name="com.google.ads.AdActivity" android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"/>

于 2012-06-07T19:19:41.507 回答