我陷入了这个错误。也无法生成APK。
应用程序级别build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.xyz"
minSdkVersion 16
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
debug {
zipAlignEnabled false
}
}
lintOptions {
abortOnError false // true by default
checkAllWarnings false
checkReleaseBuilds false
checkDependencies false
ignoreWarnings true // false by default
quiet true // false by default
}
dexOptions {
javaMaxHeapSize "4g"
preDexLibraries = false
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
packagingOptions {
exclude 'META-INF/ASL2.0'
exclude 'META-INF/LICENSE'
exclude 'META-INF/NOTICE'
}}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:design:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation 'com.android.support:cardview-v7:28.0.0'
implementation 'com.google.code.gson:gson:2.8.5'
implementation 'com.jakewharton:butterknife:8.8.1'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1'
implementation 'com.github.bumptech.glide:glide:4.8.0'
annotationProcessor 'com.github.bumptech.glide:compiler:4.8.0'
implementation 'com.googlecode.libphonenumber:libphonenumber:7.2.2'
implementation 'com.karumi:dexter:4.2.0'
implementation 'com.hbb20:ccp:2.2.3'
implementation 'com.squareup.picasso:picasso:2.71828'
implementation 'com.google.firebase:firebase-core:16.0.6'
implementation 'com.google.firebase:firebase-auth:16.1.0'
// implementation 'com.google.firebase:firebase-database:16.0.5'
implementation 'com.google.firebase:firebase-storage:16.0.5'
implementation ('com.google.firebase:firebase-firestore:17.1.5')
implementation 'com.google.firebase:firebase-messaging:17.3.4'
implementation 'com.linchaolong.android:imagepicker:1.5'
implementation 'com.android.support:multidex:1.0.3'
} 应用插件:“ com.google.gms.google-services”
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
classpath 'com.google.gms:google-services:4.2.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}}
错误
Caused by: com.android.build.api.transform.TransformException: Error while generating the main dex list.
at com.android.build.gradle.internal.transforms.D8MainDexListTransform.transform(D8MainDexListTransform.kt:144)
at com.android.build.gradle.internal.pipeline.TransformTask$2.call(TransformTask.java:239)
at com.android.build.gradle.internal.pipeline.TransformTask$2.call(TransformTask.java:235)
at com.android.builder.profile.ThreadRecorder.record(ThreadRecorder.java:102)
Caused by: com.android.builder.multidex.D8MainDexList$MainDexListException: com.android.tools.r8.errors.CompilationError: Program type already present: com.google.protobuf.DescriptorProtos$1
at com.android.builder.multidex.D8MainDexList.generate(D8MainDexList.java:87)
at com.android.build.gradle.internal.transforms.D8MainDexListTransform.transform(D8MainDexListTransform.kt:131)
Caused by: com.android.tools.r8.errors.CompilationError: Program type already present: com.google.protobuf.DescriptorProtos$1
at com.android.tools.r8.utils.ProgramClassCollection.resolveClassConflictImpl(ProgramClassCollection.java:64)
at com.android.tools.r8.utils.ProgramClassCollection.lambda$create$0(ProgramClassCollection.java:25)
at java.util.concurrent.ConcurrentHashMap.merge(ConcurrentHashMap.java:1990)
at com.android.tools.r8.utils.ProgramClassCollection.create(ProgramClassCollection.java:24)
at com.android.tools.r8.graph.LazyLoadedDexApplication$Builder.build(LazyLoadedDexApplication.java:124)
at com.android.tools.r8.dex.ApplicationReader.read(ApplicationReader.java:123)
at com.android.tools.r8.dex.ApplicationReader.read(ApplicationReader.java:86)
at com.android.tools.r8.GenerateMainDexList.run(GenerateMainDexList.java:40)
at com.android.tools.r8.GenerateMainDexList.run(GenerateMainDexList.java:110)
at com.android.builder.multidex.D8MainDexList.generate(D8MainDexList.java:83)
我已经尝试了Stackoverflow的许多解决方案,但是仍然没有成功,因此,如果有人遇到此类错误,或者您有任何解决方案,请从中帮助我。
谢谢