Stripe-android: The 3ds2 dependency breaks Firebase Performance and Robolectric

Created on 28 Jun 2019  路  47Comments  路  Source: stripe/stripe-android

Summary


Upgrading Stripe to version 9.3.5 (or any version after 9.1.1) breaks our app. The 3ds2 dependency added transitively the dependency to org.bouncycastle:bcprov-jdk15on:1.61. This forces a few other dependency to use that version and breaks the app in different ways:

  • The Firebase performance plugin (version 1.1.5) fails to load with the following error:
/.../app/build/intermediates/transforms/FirebasePerformancePlugin/release/162/module-info.class: D8: Unsupported source file type
  • The robolectric (version 4.0.2) tests take a very long time to run (~15 minutes per test)

Screenshot 2019-06-28 at 11 56 20

Android version


minSdk 21

SDK version


Version 9.1.1 to 9.3.5

Other information


I managed to work around both issues by forcing the bouncy castle dependency to 1.52.
Forcing the version to 1.52 shows an issue with Lint:

Invalid package reference in library; not included in Android: javax.naming.directory. Referenced from org.bouncycastle.jce.provider.X509LDAPCertStoreSpi.

But I imagine we can safely ignore it as I don't assume we do LDAP with Stripe.

triaged

All 47 comments

I was wondering if we could downgrade the bouncy castle to something like 1.52, given it's the version most commonly used by other dependencies?

I was also facing an issue with Firebase performance plugin, its reported here https://issuetracker.google.com/issues/135171107#comment14 the problem is Firebase extracts the jar files and the obfuscated filenames are designed to be used on a case-sensitive file system, like A.class and a.class are considered same in the default case insensitive file systems of Windows and Mac so either one will overwrite the other, the only viable solution is to work on the project on a case sensitive file system, but be warned its asinine to do so because a.java and a.JAVA will be considered two separate files, also since Google said they'll fix firebase and work on it and has no forseeable future when the fix will come, can Stripe handle it on their side?

@droidluv see #1139 for discussion about the issue you are running into (fixed in 9.3.6)

@RomainPiel out of curiosity, does upgrading to the latest version of Robolectric (4.3) help with the performance issues?

@msaffitz-stripe I tried upgrading Robolectric to version 4.3 and faced that other issue: https://github.com/robolectric/robolectric/issues/4621#issuecomment-499080171

Trying with 4.2.1 now...

I just noticed the same issue with Robolectric 4.2.1 on our CI.

@RomainPiel I can downgrade the version of BouncyCastle we're using, but is that the cause of the Robolectric performance issues? Are the performance issues resolved when you force 1.5.2? Are you able to add any log statements to your tests to see where the bottleneck is? Also, does upgrading to stripe-android 9.3.6 improve anything?

Also, noticed there's a newer version of the Firebase performance plugin, 1.2.1. Maybe worth trying? https://firebase.google.com/docs/perf-mon/get-started-android

Are the performance issues resolved when you force 1.5.2?

Yes the firebase issue gets fixed when I force bouncy castle to version 1.56 and the robolectric issue gets fixed when I force bouncy castle to version 1.52.

Are you able to add any log statements to your tests to see where the bottleneck is?

We noticed this issue on some of our machines (like on the CI). It took us quite a long time to reach the conclusion that it was related to bouncy castle and didn't go further in our investigation.

Also, does upgrading to stripe-android 9.3.6 improve anything?

~I can try that today.~ Just tried and I'm seeing the same issue.

Also, noticed there's a newer version of the Firebase performance plugin, 1.2.1. Maybe worth trying?

I also tried this and stumbled upon that other issue: https://stackoverflow.com/questions/45172123/errorexecution-failed-for-task-apptransformclasseswithfirebaseperformanceplu

Sorry I realise this is quite a hard issue for you to fix. I'm discussing with the three parties (Stripe, Firebase, Robolectric) to see if I can find a way to unlock this situation but I also realise it's no one's real responsibility.

