我已下载https://codeload.github.com/googleads/googleads-mobile-android-examples/zip/master它有一个移动广告示例应用程序。我通过单击工作区中的import->现有的android代码从他们的示例中导入工作区中的项目。问题是当在Android 3.0版的模拟器上运行时应用程序停止工作 这是我的logcat
03-31 20:41:21.601: E/GooglePlayServicesUtil(525): The Google Play services resources were not found. Check your project configuration to ensure that the resources are included.
03-31 20:41:21.742: E/AndroidRuntime(525): FATAL EXCEPTION: main
03-31 20:41:21.742: E/AndroidRuntime(525): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.google.example.gms.ads.banner/com.google.example.gms.ads.banner.BannerSample}: java.lang.IllegalStateException: A required meta-data tag in your app's AndroidManifest.xml does not exist. You must have the following declaration within the <application> element: <meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" />
03-31 20:41:21.742: E/AndroidRuntime(525): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1736)
03-31 20:41:21.742: E/AndroidRuntime(525): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1752)
03-31 20:41:21.742: E/AndroidRuntime(525): at android.app.ActivityThread.access$1500(ActivityThread.java:123)
03-31 20:41:21.742: E/AndroidRuntime(525): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:993)
03-31 20:41:21.742: E/AndroidRuntime(525): at android.os.Handler.dispatchMessage(Handler.java:99)
03-31 20:41:21.742: E/AndroidRuntime(525): at android.os.Looper.loop(Looper.java:126)
03-31 20:41:21.742: E/AndroidRuntime(525): at android.app.ActivityThread.main(ActivityThread.java:3997)
03-31 20:41:21.742: E/AndroidRuntime(525): at java.lang.reflect.Method.invokeNative(Native Method)
03-31 20:41:21.742: E/AndroidRuntime(525): at java.lang.reflect.Method.invoke(Method.java:491)
03-31 20:41:21.742: E/AndroidRuntime(525): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:841)
03-31 20:41:21.742: E/AndroidRuntime(525): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:599)
03-31 20:41:21.742: E/AndroidRuntime(525): at dalvik.system.NativeStart.main(Native Method)
03-31 20:41:21.742: E/AndroidRuntime(525): Caused by: java.lang.IllegalStateException: A required meta-data tag in your app's AndroidManifest.xml does not exist. You must have the following declaration within the <application> element: <meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" />
03-31 20:41:21.742: E/AndroidRuntime(525): at com.google.android.gms.common.GooglePlayServicesUtil.t(Unknown Source)
03-31 20:41:21.742: E/AndroidRuntime(525): at com.google.android.gms.common.GooglePlayServicesUtil.isGooglePlayServicesAvailable(Unknown Source)
03-31 20:41:21.742: E/AndroidRuntime(525): at com.google.android.gms.internal.y.a(Unknown Source)
03-31 20:41:21.742: E/AndroidRuntime(525): at com.google.android.gms.internal.ak.an(Unknown Source)
03-31 20:41:21.742: E/AndroidRuntime(525): at com.google.android.gms.internal.ak.a(Unknown Source)
03-31 20:41:21.742: E/AndroidRuntime(525): at com.google.android.gms.ads.AdView.loadAd(Unknown Source)
03-31 20:41:21.742: E/AndroidRuntime(525): at com.google.example.gms.ads.banner.BannerSample.onCreate(BannerSample.java:45)
03-31 20:41:21.742: E/AndroidRuntime(525): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1048)
03-31 20:41:21.742: E/AndroidRuntime(525): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1700)
03-31 20:41:21.742: E/AndroidRuntime(525): ... 11 more
这里有什么问题。我已经导入了google play services.jar
答案 0 :(得分:0)
在<application>
标记内的Android清单文件中添加以下内容:
<meta-data android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />
感谢。
答案 1 :(得分:0)
1.请在Eclipse中导入Google Play服务库项目(sdk \ extras \ google \ google_play_services)。
2.将此库项目添加到您的示例项目中(右键单击您的项目获取属性 - > Android--添加库)
3.清理并建立你的项目。
我希望这项工作正常。