R8 throws NullPointerException from within AndroidStudio, but not from commandline via gradlew

蓝咒 提交于 2020-02-28 15:40:49

问题


Problem

When I click on the debug icon in Android Studio, I get this NullPointerException from R8.

Executing tasks: [:app:assembleDebug] in project /Users/gary/Developer/Foo/Foo-Android

> Task :app:preBuild UP-TO-DATE
> Task :app:preDebugBuild UP-TO-DATE
> Task :app:checkDebugManifest UP-TO-DATE
> Task :app:generateDebugBuildConfig UP-TO-DATE
> Task :app:compileDebugAidl NO-SOURCE
> Task :app:compileDebugRenderscript NO-SOURCE
> Task :app:mainApkListPersistenceDebug
> Task :app:generateDebugResValues
> Task :app:generateDebugResources
> Task :app:createDebugCompatibleScreenManifests
> Task :app:processDebugManifest
> Task :app:mergeDebugResources
> Task :app:processDebugResources
> Task :app:kaptGenerateStubsDebugKotlin

> Task :app:kaptDebugKotlin
w: [kapt] Incremental annotation processing requested, but support is disabled because the following processors are not incremental: androidx.room.RoomProcessor (NON_INCREMENTAL).

> Task :app:compileDebugKotlin
w: /Users/gary/Developer/Foo/Foo-Android/app/src/main/java/com/foo/restapis/LoggingInterceptor.kt: (38, 49): 'create(MediaType?, String): ResponseBody' is deprecated. Moved to extension function. Put the 'content' argument first to fix Java
w: /Users/gary/Developer/Foo/Foo-Android/app/src/main/java/com/Foo/screens/player/PlayerActivity.kt: (132, 33): 'getRunningServices(Int): (Mutable)List<ActivityManager.RunningServiceInfo!>!' is deprecated. Deprecated in Java
w: /Users/gary/Developer/Foo/Foo-Android/app/src/main/java/com/foo/service/KKAudioPlayer.kt: (205, 35): 'setNotificationListener(PlayerNotificationManager.NotificationListener!): Unit' is deprecated. Deprecated in Java
w: /Users/gary/Developer/Foo/Foo-Android/app/src/main/java/com/foo/service/KKAudioPlayer.kt: (283, 32): 'ExtractorMediaSource' is deprecated. Deprecated in Java
w: /Users/gary/Developer/Foo/Foo-Android/app/src/main/java/com/foo/service/KKAudioPlayer.kt: (283, 53): 'Factory' is deprecated. Deprecated in Java
w: /Users/gary/Developer/Foo/Foo-Android/app/src/main/java/com/foo/service/KKAudioPlayer.kt: (293, 17): 'ExtractorMediaSource' is deprecated. Deprecated in Java
w: /Users/gary/Developer/Foo/Foo-Android/app/src/main/java/com/foo/service/KKAudioPlayer.kt: (293, 38): 'Factory' is deprecated. Deprecated in Java
w: /Users/gary/Developer/Foo/Foo-Android/app/src/main/java/com/foo/service/KKAudioPlayer.kt: (295, 21): 'ExtractorMediaSource' is deprecated. Deprecated in Java
w: /Users/gary/Developer/Foo/Foo-Android/app/src/main/java/com/foo/service/KKAudioPlayer.kt: (295, 42): 'Factory' is deprecated. Deprecated in Java

> Task :app:mergeDebugShaders
> Task :app:compileDebugShaders
> Task :app:generateDebugAssets
> Task :app:mergeDebugAssets
> Task :app:javaPreCompileDebug
> Task :app:compileDebugJavaWithJavac
> Task :app:compileDebugSources
> Task :app:processDebugJavaRes NO-SOURCE
> Task :app:validateSigningDebug
> Task :app:checkDebugDuplicateClasses
> Task :app:transformClassesWithProfilers-transformForDebug
> Task :app:mergeDebugJavaResource

> Task :app:transformClassesWithDexBuilderForDebug FAILED
org.gradle.workers.WorkerExecutionException: There was a failure while executing work items
    at org.gradle.workers.internal.DefaultWorkerExecutor.workerExecutionException(DefaultWorkerExecutor.java:158)
    at org.gradle.workers.internal.DefaultWorkerExecutor.await(DefaultWorkerExecutor.java:152)
    at com.android.build.gradle.internal.transforms.DexArchiveBuilderTransform.transform(DexArchiveBuilderTransform.java:424)
    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:106)
    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:404)
    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:393)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:376)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.access$200(ExecuteActionsTaskExecuter.java:80)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$TaskExecution.execute(ExecuteActionsTaskExecuter.java:213)
    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:120)
    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:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:55)
    at java.lang.Thread.run(Thread.java:748)
