当我尝试生成已签名的APK时,我收到此错误。
错误
错误:任务':app:transformClassesWithDexForRelease'执行失败。 com.android.build.api.transform.TransformException:com.android.ide.common.process.ProcessException:java.util.concurrent.ExecutionException:com.android.dex.DexException:多个dex文件定义Lcom / google / android /克/内部/ zzaj;
的build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "com.comp.app"
minSdkVersion 15
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
buildTypes.each {
it.buildConfigField 'String', 'ApiKey', keystoreProperties['Api_Key']
}
}
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/YouTubeAndroidPlayerApi.jar')
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support:design:25.3.1'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.android.support:recyclerview-v7:25.3.1'
compile 'com.android.support:cardview-v7:25.3.1'
compile 'com.google.firebase:firebase-messaging:11.0.2'
compile 'com.facebook.android:facebook-android-sdk:4.23.0'
compile 'com.facebook.android:audience-network-sdk:4.24.0'
compile 'com.google.code.gson:gson:2.7'
compile 'de.hdodenhof:circleimageview:2.1.0'
compile 'com.squareup.retrofit2:converter-gson:2.3.0'
compile 'com.squareup.retrofit2:retrofit:2.3.0'
compile 'com.squareup.picasso:picasso:2.5.2'
testCompile 'junit:junit:4.12'
}
apply plugin: 'com.google.gms.google-services'
项目级别Build.gradle
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.3'
classpath 'com.google.gms:google-services:3.1.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
mavenCentral()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
类路径
compile - Classpath for compiling the main sources.
+--- com.android.support:appcompat-v7:25.3.1
| +--- com.android.support:support-annotations:25.3.1
| +--- com.android.support:support-v4:25.3.1
| | +--- com.android.support:support-compat:25.3.1
| | | \--- com.android.support:support-annotations:25.3.1
| | +--- com.android.support:support-media-compat:25.3.1
| | | +--- com.android.support:support-annotations:25.3.1
| | | \--- com.android.support:support-compat:25.3.1 (*)
| | +--- com.android.support:support-core-utils:25.3.1
| | | +--- com.android.support:support-annotations:25.3.1
| | | \--- com.android.support:support-compat:25.3.1 (*)
| | +--- com.android.support:support-core-ui:25.3.1
| | | +--- com.android.support:support-annotations:25.3.1
| | | \--- com.android.support:support-compat:25.3.1 (*)
| | \--- com.android.support:support-fragment:25.3.1
| | +--- com.android.support:support-compat:25.3.1 (*)
| | +--- com.android.support:support-media-compat:25.3.1 (*)
| | +--- com.android.support:support-core-ui:25.3.1 (*)
| | \--- com.android.support:support-core-utils:25.3.1 (*)
| +--- com.android.support:support-vector-drawable:25.3.1
| | +--- com.android.support:support-annotations:25.3.1
| | \--- com.android.support:support-compat:25.3.1 (*)
| \--- com.android.support:animated-vector-drawable:25.3.1
| \--- com.android.support:support-vector-drawable:25.3.1 (*)
+--- com.android.support:design:25.3.1
| +--- com.android.support:support-v4:25.3.1 (*)
| +--- com.android.support:appcompat-v7:25.3.1 (*)
| +--- com.android.support:recyclerview-v7:25.3.1
| | +--- com.android.support:support-annotations:25.3.1
| | +--- com.android.support:support-compat:25.3.1 (*)
| | \--- com.android.support:support-core-ui:25.3.1 (*)
| \--- com.android.support:transition:25.3.1
| +--- com.android.support:support-annotations:25.3.1
| \--- com.android.support:support-v4:25.3.1 (*)
+--- com.android.support.constraint:constraint-layout:1.0.2
| \--- com.android.support.constraint:constraint-layout-solver:1.0.2
+--- com.android.support:recyclerview-v7:25.3.1 (*)
+--- com.android.support:cardview-v7:25.3.1
| \--- com.android.support:support-annotations:25.3.1
+--- com.google.firebase:firebase-messaging:11.0.2
| +--- com.google.firebase:firebase-iid:[11.0.2] -> 11.0.2
| | +--- com.google.android.gms:play-services-basement:[11.0.2] -> 11.0.2
| | | \--- com.android.support:support-v4:25.2.0 -> 25.3.1 (*)
| | \--- com.google.firebase:firebase-common:[11.0.2] -> 11.0.2
| | +--- com.google.android.gms:play-services-basement:[11.0.2] -> 11.0.2 (*)
| | \--- com.google.android.gms:play-services-tasks:[11.0.2] -> 11.0.2
| | \--- com.google.android.gms:play-services-basement:[11.0.2] -> 11.0.2 (*)
| +--- com.google.android.gms:play-services-basement:[11.0.2] -> 11.0.2 (*)
| \--- com.google.firebase:firebase-common:[11.0.2] -> 11.0.2 (*)
+--- com.facebook.android:facebook-android-sdk:4.23.0
| +--- com.android.support:support-v4:25.3.1 (*)
| +--- com.android.support:appcompat-v7:25.3.1 (*)
| +--- com.android.support:cardview-v7:25.3.1 (*)
| +--- com.android.support:customtabs:25.3.1
| | +--- com.android.support:support-compat:25.3.1 (*)
| | \--- com.android.support:support-annotations:25.3.1
| \--- com.parse.bolts:bolts-android:1.4.0
| +--- com.parse.bolts:bolts-tasks:1.4.0
| \--- com.parse.bolts:bolts-applinks:1.4.0
| \--- com.parse.bolts:bolts-tasks:1.4.0
+--- com.facebook.android:audience-network-sdk:4.24.0
| +--- com.android.support:appcompat-v7:25.0.0 -> 25.3.1 (*)
| +--- com.android.support:recyclerview-v7:25.0.0 -> 25.3.1 (*)
| +--- com.android.support:support-annotations:25.0.0 -> 25.3.1
| +--- com.android.support:support-v4:25.0.0 -> 25.3.1 (*)
| +--- com.google.android.exoplayer:exoplayer:r2.0.3
| | \--- com.android.support:support-annotations:24.2.0 -> 25.3.1
| \--- com.google.android.gms:play-services-ads:8.4.0
| \--- com.google.android.gms:play-services-basement:8.4.0 -> 11.0.2 (*)
+--- com.google.code.gson:gson:2.7
+--- de.hdodenhof:circleimageview:2.1.0
+--- com.squareup.retrofit2:converter-gson:2.3.0
| +--- com.squareup.retrofit2:retrofit:2.3.0
| | \--- com.squareup.okhttp3:okhttp:3.8.0
| | \--- com.squareup.okio:okio:1.13.0
| \--- com.google.code.gson:gson:2.7
+--- com.squareup.retrofit2:retrofit:2.3.0 (*)
+--- com.squareup.picasso:picasso:2.5.2
+--- com.android.support:multidex:1.0.1
\--- com.google.firebase:firebase-core:11.0.2
\--- com.google.firebase:firebase-analytics:[11.0.2] -> 11.0.2
+--- com.google.firebase:firebase-analytics-impl:[11.0.2] -> 11.0.2
| +--- com.google.android.gms:play-services-basement:[11.0.2] -> 11.0.2 (*)
| +--- com.google.firebase:firebase-iid:[11.0.2] -> 11.0.2 (*)
| +--- com.google.firebase:firebase-common:[11.0.2] -> 11.0.2 (*)
| \--- com.google.android.gms:play-services-tasks:[11.0.2] -> 11.0.2 (*)
+--- com.google.android.gms:play-services-basement:[11.0.2] -> 11.0.2 (*)
\--- com.google.firebase:firebase-common:[11.0.2] -> 11.0.2 (*)
答案 0 :(得分:0)
尝试删除
compile files('libs/YouTubeAndroidPlayerApi.jar')
因为您已经添加了带线
的YouTubeAndroidPlayerApi.jarcompile fileTree(include: ['*.jar'], dir: 'libs')
答案 1 :(得分:0)
添加您的依赖项:
compile 'com.google.android.gms:play-services-ads:11.0.2'
此行将强制使用新的广告库。您的com.google.firebase:firebase-messaging
部队com.google.android.gms:play-services-basement:11.0.2