无法使用 androidx 库与 Jenkins 构建 apk

est*_*ban 0 android jenkins android-support-library androidx

由于我将我的应用程序迁移到 androidx,因此当我启动任务组合时,Jenkins 出现错误。这是错误:

Program type already present: 
android.support.v4.app.INotificationSideChannel$Stub$Proxy
Run Code Online (Sandbox Code Playgroud)

但是我在 Android Studio 上没有这个错误,我可以毫无问题地构建 apk。

因此,我尝试从 google play 服务中排除 support-v4 模块:

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'
}
Run Code Online (Sandbox Code Playgroud)

然后生成apk,但在启动应用程序时出现此错误:

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)
Run Code Online (Sandbox Code Playgroud)

但是再一次,在 Android Studio 上一切正常,自从迁移到 Androidx 以来,问题只出现在 Jenkins 上。

谢谢你的帮助

est*_*ban 6

Jenkins 没有使用具有 androidx 参数的 gradle.properties 文件:

android.enableJetifier=true
android.useAndroidX=true
Run Code Online (Sandbox Code Playgroud)

这就是为什么在本地机器上工作但在 Jenkins 上工作的原因。