Caused by: org.gradle.workers.internal.DefaultWorkerExecutor$WorkExecutionException: A failure occurred while executing com.android.build.gradle.internal.transforms.DexArchiveBuilderTransform$DexConversionWorkAction
    at org.gradle.workers.internal.DefaultWorkerExecutor$WorkerExecution.waitForCompletion(DefaultWorkerExecutor.java:285)
    at org.gradle.internal.work.DefaultAsyncWorkTracker.waitForItemsAndGatherFailures(DefaultAsyncWorkTracker.java:115)
    at org.gradle.internal.work.DefaultAsyncWorkTracker.waitForCompletion(DefaultAsyncWorkTracker.java:87)
    at org.gradle.workers.internal.DefaultWorkerExecutor.await(DefaultWorkerExecutor.java:150)
    ... 100 more
Caused by: org.gradle.tooling.BuildException: Failed to process /Users/gary/Developer/Foo/Foo-Android/app/build/intermediates/transforms/profilers-transform/debug/29.jar
    at com.android.build.gradle.internal.transforms.DexArchiveBuilderTransform$DexConversionWorkAction.run(DexArchiveBuilderTransform.java:705)
    at org.gradle.workers.internal.DefaultWorkerServer.execute(DefaultWorkerServer.java:39)
    at org.gradle.workers.internal.NoIsolationWorkerFactory$1$1.execute(NoIsolationWorkerFactory.java:61)
    at org.gradle.workers.internal.AbstractWorker$1.call(AbstractWorker.java:44)
    at org.gradle.workers.internal.AbstractWorker$1.call(AbstractWorker.java:41)
    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.workers.internal.AbstractWorker.executeWrappedInBuildOperation(AbstractWorker.java:41)
    at org.gradle.workers.internal.NoIsolationWorkerFactory$1.execute(NoIsolationWorkerFactory.java:55)
    at org.gradle.workers.internal.DefaultWorkerExecutor$1.call(DefaultWorkerExecutor.java:105)
    at org.gradle.workers.internal.DefaultWorkerExecutor$1.call(DefaultWorkerExecutor.java:99)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at org.gradle.internal.work.DefaultConditionalExecutionQueue$ExecutionRunner.runExecution(DefaultConditionalExecutionQueue.java:215)
    at org.gradle.internal.work.DefaultConditionalExecutionQueue$ExecutionRunner.runBatch(DefaultConditionalExecutionQueue.java:164)
    at org.gradle.internal.work.DefaultConditionalExecutionQueue$ExecutionRunner.run(DefaultConditionalExecutionQueue.java:131)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    ... 6 more
Caused by: com.android.builder.dexing.DexArchiveBuilderException: Failed to process /Users/gary/Developer/Foo/Foo-Android/app/build/intermediates/transforms/profilers-transform/debug/29.jar
    at com.android.build.gradle.internal.transforms.DexArchiveBuilderTransform.launchProcessing(DexArchiveBuilderTransform.java:910)
    at com.android.build.gradle.internal.transforms.DexArchiveBuilderTransform.access$600(DexArchiveBuilderTransform.java:114)
    at com.android.build.gradle.internal.transforms.DexArchiveBuilderTransform$DexConversionWorkAction.run(DexArchiveBuilderTransform.java:697)
    ... 27 more
Caused by: com.android.builder.dexing.DexArchiveBuilderException: Error while dexing.
    at com.android.builder.dexing.D8DexArchiveBuilder.getExceptionToRethrow(D8DexArchiveBuilder.java:124)
    at com.android.builder.dexing.D8DexArchiveBuilder.convert(D8DexArchiveBuilder.java:101)
    at com.android.build.gradle.internal.transforms.DexArchiveBuilderTransform.launchProcessing(DexArchiveBuilderTransform.java:905)
    ... 29 more