The Firebase team has asked me to build a sample to demonstrate the issue. So I forked the Firebase sample and added a dependency to Stripe 9.3.5: https://github.com/RomainPiel/quickstart-android/tree/stripe-issue

To reproduce the Firebase issue, run ./gradlew assembleDebug

@mshafrir-stripe I updated to 9.3.6 and I am now facing the issue with bouncy castle as mentioned by the OP

AGPBI: {"kind":"error","text":"Unsupported source file type","sources":[{"file":"/app/build/intermediates/transforms/FirebasePerformancePlugin/staging/186/module-info.class"}],"tool":"D8"}

186 directory is part of org.bouncycastle

@droidluv what versions of Gradle and Android Gradle Plugin are you using?

@mshafrir-stripe Gradel 3.4.2 and Android Studio is 3.4.2, also Firebase plugin is 1.2.1

@droidluv can you try upgrading Gradle to at least 5.4.1

distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip

and Android Gradle Plugin to at least 3.4.1

    dependencies {
        classpath 'com.android.tools.build:gradle:3.4.1'
    }

@mshafrir-stripe Oh I'm sorry I was not clear enough my gradle plugin is 3.4.2 and gradle version is 5.1.1

@droidluv can you try using Gradle 5.4.1?

@mshafrir-stripe also just updated and started using gradle 5.4.1 but facing same failure

AGPBI: {"kind":"error","text":"Unsupported source file type","sources":[{"file":"/app/build/intermediates/transforms/FirebasePerformancePlugin/staging/186/module-info.class"}],"tool":"D8"}

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ':app:transformClassesAndResourcesWithR8ForDebug'.
    > com.android.tools.r8.CompilationFailedException: Compilation failed to complete

@droidluv can you send me your build.gradle and Proguard rules. I'd like to reproduce the issue.

@mshafrir-stripe How should I send it, can you give me your email address?

@droidluv can you post it as a gist?

@mshafrir-stripe You can also use the sample I posted yesterday to reproduce the issue: https://github.com/RomainPiel/quickstart-android/tree/stripe-issue

  • open the perf folder
  • run ./gradlew assembleDebug

I think we're facing the same issue with @droidluv

Also for reference, the firebase team got back to me with this answer:

Thanks a lot for sharing the sample app, Romain. Really appreciate it.
I was able to replicate the issue locally, and it's possible that the Performance Monitoring SDK has a compatibility issue with Stripe SDK. Because of that, I've filed an internal bug to our engineers to check if this error message is caused by our SDK. Once we've identified the root cause of the issue, we'll be sure to address it. For any updates, please keep an eye out on our release notes.

@mshafrir-stripe sorry I ran off it was getting late for me and the error I am facing is just like @RomainPiel's sample

@mshafrir-stripe You can also use the sample I posted yesterday to reproduce the issue: https://github.com/RomainPiel/quickstart-android/tree/stripe-issue

  • open the perf folder
  • run ./gradlew assembleDebug

I think we're facing the same issue with @droidluv

I followed these steps but got the following:

perf $ ./gradlew assembleDebug

> Configure project :app
WARNING: API 'variant.getMergeResources()' is obsolete and has been replaced with 'variant.getMergeResourcesProvider()'.
It will be removed at the end of 2019.
For more information, see https://d.android.com/r/tools/task-configuration-avoidance.
To determine what is calling variant.getMergeResources(), use -Pandroid.debug.obsoleteApi=true on the command line to display more information.

> Task :app:processDebugGoogleServices FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:processDebugGoogleServices'.
> File google-services.json is missing. The Google Services Plugin cannot function without it.
   Searched Location:
  /Users/mshafrir/workspace/quickstart-android/perf/app/src/nullnull/google-services.json
  /Users/mshafrir/workspace/quickstart-android/perf/app/src/debug/google-services.json
  /Users/mshafrir/workspace/quickstart-android/perf/app/src/nullnullDebug/google-services.json
  /Users/mshafrir/workspace/quickstart-android/perf/app/src/nullnull/debug/google-services.json
  /Users/mshafrir/workspace/quickstart-android/perf/app/src/debug/nullnull/google-services.json
  /Users/mshafrir/workspace/quickstart-android/perf/app/google-services.json

