com.android.builder.dexing.DexArchiveBuilderException,同时使用newrelic转换进行分解

时间:2019-07-11 11:11:49

标签: android gradle newrelic

我有一个要在DemoApp中使用的图书馆项目。

如果将NewRelic添加到DemoApp build.gradle中,则将Library项目集成到DemoApp中失败,因为在NewRelic转换后Dexing失败,如果我不使用NewRelic,则成功发生。

以下是构建错误

    MacBook-Pro:Project admin$ ./gradlew clean;
    > Configure project :DemoApp
    google-services plugin could not detect any version for com.google.android.gms or com.google.firebase, default version: 11.4.2 will be used.
    please apply google-services plugin at the bottom of the build file.
    Could not find google-services.json while looking in [src/nullnull/debug, src/debug/nullnull, src/nullnull, src/debug, src/nullnullDebug]
    registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)
    Could not find google-services.json while looking in [src/nullnull/release, src/release/nullnull, src/nullnull, src/release, src/nullnullRelease]
    registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)

    BUILD SUCCESSFUL in 5s
    2 actionable tasks: 1 executed, 1 up-to-date


    MacBook-Pro:Project admin$ ./gradlew --stacktrace --scan build;
    > Configure project :DemoApp
    google-services plugin could not detect any version for com.google.android.gms or com.google.firebase, default version: 11.4.2 will be used.
    please apply google-services plugin at the bottom of the build file.
    Could not find google-services.json while looking in [src/nullnull/debug, src/debug/nullnull, src/nullnull, src/debug, src/nullnullDebug]
    registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)
    Could not find google-services.json while looking in [src/nullnull/release, src/release/nullnull, src/nullnull, src/release, src/nullnullRelease]
    registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)

    > Task :DemoApp:processDebugGoogleServDcesApp
    Parsing json file: /Users/admin/Project/DemoApp/google-services.json
    /Users/admin/Project/DemoApp/build/intermediates/incremental/mergeDebugResources/merged.dir/values-sw600dp-v13/values-sw600dp-v13.xml:74: warn: ignoring configuration 'sw600dp-v13' for styleable PagerIndicator.
    /Users/admin/Project/DemoApp/build/intermediates/incremental/mergeDebugResources/merged.dir/values-sw600dp-v13/values-sw600dp-v13.xml:116: warn: ignoring configuration 'sw600dp-v13' for styleable SliderLayout.
    /Users/admin/Project/DemoApp/build/intermediates/incremental/mergeDebugResources/merged.dir/values-sw600dp-v13/values-sw600dp-v13.xml:150: warn: ignoring configuration 'sw600dp-v13' for styleable Themes.


    > Task :DemoApp:transformClassesWithDexBuilderForDDbugApp
    com.android.builder.dexing.DexArchiveBuilderException: com.android.builder.dexing.DexArchiveBuilderException: Failed to process /Users/admin/Project/DemoApp/build/intermediates/transforms/newrelicTransform/debug/14.jar
            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.android.ide.common.internal.WaitableExecutor.waitForTasksWithQuickFail(WaitableExecutor.java:149)
            at com.android.build.gradle.internal.transforms.DexArchiveBuilderTransform.transform(DexArchiveBuilderTransform.java:420)
            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.StartSnapshotTaskInputsBuildOperationTaskExecuter.execute(StartSnapshotTaskInputsBuildOperationTaskExecuter.java:62)
            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: com.android.builder.dexing.DexArchiveBuilderException: Failed to process /Users/admin/Project/DemoApp/build/intermediates/transforms/newrelicTransform/debug/14.jar
            at com.android.build.gradle.internal.transforms.DexArchiveBuilderTransform.launchProcessing(DexArchiveBuilderTransform.java:909)
            at com.android.build.gradle.internal.transforms.DexArchiveBuilderTransform.lambda$convertToDexArchive$6(DexArchiveBuilderTransform.java:834)
            at java.util.concurrent.ForkJoinTask$AdaptedCallable.exec(ForkJoinTask.java:1424)
            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.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:904)
            ... 6 more
    Caused by: java.util.NoSuchElementException
            at java.util.ArrayDeque.removeFirst(ArrayDeque.java:285)
            at java.util.ArrayDeque.pop(ArrayDeque.java:522)
            at com.android.tools.r8.ir.conversion.JarState.pop(JarState.java:740)
            at com.android.tools.r8.ir.conversion.JarSourceCode.updateState(JarSourceCode.java:1308)
            at com.android.tools.r8.ir.conversion.JarSourceCode.updateState(JarSourceCode.java:1194)
            at com.android.tools.r8.ir.conversion.JarSourceCode.computeBlockEntryJarStates(JarSourceCode.java:433)
            at com.android.tools.r8.ir.conversion.JarSourceCode.buildPrelude(JarSourceCode.java:364)
            at com.android.tools.r8.ir.conversion.IRBuilder.build(IRBuilder.java:569)
            at com.android.tools.r8.graph.JarCode.internalBuild(JarCode.java:215)
            at com.android.tools.r8.graph.JarCode.internalBuildWithLocals(JarCode.java:177)
            at com.android.tools.r8.graph.JarCode.internalBuildPossiblyWithLocals(JarCode.java:163)
            at com.android.tools.r8.graph.JarCode.buildIR(JarCode.java:128)
            at com.android.tools.r8.graph.DexEncodedMethod.buildIR(DexEncodedMethod.java:323)
            at com.android.tools.r8.ir.conversion.IRConverter.rewriteCode(IRConverter.java:839)
            at com.android.tools.r8.ir.conversion.IRConverter.convertMethodToDex(IRConverter.java:502)
            at com.android.tools.r8.ir.conversion.IRConverter.lambda$convertMethodsToDex$3(IRConverter.java:490)
            at com.android.tools.r8.graph.DexClass.forEachMethod(DexClass.java:261)
            at com.android.tools.r8.ir.conversion.IRConverter.convertMethodsToDex(IRConverter.java:486)
            at com.android.tools.r8.ir.conversion.IRConverter.lambda$convertClassesToDex$2(IRConverter.java:471)
            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:258)
            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.convertClassesToDex(IRConverter.java:471)
            at com.android.tools.r8.ir.conversion.IRConverter.convertToDex(IRConverter.java:381)
            at com.android.tools.r8.D8.optimize(D8.java:238)
            at com.android.tools.r8.D8.run(D8.java:179)
            at com.android.tools.r8.D8.lambda$run$1(D8.java:97)
            at com.android.tools.r8.utils.ExceptionUtils.withCompilationHandler(ExceptionUtils.java:62)
            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.D8DexArchiveBuilder.convert(D8DexArchiveBuilder.java:99)
            ... 7 more
            Suppressed: java.util.concurrent.ExecutionException: java.util.NoSuchElementException
                    at com.google.common.util.concurrent.AbstractFuture.getDoneValue(AbstractFuture.java:531)
                    at com.google.common.util.concurrent.AbstractFuture.get(AbstractFuture.java:492)
                    at com.google.common.util.concurrent.AbstractFuture$TrustedFuture.get(AbstractFuture.java:83)
                    at com.android.tools.r8.utils.ThreadUtils.awaitFutures(ThreadUtils.java:21)
                    at com.android.tools.r8.ir.conversion.IRConverter.convertClassesToDex(IRConverter.java:473)
                    ... 15 more
            [CIRCULAR REFERENCE:java.util.NoSuchElementException]


    > Task :DemoApp:transformClassesWithDexBuilderForDebug FAILED

    FAILURE: Build failed with an exception.

    BUILD FAILED in 35s

