我已经在StackOverflow中看到过这个问题,但是刚才提到的解决方案是导入google-play-services。我这样做但仍然没有这个错误,我的应用程序在启动时崩溃。我想使用谷歌地图并获得API密钥并将其放入应用程序。另外正如我所说的,我已经导入了谷歌播放服务,但事情没有用,应用程序在我的手机上运行时崩溃了。我的堆栈跟踪是 - :
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
将google-play-services项目添加到我的项目后,它添加了google-play-services的文件夹
答案 0 :(得分:1)
您需要在Android studio中的build.gradle中添加依赖项。
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.google.android.gms:play-services:8.1.0'
}