@mshafrir-stripe Ah right, You need to create a Firebase project following these steps first: https://firebase.google.com/docs/android/setup
The config is not included in the config.

@RomainPiel what Application Id should I be using when registering the app in Firebase?

Screen Shot 2019-07-11 at 6 46 21 AM

com.google.firebase.quickstart.perfmon

@RomainPiel this is what I'm seeing now after adding `implementation 'com.stripe:stripe-android:9.3.6' to the perf module's dependencies

$ ./gradlew assembleDebug

> Configure project :app
WARNING: API 'variant.getMergeResources()' is obsolete and has been replaced with 'variant.getMergeResourcesProvider()'.
It will be removed at the end of 2019.
For more information, see https://d.android.com/r/tools/task-configuration-avoidance.
To determine what is calling variant.getMergeResources(), use -Pandroid.debug.obsoleteApi=true on the command line to display more information.
D8: Program type already present: com.firebase.lintchecks.BuildConfig

> Task :app:transformDexArchiveWithDexMergerForDebug FAILED
java.lang.RuntimeException: java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Error while merging dex archives:
Learn how to resolve the issue at https://developer.android.com/studio/build/dependencies#duplicate_classes.
Program type already present: com.firebase.lintchecks.BuildConfig
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
        at java.util.concurrent.ForkJoinTask.getThrowableException(ForkJoinTask.java:593)
        at java.util.concurrent.ForkJoinTask.reportException(ForkJoinTask.java:677)
        at java.util.concurrent.ForkJoinTask.join(ForkJoinTask.java:720)
        at com.google.common.collect.ImmutableList.forEach(ImmutableList.java:407)
        at com.android.build.gradle.internal.transforms.DexMergerTransform.transform(DexMergerTransform.java:244)
        at com.android.build.gradle.internal.pipeline.TransformTask$2.call(TransformTask.java:239)
        at com.android.build.gradle.internal.pipeline.TransformTask$2.call(TransformTask.java:235)
        at com.android.builder.profile.ThreadRecorder.record(ThreadRecorder.java:102)
        at com.android.build.gradle.internal.pipeline.TransformTask.transform(TransformTask.java:230)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:103)
        at org.gradle.api.internal.project.taskfactory.IncrementalTaskInputsTaskAction.doExecute(IncrementalTaskInputsTaskAction.java:46)
        at org.gradle.api.internal.project.taskfactory.StandardTaskAction.execute(StandardTaskAction.java:41)
        at org.gradle.api.internal.project.taskfactory.AbstractIncrementalTaskAction.execute(AbstractIncrementalTaskAction.java:25)
        at org.gradle.api.internal.project.taskfactory.StandardTaskAction.execute(StandardTaskAction.java:28)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$5.run(ExecuteActionsTaskExecuter.java:401)
        at org.gradle.internal.operations.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:402)
        at org.gradle.internal.operations.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:394)
        at org.gradle.internal.operations.DefaultBuildOperationExecutor$1.execute(DefaultBuildOperationExecutor.java:165)
        at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:250)
        at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:158)
        at org.gradle.internal.operations.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:92)
        at org.gradle.internal.operations.DelegatingBuildOperationExecutor.run(DelegatingBuildOperationExecutor.java:31)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:390)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:373)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.access$200(ExecuteActionsTaskExecuter.java:79)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$TaskExecution.execute(ExecuteActionsTaskExecuter.java:210)
        at org.gradle.internal.execution.steps.ExecuteStep.lambda$execute$0(ExecuteStep.java:32)
        at java.util.Optional.map(Optional.java:215)
        at org.gradle.internal.execution.steps.ExecuteStep.execute(ExecuteStep.java:32)
        at org.gradle.internal.execution.steps.ExecuteStep.execute(ExecuteStep.java:26)
        at org.gradle.internal.execution.steps.CleanupOutputsStep.execute(CleanupOutputsStep.java:58)
        at org.gradle.internal.execution.steps.CleanupOutputsStep.execute(CleanupOutputsStep.java:35)
        at org.gradle.internal.execution.steps.ResolveInputChangesStep.execute(ResolveInputChangesStep.java:48)
        at org.gradle.internal.execution.steps.ResolveInputChangesStep.execute(ResolveInputChangesStep.java:33)
        at org.gradle.internal.execution.steps.CancelExecutionStep.execute(CancelExecutionStep.java:39)
        at org.gradle.internal.execution.steps.TimeoutStep.executeWithoutTimeout(TimeoutStep.java:73)
        at org.gradle.internal.execution.steps.TimeoutStep.execute(TimeoutStep.java:54)
        at org.gradle.internal.execution.steps.CatchExceptionStep.execute(CatchExceptionStep.java:35)
        at org.gradle.internal.execution.steps.CreateOutputsStep.execute(CreateOutputsStep.java:51)
        at org.gradle.internal.execution.steps.SnapshotOutputsStep.execute(SnapshotOutputsStep.java:45)
        at org.gradle.internal.execution.steps.SnapshotOutputsStep.execute(SnapshotOutputsStep.java:31)
        at org.gradle.internal.execution.steps.CacheStep.executeWithoutCache(CacheStep.java:201)
        at org.gradle.internal.execution.steps.CacheStep.execute(CacheStep.java:70)
        at org.gradle.internal.execution.steps.CacheStep.execute(CacheStep.java:45)
        at org.gradle.internal.execution.steps.BroadcastChangingOutputsStep.execute(BroadcastChangingOutputsStep.java:49)
        at org.gradle.internal.execution.steps.StoreSnapshotsStep.execute(StoreSnapshotsStep.java:43)
        at org.gradle.internal.execution.steps.StoreSnapshotsStep.execute(StoreSnapshotsStep.java:32)
        at org.gradle.internal.execution.steps.RecordOutputsStep.execute(RecordOutputsStep.java:38)
        at org.gradle.internal.execution.steps.RecordOutputsStep.execute(RecordOutputsStep.java:24)
        at org.gradle.internal.execution.steps.SkipUpToDateStep.executeBecause(SkipUpToDateStep.java:96)
        at org.gradle.internal.execution.steps.SkipUpToDateStep.lambda$execute$0(SkipUpToDateStep.java:89)
        at java.util.Optional.map(Optional.java:215)
        at org.gradle.internal.execution.steps.SkipUpToDateStep.execute(SkipUpToDateStep.java:54)
        at org.gradle.internal.execution.steps.SkipUpToDateStep.execute(SkipUpToDateStep.java:38)
        at org.gradle.internal.execution.steps.ResolveChangesStep.execute(ResolveChangesStep.java:77)
        at org.gradle.internal.execution.steps.ResolveChangesStep.execute(ResolveChangesStep.java:37)
        at org.gradle.internal.execution.steps.legacy.MarkSnapshottingInputsFinishedStep.execute(MarkSnapshottingInputsFinishedStep.java:36)
        at org.gradle.internal.execution.steps.legacy.MarkSnapshottingInputsFinishedStep.execute(MarkSnapshottingInputsFinishedStep.java:26)
        at org.gradle.internal.execution.steps.ResolveCachingStateStep.execute(ResolveCachingStateStep.java:90)
        at org.gradle.internal.execution.steps.ResolveCachingStateStep.execute(ResolveCachingStateStep.java:48)
        at org.gradle.internal.execution.impl.DefaultWorkExecutor.execute(DefaultWorkExecutor.java:33)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:117)
        at org.gradle.api.internal.tasks.execution.ResolveBeforeExecutionStateTaskExecuter.execute(ResolveBeforeExecutionStateTaskExecuter.java:75)
        at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:62)
        at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:108)
        at org.gradle.api.internal.tasks.execution.ResolveBeforeExecutionOutputsTaskExecuter.execute(ResolveBeforeExecutionOutputsTaskExecuter.java:67)
        at org.gradle.api.internal.tasks.execution.ResolveAfterPreviousExecutionStateTaskExecuter.execute(ResolveAfterPreviousExecutionStateTaskExecuter.java:46)
        at org.gradle.api.internal.tasks.execution.CleanupStaleOutputsExecuter.execute(CleanupStaleOutputsExecuter.java:94)
        at org.gradle.api.internal.tasks.execution.FinalizePropertiesTaskExecuter.execute(FinalizePropertiesTaskExecuter.java:46)
        at org.gradle.api.internal.tasks.execution.ResolveTaskExecutionModeExecuter.execute(ResolveTaskExecutionModeExecuter.java:95)
        at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:57)
        at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:56)
        at org.gradle.api.internal.tasks.execution.CatchExceptionTaskExecuter.execute(CatchExceptionTaskExecuter.java:36)
        at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.executeTask(EventFiringTaskExecuter.java:73)
        at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.call(EventFiringTaskExecuter.java:52)
        at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.call(EventFiringTaskExecuter.java:49)
        at org.gradle.internal.operations.DefaultBuildOperationExecutor$CallableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:416)
        at org.gradle.internal.operations.DefaultBuildOperationExecutor$CallableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:406)
        at org.gradle.internal.operations.DefaultBuildOperationExecutor$1.execute(DefaultBuildOperationExecutor.java:165)
        at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:250)
        at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:158)
        at org.gradle.internal.operations.DefaultBuildOperationExecutor.call(DefaultBuildOperationExecutor.java:102)
        at org.gradle.internal.operations.DelegatingBuildOperationExecutor.call(DelegatingBuildOperationExecutor.java:36)
        at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter.execute(EventFiringTaskExecuter.java:49)
        at org.gradle.execution.plan.LocalTaskNodeExecutor.execute(LocalTaskNodeExecutor.java:43)
        at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$InvokeNodeExecutorsAction.execute(DefaultTaskExecutionGraph.java:355)
        at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$InvokeNodeExecutorsAction.execute(DefaultTaskExecutionGraph.java:343)
        at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$BuildOperationAwareExecutionAction.execute(DefaultTaskExecutionGraph.java:336)
        at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$BuildOperationAwareExecutionAction.execute(DefaultTaskExecutionGraph.java:322)
        at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker$1.execute(DefaultPlanExecutor.java:134)
        at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker$1.execute(DefaultPlanExecutor.java:129)
        at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.execute(DefaultPlanExecutor.java:202)
        at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.executeNextNode(DefaultPlanExecutor.java:193)
        at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.run(DefaultPlanExecutor.java:129)
        at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63)
        at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:46)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
        at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:55)
        at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Error while merging dex archives:
