我更新到Android Studio 3.0后出现了这个错误。我尝试了许多类似问题的解决方法,但是都没有效果。
这里是错误信息:
我发现当我移除库'com.google.android.gms:play-services-maps:11.4.2'时,我的项目可以成功构建。但我需要在我的项目中使用这个库,请问有人知道如何解决这个问题吗?
我的完整build.gradle文件如下:
这里是错误信息:
![enter image description here](https://istack.dev59.com/3yF0n.webp)
我的完整build.gradle文件如下:
buildscript {
repositories {
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'io.fabric.tools:gradle:1.+'
}
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
repositories {
maven { url 'https://maven.fabric.io/public' }
google()
}
android {
compileSdkVersion 25
buildToolsVersion '26.0.2'
defaultConfig {
applicationId "vn.com.ttsoft.dhd"
minSdkVersion 21
targetSdkVersion 25
versionCode 14
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
useLibrary 'org.apache.http.legacy'
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
debug {
// Disable fabric build ID generation for debug builds
ext.enableCrashlytics = false
}
}
productFlavors {
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile files('libs/android-async-http-1.4.4.jar')
compile files('libs/google-play-services.jar')
compile files('libs/gson-2.3.1.jar')
compile('com.crashlytics.sdk.android:crashlytics:2.6.8@aar') {
transitive = true;
}
compile 'com.github.pavlospt:roundedletterview:1.2'
compile 'com.github.PhilJay:MPAndroidChart:v3.0.1'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.android.support:appcompat-v7:25.4.0'
compile 'com.android.support:design:25.4.0'
compile 'com.android.support:support-v4:25.4.0'
compile 'com.google.android.gms:play-services-maps:11.4.2'
compile 'me.tatarka.support:jobscheduler:0.1.1'
compile 'com.evernote:android-job:1.1.8'
testCompile 'junit:junit:4.12'
compile files('libs/activation.jar')
compile files('libs/additionnal.jar')
compile files('libs/mail.jar')
}
这是一个Gradle构建脚本,用于在Android应用程序中使用Fabric和一些其他依赖项。其中包括Google Play服务、Espresso测试框架、Android异步HTTP库、Gson JSON解析器以及一些UI库等。
com.google.android.gms:play-services-maps:11.4.2
,在此处...compile files('libs/google-play-services.jar')
,最后在此处...compile fileTree(include: ['*.jar'], dir: 'libs')
。Gradle 2.3.3宽容一些。Gradle 3.0.0不喜欢多个Dex并抛出构建错误。要么删除.jar文件,要么删除compile 'com.google.android.gms:play-services-maps:11.4.2'
。 - Simon Hutton