我正在尝试运行Google Cloud消息系统,logcat向我展示了这一点 元数据应该包括android名称和android值,这已经是 存在于清单
中3016-3016/com.icanappz.gcmimplementation E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: com.icanappz.gcmimplementation, PID: 3016
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.icanappz.gcmimplementation/com.icanappz.gcmimplementation.MainActivity}: java.lang.IllegalStateException: The meta-data tag in your app's AndroidManifest.xml does not have the right value. Expected 6587000 but found 6171000. 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" />
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2298)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2360)
at android.app.ActivityThread.access$800(ActivityThread.java:144)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1278)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5221)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
Caused by: java.lang.IllegalStateException: The meta-data tag in your app's AndroidManifest.xml does not have the right value. Expected 6587000 but found 6171000. 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" />
at com.google.android.gms.common.GooglePlayServicesUtil.D(Unknown Source)
at com.google.android.gms.common.GooglePlayServicesUtil.isGooglePlayServicesAvailable(Unknown Source)
at com.icanappz.gcmimplementation.MainActivity.onCreate(MainActivity.java:112)
at android.app.Activity.performCreate(Activity.java:5933)
这是logcat,这是最主要的:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.icanappz.gcmimplementation"
android:versionCode="2"
android:versionName="1.1.0" >
<uses-sdk
android:minSdkVersion="9"
android:targetSdkVersion="21" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<!-- This app has permission to register and receive data message. -->
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<!-- Permission to vibrate -->
<uses-permission android:name="android.permission.VIBRATE" />
<!-- Creates a custom permission so only this app can receive its messages. -->
<permission
android:name="com.icanappz.gcmimplementation.permission.C2D_MESSAGE"
android:protectionLevel="signature" />
<uses-permission android:name="com.icanappz.gcmimplementation.permission.C2D_MESSAGE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/icanTheme" >
<meta-data
android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version"/>
<activity
android:name="com.icanappz.gcmimplementation.MainActivity"
android:theme="@style/Theme.AppCompat.Light"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.icanappz.gcmimplementation.DailogeNotice"
android:theme="@style/AppTheme.Dialog" >
</activity>
<activity
android:name="com.icanappz.gcmimplementation.CustomeWebView"
android:theme="@style/Theme.AppCompat.Light" >
</activity>
<activity
android:name="com.icanappz.gcmimplementation.PreferenceActivity"
android:theme="@style/Theme.AppCompat.Light" >
</activity>
<activity
android:name="com.google.android.gms.ads.AdActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize" />
<receiver
android:name="com.icanappz.gcmimplementation.GcmBroadcastReceiver"
android:permission="com.google.android.c2dm.permission.SEND" >
<intent-filter>
<!-- Receives the actual messages. -->
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
<category android:name="com.icanappz.gcmimplementation" />
</intent-filter>
</receiver>
<service android:name="com.icanappz.gcmimplementation.GcmIntentService" />
</application>
</manifest>
答案 0 :(得分:1)
您没有收到错误消息。它说:
引起:java.lang.IllegalStateException:您的元数据标记 应用程序的AndroidManifest.xml没有正确的值。预期 6587000但找到了6171000.您必须拥有以下声明 在元素内:
和
expected 6587000 but found 6171000.
在这里至关重要。它只是意味着您构建的应用程序更新版本(6587000),而不是您在设备/模拟器(6171000)上安装的尝试运行应用程序。
我还有一些担心,你有不正确的代码处理这种情况,因为你应该告诉用户这个并要求升级而不是崩溃。实际上,您应该查看GooglePlayServiceUtil类,尤其是isGooglePlayServicesAvailable并正确处理返回的代码:
if( GooglePlayServicesUtil.isUserRecoverableError( errorCode ) ) {
GooglePlayServicesUtil.getErrorDialog(errorCode, null, requestCode)
}
每当用户可恢复错误发生时包括:
ConnectionResult.SERVICE_VERSION_UPDATE_REQUIRED
ConnectionResult.SERVICE_MISSING
ConnectionResult.SERVICE_DISABLED
ConnectionResult.SERVICE_INVALID
答案 1 :(得分:1)
您需要将此元数据添加到AndroidManifest.xml
内的<application>
:
<meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" />
您在获取正确的Google Play服务版本时不会遇到任何问题。
答案 2 :(得分:1)
您很可能不会从您的&#34;依赖&#34;中取出JAR。项目。因此,如果其中一个版本得到更新,则JAR和Google项目处于不同的版本。您在LogCat中获得的错误完全是误导性的。
如何解决?
从&#34; real&#34;的/ libs /文件夹中添加.jar google-play-services_lib
项目(来自您的工作区或直接来自/ sdk / extras / google / ...,具体取决于您的工作区/项目设置),以便从那里编译新的jar。
更新SDK管理器中的内容后,您的错误出现在我的屏幕上,我花了3个小时来解决这个问题,现在又花30分钟向人们解释如何修复并将其发布到所有人的手中问题
我讨厌Android。