首页 > 解决方案 > 如何在gradle中修复“程序类型已经存在”?

问题描述

我还是个新手,还是个学生。我正在尝试在 Android Studio 中构建一个应用程序,但我不知道在 gradle 中添加或删除某些内容时哪里出错了。

我检查了许多与此错误相关的不同 StackOverflow 问题,但答案都是特定于某些库的。

从其他 StackOverflow 答案中,我收集到它与我的 gradle 文件有关。所以,这里是 app/build.gradle:

    `apply plugin: 'com.android.application'

    android {
        compileSdkVersion 28
        defaultConfig {
            applicationId "com.example.jaaay.firebaseregister"
            minSdkVersion 21
            targetSdkVersion 28
            versionCode 1
            versionName "1.0"
            testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        }
        buildTypes {
            release {
                minifyEnabled false
                proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            }
        }
        packagingOptions {
            pickFirst 'lib/armeabi-v7a/libassmidi.so'
            pickFirst 'lib/x86/libassmidi.so'
            exclude 'META-INF/DEPENDENCIES'
            exclude 'META-INF/LICENSE'
            exclude 'META-INF/LICENSE.txt'
            exclude 'META-INF/license.txt'
            exclude 'META-INF/NOTICE'
            exclude 'META-INF/NOTICE.txt'
            exclude 'META-INF/notice.txt'
            exclude 'META-INF/ASL2.0'
        }
    }

dependencies {

    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    implementation 'com.android.support:support-annotations:28.0.0'
    //noinspection GradleCompatible
    implementation 'com.android.support:appcompat-v7:28.0.0'
    implementation 'com.google.firebase:firebase-database:17.0.0'
    implementation 'com.android.support:recyclerview-v7:28.0.0'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test:runner:1.2.0'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
    implementation 'com.google.firebase:firebase-core:16.0.9'
    implementation 'com.google.firebase:firebase-auth:17.0.0'
    implementation 'com.google.firebase:firebase-storage:17.0.0'
    implementation files('libs/CircleImageView-master/gradle/wrapper/gradle-wrapper.jar')
    implementation 'de.hdodenhof:circleimageview:3.0.0'
    implementation files('libs/Android-Image-Cropper-master/gradle/gradle/wrapper/gradle-wrapper.jar')
    implementation 'com.theartofdev.edmodo:android-image-cropper:2.8.0'

}
apply plugin: 'com.google.gms.google-services'`

这是问题:

Program type already present: org.gradle.cli.CommandLineOption
Message{kind=ERROR, text=Program type already present: org.gradle.cli.CommandLineOption, sources=[Unknown source file], tool name=Optional.of(D8)}

标签: javaandroid

解决方案


推荐阅读