Learn how to resolve the issue at https://developer.android.com/studio/build/dependencies#duplicate_classes.
Program type already present: com.firebase.lintchecks.BuildConfig
        at java.util.concurrent.ForkJoinTask$AdaptedCallable.exec(ForkJoinTask.java:1431)
        at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:289)
        at java.util.concurrent.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1056)
        at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1692)
        at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:157)
Caused by: com.android.builder.dexing.DexArchiveMergerException: Error while merging dex archives:
Learn how to resolve the issue at https://developer.android.com/studio/build/dependencies#duplicate_classes.
Program type already present: com.firebase.lintchecks.BuildConfig
        at com.android.builder.dexing.D8DexArchiveMerger.getExceptionToRethrow(D8DexArchiveMerger.java:131)
        at com.android.builder.dexing.D8DexArchiveMerger.mergeDexArchives(D8DexArchiveMerger.java:118)
        at com.android.build.gradle.internal.transforms.DexMergerTransformCallable.call(DexMergerTransformCallable.java:102)
        at com.android.build.gradle.internal.transforms.DexMergerTransformCallable.call(DexMergerTransformCallable.java:37)
        at java.util.concurrent.ForkJoinTask$AdaptedCallable.exec(ForkJoinTask.java:1424)
        ... 4 more
Caused by: com.android.tools.r8.CompilationFailedException: Compilation failed to complete
        at com.android.tools.r8.utils.ExceptionUtils.withCompilationHandler(ExceptionUtils.java:81)
        at com.android.tools.r8.utils.ExceptionUtils.withD8CompilationHandler(ExceptionUtils.java:45)
        at com.android.tools.r8.D8.run(D8.java:94)
        at com.android.builder.dexing.D8DexArchiveMerger.mergeDexArchives(D8DexArchiveMerger.java:116)
        ... 7 more
