Тип программы уже присутствует: com.folder.servicehelper.BuildConfig - PullRequest
0 голосов
/ 01 октября 2018

Я занимаюсь разработкой библиотеки Android.Итак, у меня есть модуль, который будет файлом .aar.

Это файл Graddle этого модуля:

apply plugin: 'com.android.library'

android {
compileSdkVersion 28



defaultConfig {
    minSdkVersion 16
    targetSdkVersion 28
    versionCode 1
    versionName "1.0"
    multiDexEnabled true
    testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"

}

buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}

}

dependencies {
implementation fileTree(include: ['*.jar', '*.aar'], dir: 'libs')
implementation 'com.esri.arcgis.android:arcgis-android:10.2.9'
implementation 'com.squareup.okhttp3:okhttp:3.11.0'
implementation 'com.android.support:appcompat-v7:28.0.0-rc02'
implementation (name:'offending_library_2.0.0', ext:'aar')
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'
}

Кроме того, у меня есть другой модуль (модуль приложения), который яиспользовать для проверки этой библиотеки, как фиктивное приложение.У меня здесь тоже загружена эта библиотека, поскольку, если у меня ее нет, она не будет компилироваться. Это Graddle модуля приложения:

apply plugin: 'com.android.application'

android {
compileSdkVersion 28
defaultConfig {
    applicationId "com.my.company.domain"
    minSdkVersion 16
    targetSdkVersion 28
    versionCode 1
    versionName "1.0"
    testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
packagingOptions{
    exclude 'META-INF/LGPL2.1'
    exclude 'META-INF/LICENSE'
    exclude 'META-INF/NOTICE'
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}
}

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar', '*.aar'])
implementation 'com.esri.arcgis.android:arcgis-android:10.2.9'
implementation 'com.squareup.okhttp3:okhttp:3.11.0'
implementation 'com.android.support:appcompat-v7:28.0.0-rc02'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation (name:'offending_library_2.0.0', ext:'aar')
implementation project (':arcgislibrary')<----- This is the other module
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'
}

Таким образом, у меня уже есть ошибка Тип программыpresent: com.folder.servicehelper.BuildConfig Сообщение {kind = ERROR, text = тип программы уже присутствует: com.folder.servicehelper.BuildConfig, sources = [неизвестный исходный файл], имя инструмента = Optional.of (D8)}

Класс BuildConfig находится в каталоге abusendinglibrary моих файлов graddle.

Я попытался удалить файл .aar из папки libs модуля приложения, но таким образом он не компилируется.Пытался сделать

implementation (name:'offending_library_2.0.0', ext:'aar'){
    exclude group:'com.folder.servicehelper'
}

, но результат тот же.

Есть идеи, как мне избавиться от этой ошибки?

Спасибо.

1 Ответ

0 голосов
/ 16 октября 2018

, что есть два BuildConfig включенных, происходит от AAR, на который ссылаются дважды:

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar', '*.aar'])
    implementation (name:'offending_library_2.0.0', ext:'aar')
}

, когда только включает ['*.jar'], это должно быть разрешено.

втем не менее, включив AAR, можно определить каталог libs как плоский репозиторий :

allprojects {
    repositories {
        ...
        flatDir { dirs "libs" }
    }
}

и затем использовать этот синтаксис на уровне модуля build.gradle:

dependencies {
    ...
    implementation "com.my.company.domain:offending_library:2.0.0@aar"
}

документация: Управление переходными зависимостями .

...