以下是我的构建配置

图书馆项目build.gradle

buildscript {
    repositories {
        google()
        jcenter()
        mavenCentral()
        maven { url 'https://plugins.gradle.org/m2/' }
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.4.2'
        classpath 'com.google.gms:google-services:4.2.0'
        classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.4'
        classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1'
        //classpath "gradle.plugin.com.github.spotbugs:spotbugs-gradle-plugin:2.0.0" // For SpotBugs

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        google()
        jcenter()
        maven { url 'https://maven.google.com' }
        flatDir {
            dirs 'libs'
        }
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

库模块build.gradle

apply plugin: 'com.android.library'
android {
    compileSdkVersion 28

    defaultConfig {
        minSdkVersion 21
        targetSdkVersion 28
        versionCode 1
        versionName libraryVersion
        multiDexEnabled true
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }

    buildTypes {
        release {
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            multiDexKeepProguard file('multidex-config.pro')
        }
    }
}

dependencies {
    implementation 'androidx.legacy:legacy-support-v4:1.0.0'
    implementation 'com.google.android.gms:play-services-ads:18.0.0'
    implementation 'com.google.firebase:firebase-core:17.0.0'
    implementation 'com.google.firebase:firebase-messaging:19.0.1'
    implementation 'com.squareup.picasso:picasso:2.5.2'
}

apply from: 'https://raw.githubusercontent.com/nuuneoi/JCenter/master/installv1.gradle'

DemoApp项目build.gradle

buildscript {
            repositories {
                google()
                jcenter()
                mavenCentral()
                maven { url 'https://plugins.gradle.org/m2/' }
            }
            dependencies {
                classpath 'com.android.tools.build:gradle:3.4.2'
                classpath 'com.google.gms:google-services:3.2.0'
                classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.4'
                classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1'
                classpath "gradle.plugin.com.github.spotbugs:spotbugs-gradle-plugin:2.0.0" // For SpotBugs
                classpath "com.newrelic.agent.android:agent-gradle-plugin:5.+"
            }
        }

        allprojects {
            repositories {
                google()
                jcenter()
                maven { url 'https://maven.google.com' }
                flatDir {
                    dirs 'libs'
                }
            }
        }

        task clean(type: Delete) {
            delete rootProject.buildDir
        }

DemoApp模块build.gradle

apply plugin: 'com.android.application'
apply plugin: 'newrelic'

android {
    compileSdkVersion 28
    defaultConfig {
        applicationId "com.demo.demoapp"
        minSdkVersion 21
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"
        multiDexEnabled true
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:28.0.0'
    implementation "com.android.support:customtabs:28.0.0"
    implementation "com.android.support:support-media-compat:28.0.0"
    implementation "com.android.support:support-v4:28.0.0"
    implementation "com.android.support:mediarouter-v7:28.0.0"

    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
    implementation(name:'AndroidSDK-release', ext:'aar') // Library depedency
    implementation "com.newrelic.agent.android:android-agent:5.23.0"
}
apply plugin: 'com.google.gms.google-services'

图书馆Progaurd规则:

#-printmapping out.map
-keepparameternames
#-renamesourcefileattribute SourceFile
-keepattributes Exceptions,InnerClasses,Signature,Deprecated,SourceFile,LineNumberTable,EnclosingMethod

# Preserve all annotations.

-keepattributes *Annotation*

# Preserve all public classes, and their public and protected fields and
# methods.

-keep public class * {
    public protected *;
}

# Preserve all .class method names.

-keepclassmembernames class * {
    java.lang.Class class$(java.lang.String);
    java.lang.Class class$(java.lang.String, boolean);
}

# Preserve all native method names and the names of their classes.

-keepclasseswithmembernames class * {
    native <methods>;
}

# Preserve the special static methods that are required in all enumeration
# classes.

-keepclassmembers class * extends java.lang.Enum {
    public static **[] values();
    public static ** valueOf(java.lang.String);
}

为什么在Dexing时看到CIRCULAR REFERENCE:java.util.NoSuchElementException异常。仅当添加了NewRelic进行构建时,才会发生这种情况,否则DemoApp的构建将获得成功。

1 个答案:

答案 0 :(得分:0)

这是D8 / R8错误,影响newrelic之前的5.24.2个版本。您必须使用com.newrelic.agent.android:android-agent:5.24.2或更高版本。

请参阅此处的讨论: https://discuss.newrelic.com/t/dexing-fails-with-com-android-builder-dexing-dexarchivebuilderexception-with-newrelic-transformation/78405/7