Caused by: com.android.tools.r8.utils.AbortException: Error: Program type already present: com.firebase.lintchecks.BuildConfig
        at com.android.tools.r8.utils.Reporter.failIfPendingErrors(Reporter.java:101)
        at com.android.tools.r8.utils.Reporter.fatalError(Reporter.java:72)
        at com.android.tools.r8.utils.ExceptionUtils.withCompilationHandler(ExceptionUtils.java:66)
        ... 10 more


FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:transformDexArchiveWithDexMergerForDebug'.
> com.android.build.api.transform.TransformException: java.lang.RuntimeException: java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Error while merging dex archives:
  Learn how to resolve the issue at https://developer.android.com/studio/build/dependencies#duplicate_classes.
  Program type already present: com.firebase.lintchecks.BuildConfig

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

Deprecated Gradle features were used in this build, making it incompatible with Gradle 6.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/5.5/userguide/command_line_interface.html#sec:command_line_warnings

BUILD FAILED in 7s
54 actionable tasks: 3 executed, 51 up-to-date

@mshafrir-stripe you can switch to my branch stripe-issue https://github.com/RomainPiel/quickstart-android/tree/stripe-issue where this is fixed

@RomainPiel I came across the following two issues which seem to indicate that they'll be fixed in the next Android Studio release?

