esteban
esteban

Reputation: 563

Cannot build apk with Jenkins using androidx libraries

Since I migrate to androidx my app, I've got an error on Jenkins when I launch the task assemble. This is error:

Program type already present: 
android.support.v4.app.INotificationSideChannel$Stub$Proxy

But I don't have this error on Android Studio, I can build the apk without any problem.

So, I tried to exclude the support-v4 module from the google play services:

implementation( "com.google.android.gms:play-services-maps:16.0.0"){
    exclude module: 'support-v4'
}
implementation ("com.google.android.gms:play-services-location:16.0.0"){
    exclude module: 'support-v4'
}
implementation ("com.google.android.gms:play-services-places:16.0.0"){
    exclude module: 'support-v4'
}

Then the apk is generate but on start the app I've got this error:

java.lang.NoClassDefFoundError: Failed resolution of: Landroid/support/v4/util/ArraySet;
   at com.google.android.gms.common.api.internal.c.<init>(Unknown Source:45)
   at com.google.android.gms.common.api.internal.c.a(Unknown Source:33)
   at com.google.android.gms.common.api.e.<init>(Unknown Source:51)
   at com.google.android.gms.common.api.e.<init>(Unknown Source:13)
   at com.google.android.gms.location.b.<init>(Unknown Source:8)
   at com.google.android.gms.location.f.a(Unknown Source:2)

But once again, everything work fine on Android studio, the problem is only on Jenkins since a migrate to Androidx.

Thanks for your help

Upvotes: 0

Views: 576

Answers (1)

esteban
esteban

Reputation: 563

Jenkins is not using the gradle.properties file that has the androidx parameters:

android.enableJetifier=true
android.useAndroidX=true

This is why is working on the local machine but on Jenkins.

Upvotes: 6

Related Questions