Caused by: java.lang.NullPointerException
    at com.android.tools.r8.ir.conversion.N.b(:988)
    at com.android.tools.r8.ir.conversion.N.buildPrelude(:149)
    at com.android.tools.r8.ir.conversion.IRBuilder.a(:51)
    at com.android.tools.r8.graph.JarCode.a(:16)
    at com.android.tools.r8.graph.JarCode.b(:69)
    at com.android.tools.r8.graph.JarCode.buildIR(:1)
    at com.android.tools.r8.graph.DexEncodedMethod.buildIR(:2)
    at com.android.tools.r8.ir.conversion.IRConverter.b(:215)
    at com.android.tools.r8.ir.conversion.IRConverter.b(:37)
    at com.android.tools.r8.ir.conversion.IRConverter.a(:49)
    at com.android.tools.r8.graph.DexClass.forEachMethod(:2)
    at com.android.tools.r8.ir.conversion.IRConverter.b(:28)
    at com.android.tools.r8.ir.conversion.IRConverter.d(:8)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    at com.google.common.util.concurrent.TrustedListenableFutureTask$TrustedFutureInterruptibleTask.runInterruptibly(TrustedListenableFutureTask.java:125)
    at com.google.common.util.concurrent.InterruptibleTask.run(InterruptibleTask.java:57)
    at com.google.common.util.concurrent.TrustedListenableFutureTask.run(TrustedListenableFutureTask.java:78)
    at com.google.common.util.concurrent.MoreExecutors$DirectExecutorService.execute(MoreExecutors.java:261)
    at java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:112)
    at com.google.common.util.concurrent.AbstractListeningExecutorService.submit(AbstractListeningExecutorService.java:56)
    at com.google.common.util.concurrent.AbstractListeningExecutorService.submit(AbstractListeningExecutorService.java:36)
    at com.android.tools.r8.ir.conversion.IRConverter.a(:44)
    at com.android.tools.r8.ir.conversion.IRConverter.a(:9)
    at com.android.tools.r8.D8.a(:33)
    at com.android.tools.r8.D8.d(:8)
    at com.android.tools.r8.D8.b(:1)
    at com.android.tools.r8.utils.t.a(:23)
    at com.android.tools.r8.D8.run(:11)
    at com.android.builder.dexing.D8DexArchiveBuilder.convert(D8DexArchiveBuilder.java:99)
    ... 30 more
    Suppressed: java.util.concurrent.ExecutionException: java.lang.NullPointerException
        at com.google.common.util.concurrent.AbstractFuture.getDoneValue(AbstractFuture.java:552)
        at com.google.common.util.concurrent.AbstractFuture.get(AbstractFuture.java:513)
        at com.google.common.util.concurrent.FluentFuture$TrustedFuture.get(FluentFuture.java:82)
        at com.android.tools.r8.utils.ThreadUtils.a(:4)
        at com.android.tools.r8.ir.conversion.IRConverter.a(:46)
        ... 37 more
    [CIRCULAR REFERENCE:java.lang.NullPointerException]


FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:transformClassesWithDexBuilderForDebug'.
> There was a failure while executing work items
   > A failure occurred while executing com.android.build.gradle.internal.transforms.DexArchiveBuilderTransform$DexConversionWorkAction
      > Failed to process /Users/gary/Developer/Foo/Foo-Android/app/build/intermediates/transforms/profilers-transform/debug/29.jar

* 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

BUILD FAILED in 45s
21 actionable tasks: 19 executed, 2 up-to-date

But...

When I try to investigate further by running gradlew from the command line, there are no reported errors.

./gradlew :app:assembleDebug

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.4.1/userguide/command_line_interface.html#sec:command_line_warnings

BUILD SUCCESSFUL in 16s
29 actionable tasks: 12 executed, 17 up-to-date

So I'm at a loss for how to proceed. This is a commercial media app that had passed beta testing and was supposed to be released... but now this has me stymied.

Things I've tried so far...

  1. clean and rebuild
  2. File -> Invalidate Caches & Restart
  3. Wiping project .gradle and user/.gradle caches, clean and rebuild
  4. enableMultiDex = true in the gradle.config
  5. Increasing JVM memory from 2MB to 4MB
  6. Rebooting the computer

Questions

  1. How to resolve this exception and get un-stuck?
  2. Is it my code or an R8 bug?
  3. Why can't I reproduce the error from the command line?
  4. Is Android Studio running gradle with extra flags its not reporting?

Version Information

(everything should be up-to-date when filed in stack overflow)

  • Android Studio 3.5
  • Gradle 5.4.1
  • Android Studio Gradle Plugin 3.5.0
  • Java 1.8
  • Build Tools 28.0.3

build.gradle =

apply plugin: 'com.android.application'

apply plugin: 'kotlin-android'

apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'


android {
    compileSdkVersion 28
    defaultConfig {
        applicationId "com.foo"
        minSdkVersion 25
        targetSdkVersion 28
        versionCode 16
        versionName "1.0.1"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        javaCompileOptions {
            annotationProcessorOptions {
                arguments = ["room.schemaLocation": "$projectDir/schemas".toString()]
            }
        }
    }

    buildTypes {
        debug {
            buildConfigField "String", 'AUTH_URL', "\"https://debug.foo.com/oauth/\""
            buildConfigField "String", 'BASE_URL', "\"https://debug.foo.com/api/v1/\""
        }
        staging {
            buildConfigField "String", 'AUTH_URL', "\"https://staging.foo.com/oauth/\""
            buildConfigField "String", 'BASE_URL', "\"https://staging.foo.com/api/v1/\""
        }
        release {
            buildConfigField "String", 'AUTH_URL', "\"https://api.foo.com/oauth/\""
            buildConfigField "String", 'BASE_URL', "\"https://api.foo.com/api/v1/\""

            // enables code shrinking, obfuscation, and optimization
            minifyEnabled true

            // enables resource shrinking
            shrinkResources true

            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
    androidExtensions {
        experimental = true
    }
    lintOptions {
        disable 'RestrictedApi'
    }
    kotlinOptions {
        jvmTarget = '1.8'
    }
    kapt {
        useBuildCache = true
    }
    packagingOptions {
        exclude 'META-INF/atomicfu.kotlin_module'
    }
    buildToolsVersion = '28.0.3'
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.3.50"
    implementation "org.jetbrains.kotlin:kotlin-reflect:1.3.50"
    implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.0'

    implementation "android.arch.lifecycle:extensions:1.1.1"
    kapt "android.arch.lifecycle:common-java8:1.1.1"

    implementation "android.arch.persistence.room:runtime:1.1.1"
    kapt "android.arch.persistence.room:compiler:1.1.1"
    implementation "android.arch.persistence.room:rxjava2:1.1.1"
    testImplementation "android.arch.persistence.room:testing:1.1.1"

    implementation 'com.google.android.exoplayer:exoplayer-core:2.10.1'
    implementation 'com.google.android.exoplayer:exoplayer-ui:2.10.1'

    implementation "androidx.appcompat:appcompat:1.1.0"
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    implementation "androidx.preference:preference:1.1.0"

    // retrofit
    implementation 'com.squareup.retrofit2:retrofit:2.6.1'
    implementation 'com.squareup.retrofit2:converter-moshi:2.6.1'
    implementation 'com.squareup.retrofit2:adapter-rxjava2:2.6.1'

    // rxjava
    implementation "io.reactivex.rxjava2:rxjava:2.2.10"
    implementation "io.reactivex.rxjava2:rxandroid:2.1.1"

    implementation 'cz.ackee.rxoauth2:core:2.1.1'
    implementation 'cz.ackee.rxoauth2:retrofit-adapter:2.1.1'


    implementation 'com.squareup.picasso:picasso:2.71828'

    implementation 'com.google.android.material:material:1.0.0'

    implementation 'com.beust:klaxon:5.0.1'

    // test

    testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:5.5.1"

    testImplementation "androidx.test:runner:1.2.0"
    testImplementation 'org.assertj:assertj-core:3.13.2'
    testImplementation "org.junit.jupiter:junit-jupiter-api:5.5.1"
    testImplementation "org.junit.jupiter:junit-jupiter-params:5.5.1"
    testImplementation "io.mockk:mockk:1.9.3"
    testImplementation "com.github.andrzejchm.RESTMock:android:0.4.0"

    androidTestImplementation "androidx.test:runner:1.2.0"
    androidTestImplementation "androidx.test.espresso:espresso-core:3.2.0"
}

gradle.properties =

org.gradle.jvmargs=-Xmx4096m
kotlin.code.style=official

# migrate to androidX
android.useAndroidX=true
android.enableJetifier=true

回答1:


followed a workaround mentioned in commit 38934 and also disable Advanced profiling




回答2:


Posting as answer as I don't have privileges to comment:

If you're seeing above R8 Nullpointerexception only when building to Lollipop or Marshmallow devices, disabling Advanced profiling did the trick for me.

all credit to antoniomerlin! Thank you!



来源:https://stackoverflow.com/questions/57933038/r8-throws-nullpointerexception-from-within-androidstudio-but-not-from-commandli

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!