Тип программы уже представлен com.google.gson.FieldAttributes - PullRequest
0 голосов
/ 30 июня 2018

Моё приложение для Android отказывается строить со следующей ошибкой:

Program type already present: com.google.gson.FieldAttributes
Message{kind=ERROR, text=Program type already present: com.google.gson.FieldAttributes, sources=[Unknown source file], tool name=Optional.of(D8)}

Мои зависимости build.gradle

 dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:27.1.1'
    implementation 'com.android.support:support-v4:27.1.1'
    implementation 'com.android.support:animated-vector-drawable:27.1.1'
    implementation 'com.android.support:customtabs:27.1.1'
    implementation 'com.android.support:support-media-compat:27.1.1'
    implementation 'com.android.support:design:27.1.1'
    implementation 'com.android.support.constraint:constraint-layout:1.1.2'
    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'
    api 'com.github.Steveice10:MCProtocolLib:1.12.2-2'
    api 'com.github.Steveice10:OpenNBT:1.0'
    implementation 'com.android.support:multidex:1.0.3'
    implementation 'com.google.android.gms:play-services-ads:15.0.1'
    implementation 'com.google.android.ads.consent:consent-library:1.0.6'
    implementation 'com.github.GrenderG:Prefs:1.3' //Propably this cause problem
    implementation('com.crashlytics.sdk.android:answers:1.4.2@aar') {
        transitive = true
    }
    implementation('com.crashlytics.sdk.android:crashlytics:2.9.4@aar') {
        transitive = true
    }}

Это, вероятно, начало происходить, когда я добавил com.github.GrenderG: зависимость Prefs

Ответы [ 4 ]

0 голосов
/ 18 февраля 2019

добавить этот код в build.gradle (приложение) -

dependencies {
    configurations {
    all*.exclude group: 'com.google.code.gson'
}

Это должно решить вашу проблему.

0 голосов
/ 11 июля 2018

Добавить зависимость к файлу build.gradle

implementation 'com.google.code.gson:gson:2.8.2'
0 голосов
/ 13 сентября 2018

Добавьте эту строку в файл build.gradle.

configurations {
            all*.exclude group: 'com.google.code.gson'
        }
0 голосов
/ 30 июня 2018

После 3 часов поисков, я в конце концов нашел ответ:
Компиляция GPDR вызвала проблему

implementation ('com.google.android.ads.consent:consent-library:1.0.6') {
                exclude module: 'gson'
 }
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...