在xml文件上添加添加Mobs AD之后我的应用程序不再打开

时间:2014-07-04 19:23:23

标签: android

错误是:

07-05 01:20:16.492: E/AndroidRuntime(560): FATAL EXCEPTION: main
07-05 01:20:16.492: E/AndroidRuntime(560): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.lantran/com.example.lantran.Homepage}: android.view.InflateException: Binary XML file line #34: Error inflating class com.google.ads.AdView
07-05 01:20:16.492: E/AndroidRuntime(560):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1647)
07-05 01:20:16.492: E/AndroidRuntime(560):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
07-05 01:20:16.492: E/AndroidRuntime(560):  at android.app.ActivityThread.access$1500(ActivityThread.java:117)
07-05 01:20:16.492: E/AndroidRuntime(560):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
07-05 01:20:16.492: E/AndroidRuntime(560):  at android.os.Handler.dispatchMessage(Handler.java:99)
07-05 01:20:16.492: E/AndroidRuntime(560):  at android.os.Looper.loop(Looper.java:123)
07-05 01:20:16.492: E/AndroidRuntime(560):  at android.app.ActivityThread.main(ActivityThread.java:3683)
07-05 01:20:16.492: E/AndroidRuntime(560):  at java.lang.reflect.Method.invokeNative(Native Method)
07-05 01:20:16.492: E/AndroidRuntime(560):  at java.lang.reflect.Method.invoke(Method.java:507)
07-05 01:20:16.492: E/AndroidRuntime(560):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
07-05 01:20:16.492: E/AndroidRuntime(560):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
07-05 01:20:16.492: E/AndroidRuntime(560):  at dalvik.system.NativeStart.main(Native Method)
07-05 01:20:16.492: E/AndroidRuntime(560): Caused by: android.view.InflateException: Binary XML file line #34: Error inflating class com.google.ads.AdView
07-05 01:20:16.492: E/AndroidRuntime(560):  at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:581)
07-05 01:20:16.492: E/AndroidRuntime(560):  at android.view.LayoutInflater.rInflate(LayoutInflater.java:623)
07-05 01:20:16.492: E/AndroidRuntime(560):  at android.view.LayoutInflater.inflate(LayoutInflater.java:408)
07-05 01:20:16.492: E/AndroidRuntime(560):  at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
07-05 01:20:16.492: E/AndroidRuntime(560):  at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
07-05 01:20:16.492: E/AndroidRuntime(560):  at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:207)
07-05 01:20:16.492: E/AndroidRuntime(560):  at android.app.Activity.setContentView(Activity.java:1657)
07-05 01:20:16.492: E/AndroidRuntime(560):  at com.example.lantran.Homepage.onCreate(Homepage.java:31)
07-05 01:20:16.492: E/AndroidRuntime(560):  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
07-05 01:20:16.492: E/AndroidRuntime(560):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
07-05 01:20:16.492: E/AndroidRuntime(560):  ... 11 more
07-05 01:20:16.492: E/AndroidRuntime(560): Caused by: java.lang.ClassNotFoundException: com.google.ads.AdView in loader dalvik.system.PathClassLoader[/data/app/com.example.lantran-1.apk]
07-05 01:20:16.492: E/AndroidRuntime(560):  at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:240)
07-05 01:20:16.492: E/AndroidRuntime(560):  at java.lang.ClassLoader.loadClass(ClassLoader.java:551)
07-05 01:20:16.492: E/AndroidRuntime(560):  at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
07-05 01:20:16.492: E/AndroidRuntime(560):  at android.view.LayoutInflater.createView(LayoutInflater.java:471)
07-05 01:20:16.492: E/AndroidRuntime(560):  at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:570)

1 个答案:

答案 0 :(得分:0)

您的错误是:

java.lang.ClassNotFoundException: com.google.ads.AdView 

您是否已正确添加Google Play服务?

app/build.gradle

你需要

dependencies {
     compile 'com.google.android.gms:play-services:5.0.77'
}

这在你的清单中

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

这里有完整的解释:

http://developer.android.com/google/play-services/setup.html

在这里用admob解释:

https://developers.google.com/mobile-ads-sdk/docs/#play