简体   繁体   中英

Unable to resolve the error - java.lang.NoClassDefFoundError: com.google.android.gms.R$string

I have seen this question already in StackOverflow but the solutions there just mentioned to import the google-play-services. I did that but still this error is not going and my app is crashing on start. I want to use the google maps and have obtained the API key and put it in the app. Also as I said , I already imported the google-play-services but things are not working and the app is crashing on running it on my mobile. My stacktrace is-:

    12-26 12:11:41.563: E/AndroidRuntime(17574): FATAL EXCEPTION: main
    12-26 12:11:41.563: E/AndroidRuntime(17574): Process: com.example.pranav.iskconapp, PID: 17574
    12-26 12:11:41.563: E/AndroidRuntime(17574): java.lang.NoClassDefFoundError: com.google.android.gms.R$string
    12-26 12:11:41.563: E/AndroidRuntime(17574):    at com.google.android.gms.measurement.zza.<init>(Unknown Source)
    12-26 12:11:41.563: E/AndroidRuntime(17574):    at com.google.android.gms.measurement.zza.zzaR(Unknown Source)
    12-26 12:11:41.563: E/AndroidRuntime(17574):    at com.google.android.gms.measurement.internal.zzn.zziJ(Unknown Source)
    12-26 12:11:41.563: E/AndroidRuntime(17574):    at com.google.android.gms.measurement.internal.zzz.zza(Unknown Source)
    12-26 12:11:41.563: E/AndroidRuntime(17574):    at com.google.android.gms.measurement.internal.zzw.<init>(Unknown Source)
    12-26 12:11:41.563: E/AndroidRuntime(17574):    at com.google.android.gms.measurement.internal.zzaa.zzDj(Unknown Source)
    12-26 12:11:41.563: E/AndroidRuntime(17574):    at com.google.android.gms.measurement.internal.zzw.zzaT(Unknown Source)
    12-26 12:11:41.563: E/AndroidRuntime(17574):    at com.google.android.gms.measurement.AppMeasurementContentProvider.onCreate(Unknown Source)
    12-26 12:11:41.563: E/AndroidRuntime(17574):    at android.content.ContentProvider.attachInfo(ContentProvider.java:1656)
    12-26 12:11:41.563: E/AndroidRuntime(17574):    at android.content.ContentProvider.attachInfo(ContentProvider.java:1627)
    12-26 12:11:41.563: E/AndroidRuntime(17574):    at android.app.ActivityThread.installProvider(ActivityThread.java:5008)
    12-26 12:11:41.563: E/AndroidRuntime(17574):    at android.app.ActivityThread.installContentProviders(ActivityThread.java:4582)
    12-26 12:11:41.563: E/AndroidRuntime(17574):    at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4522)
    12-26 12:11:41.563: E/AndroidRuntime(17574):    at android.app.ActivityThread.access$1500(ActivityThread.java:151)
    12-26 12:11:41.563: E/AndroidRuntime(17574):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1381)
    12-26 12:11:41.563: E/AndroidRuntime(17574):    at android.os.Handler.dispatchMessage(Handler.java:110)
    12-26 12:11:41.563: E/AndroidRuntime(17574):    at android.os.Looper.loop(Looper.java:193)
    12-26 12:11:41.563: E/AndroidRuntime(17574):    at android.app.ActivityThread.main(ActivityThread.java:5292)
    12-26 12:11:41.563: E/AndroidRuntime(17574):    at java.lang.reflect.Method.invokeNative(Native Method)
    12-26 12:11:41.563: E/AndroidRuntime(17574):    at java.lang.reflect.Method.invoke(Method.java:515)
    12-26 12:11:41.563: E/AndroidRuntime(17574):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:828)
    12-26 12:11:41.563: E/AndroidRuntime(17574):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:644)
    12-26 12:11:41.563: E/AndroidRuntime(17574):    at dalvik.system.NativeStart.main(Native Method)
    12-26 12:11:41.636: E/STBMonitorReceiver(15953): dropboxTag:data_app_crash;dropboxTime:1451112101576
    12-26 12:11:41.654: E/STBIntentService(15953): Service Started.. 
    12-26 12:11:41.691: E/StabilityMonitor(15953): [APRReport] get APRReport from memory
    12-26 12:11:41.756: E/STBIntentService(15953): send error message:data_app_crash;1451112101576(pkgName:com.example.pranav.iskconapp;version:1.0;versionCode:1) to BBS for ANR/FC/TOMB_STONE...
    12-26 12:11:41.757: E/STBIntentService(15953): Add /data/system/dropbox/data_app_crash@1451112101576.txt into short queue...
    12-26 12:11:41.757: E/STBIntentService(15953): DMC enabled...
    12-26 12:11:41.758: E/STBIntentService(15953): alarm had already been set...
    12-26 12:11:41.759: E/STBIntentService(15953): Service Destroyed.. 
    12-26 12:11:42.158: E/SharedPreferencesImpl(1051): Couldn't create directory for SharedPreferences file /data/data/com.fihtdc.weather/shared_prefs/Configs.xml
    12-26 12:11:42.159: E/SharedPreferencesImpl(1051): Couldn't create directory for SharedPreferences file /data/data/com.fihtdc.weather/shared_prefs/Configs.xml

After adding the google-play-services project to my project it adds the folder of google-play-services

在此处输入图片说明

inside it there are 3 files-: 在此处输入图片说明

You need to add dependency in build.gradle in Android studio.

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.google.android.gms:play-services:8.1.0'
 }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM