I am developing an Android library. So, I have a module that will be the .aar file.
This is the Graddle file of this module:
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'
}
Aside, I have another module (app module) which I use to test this library, asa dummy app. I have that library loaded here too, since if I don`t have it it will not compile, This is the Graddle of the app module:
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'
}
This way, I am having the error Program type already present: com.folder.servicehelper.BuildConfig Message{kind=ERROR, text=Program type already present: com.folder.servicehelper.BuildConfig, sources=[Unknown source file], tool name=Optional.of(D8)}
The BuildConfig class is inside the offending_library of my graddle files.
I tried to delete the .aar file of the libs folder of the app module, but that way it doesn't compiles. Tried to do
implementation (name:'offending_library_2.0.0', ext:'aar'){
exclude group:'com.folder.servicehelper'
}
but the result is the same.
Any idea of how could I get rid of that error?
Thank you.
that there are two BuildConfig
included, comes from the AAR
being referenced twice:
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar', '*.aar'])
implementation (name:'offending_library_2.0.0', ext:'aar')
}
when only including ['*.jar']
, this should be resolved.
to nevertheless include the AAR
, one can define the libs
directory as flat repository:
allprojects {
repositories {
...
flatDir { dirs "libs" }
}
}
and then use this syntax in the module-level build.gradle
:
dependencies {
...
implementation "com.my.company.domain:offending_library:2.0.0@aar"
}
the documentation: Managing Transitive Dependencies.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With