https://issuetracker.google.com/issues/131114388
https://issuetracker.google.com/issues/134093979

Interesting 馃憤

@RomainPiel FYI there are new versions of some dependencies, including the Firebase perf plugin. I wonder if it makes any difference.

-        classpath 'com.android.tools.build:gradle:3.4.1'
+        classpath 'com.android.tools.build:gradle:3.4.2'
-        classpath 'com.google.firebase:perf-plugin:1.2.1'
+        classpath 'com.google.firebase:perf-plugin:1.3.0'
-    implementation 'com.google.firebase:firebase-core:17.0.0'
+    implementation 'com.google.firebase:firebase-core:17.0.1'
-    implementation 'com.stripe:stripe-android:9.3.5'
+    implementation 'com.stripe:stripe-android:9.3.6'

Updated and it still fails with the same error:

/.../quickstart-android/perf/app/build/intermediates/transforms/FirebasePerformancePlugin/debug/72/module-info.class: D8: Unsupported source file type

I've pushed the update in this commit: https://github.com/RomainPiel/quickstart-android/commit/70ce8e7eb4357dfa9cc9b20afbe17b4b09c5f956
Feel free to fork the project if you'd like to play with it.

@mshafrir-stripe I updated Firebase perf-plugin to 1.3.0 and walla all my problems disappeared into thin air, I have Firebase Performance Monitoring working and Stripe right along with it, thanks for all your help!!!

@droidluv that's great to hear! Can you share your build.gradle and Gradle version so we can compare your config with @RomainPiel's?

I've just tried using version 1.3.0 and I'm getting the same issue as with version 1.2.1 of the plugin (unrelated to the one described in this github issue): https://stackoverflow.com/questions/45172123/errorexecution-failed-for-task-apptransformclasseswithfirebaseperformanceplu

@RomainPiel can you DM me in ASG?

@RomainPiel I just released 10.0.1 which fixes some of the incompatibilities with the Firebase plugin. Can you let me know if it resolves your issues?

