因为我已更新到Android Studio 3.1,我的项目不再运行了。我在互联网上搜索了一个解决方案,没有任何积极的结果。 这是我在Logcat中得到的错误:
--------- beginning of crash
04-13 13:33:55.466 12720-12720/? E/AndroidRuntime: FATAL EXCEPTION: main
Process: woopy.domain.com.woopy, PID: 12720
java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/android/gms/common/internal/zzbq;
at com.google.firebase.provider.FirebaseInitProvider.attachInfo(Unknown Source:2)
at android.app.ActivityThread.installProvider(ActivityThread.java:6239)
at android.app.ActivityThread.installContentProviders(ActivityThread.java:5805)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5722)
at android.app.ActivityThread.-wrap1(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1656)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6494)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.android.gms.common.internal.zzbq" on path: DexPathList[[zip file "/data/app/woopy.domain.com.woopy-KqNv1gE1ZomaesHCq33DJw==/base.apk"],nativeLibraryDirectories=[/data/app/woopy.domain.com.woopy-KqNv1gE1ZomaesHCq33DJw==/lib/x86, /system/lib, /vendor/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:125)
at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
at com.google.firebase.provider.FirebaseInitProvider.attachInfo(Unknown Source:2)
at android.app.ActivityThread.installProvider(ActivityThread.java:6239)
at android.app.ActivityThread.installContentProviders(ActivityThread.java:5805)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5722)
at android.app.ActivityThread.-wrap1(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1656)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6494)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
04-13 13:33:55.567 12720-12727/? I/zygote: Debugger is no longer active
这是我的build.gradle(模块:应用)文件:
android {
compileSdkVersion 27
buildToolsVersion "27.0.3"
defaultConfig {
applicationId "woopy.domain.com.woopy"
minSdkVersion 21
targetSdkVersion 27
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
// Enabling multidex support.
multiDexEnabled true
aaptOptions {
cruncherEnabled = false
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
dexOptions {
javaMaxHeapSize "4g"
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.squareup.okhttp3:okhttp:3.10.0'
//noinspection GradleCompatible
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support:support-v4:27.1.1'
implementation 'com.android.support:design:27.1.1'
testImplementation 'junit:junit:4.12'
implementation 'com.parse:parse-android:+'
implementation 'com.parse.bolts:bolts-android:1.+'
//noinspection GradleCompatible
implementation 'com.google.android.gms:play-services-maps:+'
implementation 'com.google.android.gms:play-services-auth:12.0.1'
implementation 'com.google.android.gms:play-services-location:12.0.1'
implementation 'com.google.android.gms:play-services:+'
implementation 'com.google.android.gms:play-services-ads:+'
implementation 'de.hdodenhof:circleimageview:2.2.0'
implementation 'com.facebook.android:facebook-android-sdk:4.+'
implementation 'com.parse:parsefacebookutils-v4-android:1.10.3@aar'
implementation 'com.commit451:PhotoView:1.2.4'
}
这是我的build.gradle(项目:appname):
buildscript {
repositories {
jcenter()
maven { url 'https://maven.google.com' }
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
maven { url "https://maven.google.com" }
maven {
url 'https://maven.google.com/'
name 'Google'
}
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
构建成功,但应用程序在启动时崩溃。
修改 它现在不再构建成功,它会在Build消息控制台中抛出这个绝对奇怪的错误:
AGPBI: {"kind":"error","text":"Program type already present: com.google.android.gms.location.places.zza","sources":[{}],"tool":"D8"}
:app:transformDexArchiveWithExternalLibsDexMergerForDebug FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'
答案 0 :(得分:13)
尝试将此依赖项添加到您的gradle文件中:
implementation 'com.android.support:multidex:1.0.3'
此外,您应该为支持和播放服务库使用相同的版本。你应该避免使用" +" 来获取最新版本。改变这一部分:
implementation 'com.google.android.gms:play-services-maps:+'
implementation 'com.google.android.gms:play-services-auth:12.0.1'
implementation 'com.google.android.gms:play-services-location:12.0.1'
implementation 'com.google.android.gms:play-services:+'
implementation 'com.google.android.gms:play-services-ads:+'
进入这个:
implementation 'com.google.android.gms:play-services-maps:12.0.1'
implementation 'com.google.android.gms:play-services-auth:12.0.1'
implementation 'com.google.android.gms:play-services-location:12.0.1'
implementation 'com.google.android.gms:play-services:12.0.1'
implementation 'com.google.android.gms:play-services-ads:12.0.1'
编辑:您也可以将此部分添加到您的应用级草图文件中,然后重试。我没有看到有人试过这个,但它可能有用。
allprojects {
repositories {
//...
}
subprojects {
project.configurations.all {
resolutionStrategy.eachDependency { details ->
if (details.requested.group == 'com.google.android.gms'
&& !details.requested.name.contains('multidex') ) {
details.useVersion "12.0.1"
}
}
}
}
}
2ND UPDATE:刚看到这一点,下面的依赖项涵盖了所有其他依赖项,然后它可能会导致重复问题。删除其他依赖项并保留此项:
implementation 'com.google.android.gms:play-services:12.0.1'
答案 1 :(得分:6)
我遇到了同样的问题,我解决了这个问题。将所有com.google.android.gms:play-services
个依赖关系更新为15.0.0
。它应该是这样的:
implementation 'com.google.android.gms:play-services-maps:15.0.0'
implementation 'com.google.android.gms:play-services-auth:15.0.0'
implementation 'com.google.android.gms:play-services-location:15.0.0'
implementation 'com.google.android.gms:play-services:15.0.0'
implementation 'com.google.android.gms:play-services-ads:15.0.0'
一旦你这样做,它应该解决问题,找到NoClassDefFoundError
错误(至少它对我有用)。
答案 2 :(得分:2)
这对我有用,我在我的项目gradle文件中添加了以下子项目块
allprojects {
repositories {
//...
}
subprojects {
project.configurations.all {
resolutionStrategy.eachDependency { details ->
if (details.requested.group == 'com.google.android.gms'
&& !details.requested.name.contains('multidex') ) {
details.useVersion "+"
}
if (details.requested.group == 'com.google.firebase'
&& !details.requested.name.contains('multidex') ) {
details.useVersion "+"
}
}
}
}
}
答案 3 :(得分:1)
您可能正在使用不同版本的库。
重要的一点是,您可能正在使用使用不同播放服务版本的外部库(可能更旧)。请仔细检查所有外部库更新,并将它们全部匹配
答案 4 :(得分:1)
我通过删除
解决了这个问题implementation "com.google.android.gms:play-services:$play_service_version"
并且只保留重要的依赖关系。
就我而言,我有
implementation "com.google.android.gms:play-services:$play_service_version"
implementation "com.google.android.gms:play-services-location:$play_service"
我删除了
implementation "com.google.android.gms:play-services:$play_service_version"
并保持
implementation "com.google.android.gms:play-services-location:$play_service"
此处play_service_version
& play_service
是版本
答案 5 :(得分:1)
implementation 'com.google.android.gms:play-services-maps:15.0.0'
implementation 'com.google.android.gms:play-services-auth:15.0.0'
implementation 'com.google.android.gms:play-services-location:15.0.0'
implementation 'com.google.android.gms:play-services:15.0.0'
implementation 'com.google.android.gms:play-services-ads:15.0.0'
This helped me.
答案 6 :(得分:0)
@cubycode我也遇到了同样的问题,我尝试了这里列出的所有解决方案。
答案 7 :(得分:0)
即使使用“ zzbq;”,我也收到相同的错误;最后
在应用程序build.gradle中,我必须将com.google.firebase:firebase-core更新为16.0.1,以匹配react-native-firebase build.gradle中的同一行
示例:
app / build.gradle
implementation 'com.google.firebase:firebase-core:16.0.1'
react-native-firebase / android / build.gradle
compileOnly "com.google.firebase:firebase-core:16.0.1"
答案 8 :(得分:0)
我有完全一样的问题。我尝试了很多事情,但这实际上是有帮助的。
我将此添加到了我的项目中:
implementation 'com.google.android.gms:play-services-base:16.0.1'
。
错误消失了。
然后我将其删除。一切都还好。清理了项目-仍然没有错误。
不要问我背后的逻辑,它对我有用,仅此而已。
答案 9 :(得分:0)
步骤1:
这种错误会抛出一些日志。仔细阅读以找出导致此问题的依赖项
第2步:
将该依赖关系更新为最新版本。
例如:在我的情况下,它会引发材料设计依赖性方面的错误。我只是将该依赖关系更新为最新版本-问题已解决
我的错误日志-找不到类“ com.google.android.material.tabs ........”