找不到google_play_services_version

时间:2017-03-28 07:33:55

标签: java android gradle google-play-services

引起:java.lang.IllegalStateException:应用程序的AndroidManifest.xml中不需要的元数据标记不存在。您必须在元素中包含以下声明:

app.gradle

dependencies {
    compile 'io.nlopez.smartlocation:library:3.3.1'
    compile 'com.android.support:appcompat-v7:25.2.0'
    compile 'com.android.support:support-v4:25.2.0'
    compile 'com.loopj.android:android-async-http:1.4.9'
    compile 'com.nostra13.universalimageloader:universal-image-loader:1.9.5'
    compile 'com.google.firebase:firebase-messaging:10.2.1'
    compile 'com.google.firebase:firebase-ads:10.2.1'
    compile 'com.google.android.gms:play-services-location:10.2.1'
    compile 'com.google.firebase:firebase-crash:9.6.0'
    compile  'com.google.android.gms:play-services:10.2.1'
}
  

当我用Google搜索时,我得到了以下答案

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

但我收到一条错误,指出@ integer / google_play_services_version无法解析符号   我也得到了如果我使用最新的编译'com.google.android.gms:play-services:10.2.1'   并且无需定义元数据

我收到以下代码的错误

public boolean isGooglePlayServicesAvailable(Activity activity) {
    GoogleApiAvailability googleApiAvailability = GoogleApiAvailability.getInstance();
    int status = googleApiAvailability.isGooglePlayServicesAvailable(activity);
    if (status != ConnectionResult.SUCCESS) {
        if (googleApiAvailability.isUserResolvableError(status)) {
            googleApiAvailability.getErrorDialog(activity, status, 2404).show();
        }
        return false;
    }}

现在有人可以帮我解决这个问题吗?

错误日志

 03-28 14:48:23.297 15387-15387/app.thecity E/dalvikvm: Could not find class 'android.graphics.drawable.RippleDrawable', referenced from method android.support.v7.widget.AppCompatImageHelper.hasOverlappingRendering
03-28 14:48:25.441 15387-15387/app.thecity E/AndroidRuntime: FATAL EXCEPTION: main
                                                             Process: app.thecity, PID: 15387
                                                             java.lang.RuntimeException: Unable to start activity ComponentInfo{app.thecity/app.thecity.ActivityMain}: 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" />
                                                                 at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2338)
                                                                 at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2390)
                                                                 at android.app.ActivityThread.access$800(ActivityThread.java:151)
                                                                 at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1321)
                                                                 at android.os.Handler.dispatchMessage(Handler.java:110)
                                                                 at android.os.Looper.loop(Looper.java:193)
                                                                 at android.app.ActivityThread.main(ActivityThread.java:5292)
                                                                 at java.lang.reflect.Method.invokeNative(Native Method)
                                                                 at java.lang.reflect.Method.invoke(Method.java:515)
                                                                 at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:828)
                                                                 at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:644)
                                                                 at dalvik.system.NativeStart.main(Native Method)
                                                              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" />
                                                                 at com.google.android.gms.common.zzg.zzaH(Unknown Source)
                                                                 at com.google.android.gms.common.zzg.isGooglePlayServicesAvailable(Unknown Source)
                                                                 at com.google.android.gms.common.zze.isGooglePlayServicesAvailable(Unknown Source)
                                                                 at com.google.android.gms.common.GoogleApiAvailability.isGooglePlayServicesAvailable(Unknown Source)
                                                                 at com.icanappz.fcmpush.Push.FCMActivity.isGooglePlayServicesAvailable(FCMActivity.java:389)
                                                                 at com.icanappz.fcmpush.Push.FCMActivity.onCreate(FCMActivity.java:151)
                                                                 at app.thecity.ActivityMain.onCreate(ActivityMain.java:63)
                                                                 at android.app.Activity.performCreate(Activity.java:5264)
                                                                 at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1088)
                                                                 at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2302)
                                                                 at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2390) 
                                                                 at android.app.ActivityThread.access$800(ActivityThread.java:151) 
                                                                 at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1321) 
                                                                 at android.os.Handler.dispatchMessage(Handler.java:110) 
                                                                 at android.os.Looper.loop(Looper.java:193) 
                                                                 at android.app.ActivityThread.main(ActivityThread.java:5292) 
                                                                 at java.lang.reflect.Method.invokeNative(Native Method) 
                                                                 at java.lang.reflect.Method.invoke(Method.java:515) 
                                                                 at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:828) 
                                                                 at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:644) 
                                                                 at dalvik.system.NativeStart.main(Native Method) 

0 个答案:

没有答案