Hmm - I'm using Stripe 10.0.1, Firebase Performance plugin 1.3.0, Firebase Performance library 18.0.1, and Gradle 5.5.1, and Android Gradle plugin 3.4.2. And I still get a similar error when building my optimized builds with R8:

> Task :mobile:transformClassesAndResourcesWithR8ForAlpha FAILED
R8 is the new Android code shrinker. If you experience any issues, please file a bug at
https://issuetracker.google.com, using 'Shrinker (R8)' as component name. You can
disable R8 by updating gradle.properties with 'android.enableR8=false'.
Current version is: 1.4.94 (build 390954928f0db9c3b888a367f7f128ce3bbfb160 from go/r8bot (luci-r8-ci-archive-0-5g74)).

/home/circleci/project/mobile/build/intermediates/transforms/FirebasePerformancePlugin/alpha/161/module-info.class: D8: Unsupported source file type

Any ideas for how to debug further? It seems like there's some bad configuration somewhere, but it's a bit mysterious to me where this would come from.

@tmtrademarked can you try upgrading to the latest SDK version 10.0.3 and let me know if it resolves the issues? Can you share your other dependencies as well?

I've tried updating to the 10.0.3 branch, but unfortunately, no luck so far. We're still seeing the same error. It sure appears that this is the same problem with the org.bouncycastle:bcprov-jdk15on:1.61 dependency, which we see in our builds.

We have a LOT of dependencies in our APK. I can provide a partial dump from ./gradlew :mobile:dependencies if you think that would be instructive, though? Or if there are particular dependencies you suspect are problematic, I'm happy to list those manually as well.

I've confirmed that adding the following to our top-level build.gradle does fix the problem by forcing a bouncycastle downgrade. It's ugly, but that may be our best path forward until someone finds a real fix for the root issue.

configurations.all {
    resolutionStrategy {
        force 'org.bouncycastle:bcprov-jdk15on:1.56'
    }
}

Yes I am using a similar fix:

implementation('org.bouncycastle:bcprov-jdk15on:1.56') { force = true }

The tricky bit with this issue is that it's not really a bug on Stripe nor a bug on Firebase (or bouncy castle). But rather the three parts not playing well together.

@romainpiel @tmtrademarked if you upgrade to stripe-android 10.4.0, you may be able to remove the resolutionStrategy for org.ow2.asm:asm. Can you confirm?

The resolution strategy is on bouncy castle, not asm 馃

UPDATE: ah right the ASM issue is another one referenced previously my bad 馃槄. I still see the ASM issue when I update Stripe to the latest version and Firebase to version 1.3.1 (https://stackoverflow.com/questions/45172123/errorexecution-failed-for-task-apptransformclasseswithfirebaseperformanceplu)

@romainpiel thanks for checking

To confirm, I also still see an R8 issue using Firebase Performance Plugin 1.3.1, Firebase Performance 19.0.0, and Stripe 10.4.1. Looks like it's still having trouble with bouncy-castle unless I forcibly downgrade that one.

R8 is the new Android code shrinker. If you experience any issues, please file a bug at
https://issuetracker.google.com, using 'Shrinker (R8)' as component name. You can
disable R8 by updating gradle.properties with 'android.enableR8=false'.
Current version is: 1.4.94 (build 390954928f0db9c3b888a367f7f128ce3bbfb160 from go/r8bot (luci-r8-ci-archive-0-5g74)).

/Volumes/android/android-application/mobile/build/intermediates/transforms/FirebasePerformancePlugin/alpha/163/module-info.class: D8: Unsupported source file type

for someone out there who's still experiencing the error, this might help
https://github.com/bcgit/bc-java/issues/390

Was this page helpful?
0 / 5 - 0 ratings

Related issues

danielgomezrico picture danielgomezrico  路  9Comments

odedharth picture odedharth  路  10Comments

freszu picture freszu  路  3Comments

Petrulak picture Petrulak  路  5Comments

GuillaumeWrobel picture GuillaumeWrobel  路  8Comments