Your data. Anywhere you go.

New Relic for iOS or Android


Download on the App Store    Android App on Google play


New Relic Insights App for iOS


Download on the App Store


Learn more

Close icon

Caused by: java.io.IOException: Error while instrumenting class NewRelicConfig.class


#1

Mobile Question Template

  • What agent version are you using?
    5.21.1

  • Please share which platform you have questions about: iOS, Android or hybrid?
    Android

  • Are you seeing an error? Please paste the stack trace, or add a screenshot for us to review:

Log

$ ./gradlew clean assembleDebug --stacktrace

Configure project :app
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 :app:processDebugGoogleServices
Parsing json file: /Users/admin/android/telus/optikMW/app/google-services.json
w: /Users/admin/android/telus/optikMW/app/src/main/kotlin/com/telus/optikmw/detailScreen/DetailActivity.kt: (33, 25): Parameter ‘view’ is never used
w: /Users/admin/android/telus/optikMW/app/src/main/kotlin/com/telus/optikmw/homeScreen/HomeActivity.kt: (31, 29): Parameter ‘view’ is never used
w: /Users/admin/android/telus/optikMW/app/src/main/kotlin/com/telus/optikmw/homeScreen/HomeActivity.kt: (35, 30): Parameter ‘view’ is never used
w: /Users/admin/android/telus/optikMW/app/src/main/kotlin/com/telus/optikmw/loginScreen/LoginActivity.kt: (47, 25): Parameter ‘view’ is never used

Task :app:transformClassesWithJacocoForDebug FAILED

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ‘:app:transformClassesWithJacocoForDebug’.

There was a failure while executing work items
A failure occurred while executing com.android.build.gradle.internal.transforms.JacocoTransform$JacocoWorkerAction
Unable to instrument file with Jacoco: /Users/admin/android/telus/optikMW/app/build/intermediates/javac/debug/compileDebugJavaWithJavac/classes/com/newrelic/agent/android/NewRelicConfig.class

  • Try:
    Run with --info or --debug option to get more log output. Run with --scan to get full insights.

  • Exception is:
    org.gradle.api.tasks.TaskExecutionException: Execution failed for task ‘:app:transformClassesWithJacocoForDebug’.
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:110)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:77)
    at org.gradle.api.internal.tasks.execution.OutputDirectoryCreatingTaskExecuter.execute(OutputDirectoryCreatingTaskExecuter.java:51)
    at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:59)
    at org.gradle.api.internal.tasks.execution.ResolveTaskOutputCachingStateExecuter.execute(ResolveTaskOutputCachingStateExecuter.java:54)
    at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:59)
    at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:101)
    at org.gradle.api.internal.tasks.execution.FinalizeInputFilePropertiesTaskExecuter.execute(FinalizeInputFilePropertiesTaskExecuter.java:44)
    at org.gradle.api.internal.tasks.execution.CleanupStaleOutputsExecuter.execute(CleanupStaleOutputsExecuter.java:91)
    at org.gradle.api.internal.tasks.execution.ResolveTaskArtifactStateTaskExecuter.execute(ResolveTaskArtifactStateTaskExecuter.java:62)
    at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:59)
    at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:54)
    at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43)
    at org.gradle.api.internal.tasks.execution.CatchExceptionTaskExecuter.execute(CatchExceptionTaskExecuter.java:34)
    at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.run(EventFiringTaskExecuter.java:51)
    at org.gradle.internal.operations.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:300)
    at org.gradle.internal.operations.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:292)
    at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:174)
    at org.gradle.internal.operations.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:90)
    at org.gradle.internal.operations.DelegatingBuildOperationExecutor.run(DelegatingBuildOperationExecutor.java:31)
    at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter.execute(EventFiringTaskExecuter.java:46)
    at org.gradle.execution.taskgraph.LocalTaskInfoExecutor.execute(LocalTaskInfoExecutor.java:42)
    at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$BuildOperationAwareWorkItemExecutor.execute(DefaultTaskExecutionGraph.java:277)
    at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$BuildOperationAwareWorkItemExecutor.execute(DefaultTaskExecutionGraph.java:262)
    at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$ExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:135)
    at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$ExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:130)
    at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$ExecutorWorker.execute(DefaultTaskPlanExecutor.java:200)
    at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$ExecutorWorker.executeWithWork(DefaultTaskPlanExecutor.java:191)
    at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$ExecutorWorker.run(DefaultTaskPlanExecutor.java:130)
    at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63)
    at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:46)
    at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:55)
    Caused by: org.gradle.workers.WorkerExecutionException: There was a failure while executing work items
    at org.gradle.workers.internal.DefaultWorkerExecutor.workerExecutionException(DefaultWorkerExecutor.java:155)
    at org.gradle.workers.internal.DefaultWorkerExecutor.await(DefaultWorkerExecutor.java:149)
    at com.android.build.gradle.internal.transforms.JacocoTransform.transform(JacocoTransform.java:145)
    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 jdk.internal.reflect.GeneratedMethodAccessor615.invoke(Unknown Source)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:73)
    at org.gradle.api.internal.project.taskfactory.IncrementalTaskAction.doExecute(IncrementalTaskAction.java:50)
    at org.gradle.api.internal.project.taskfactory.StandardTaskAction.execute(StandardTaskAction.java:39)
    at org.gradle.api.internal.project.taskfactory.StandardTaskAction.execute(StandardTaskAction.java:26)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$1.run(ExecuteActionsTaskExecuter.java:131)
    at org.gradle.internal.operations.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:300)
    at org.gradle.internal.operations.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:292)
    at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:174)
    at org.gradle.internal.operations.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:90)
    at org.gradle.internal.operations.DelegatingBuildOperationExecutor.run(DelegatingBuildOperationExecutor.java:31)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:120)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:99)
    … 31 more
    Caused by: org.gradle.workers.internal.DefaultWorkerExecutor$WorkExecutionException: A failure occurred while executing com.android.build.gradle.internal.transforms.JacocoTransform$JacocoWorkerAction
    at org.gradle.workers.internal.DefaultWorkerExecutor$WorkerExecution.waitForCompletion(DefaultWorkerExecutor.java:274)
    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:147)
    … 50 more
    Caused by: java.io.UncheckedIOException: Unable to instrument file with Jacoco: /Users/admin/android/telus/optikMW/app/build/intermediates/javac/debug/compileDebugJavaWithJavac/classes/com/newrelic/agent/android/NewRelicConfig.class
    at com.android.build.gradle.internal.transforms.JacocoTransform$JacocoWorkerAction.run(JacocoTransform.java:290)
    at org.gradle.workers.internal.DefaultWorkerServer.execute(DefaultWorkerServer.java:39)
    at org.gradle.workers.internal.DefaultWorkerServer.execute(DefaultWorkerServer.java:25)
    at org.gradle.workers.internal.IsolatedClassloaderWorkerFactory$WorkerCallable.call(IsolatedClassloaderWorkerFactory.java:177)
    at org.gradle.workers.internal.IsolatedClassloaderWorkerFactory.executeInWorkerClassLoader(IsolatedClassloaderWorkerFactory.java:105)
    at org.gradle.workers.internal.IsolatedClassloaderWorkerFactory.access$100(IsolatedClassloaderWorkerFactory.java:54)
    at org.gradle.workers.internal.IsolatedClassloaderWorkerFactory$1$1.call(IsolatedClassloaderWorkerFactory.java:78)
    at org.gradle.workers.internal.IsolatedClassloaderWorkerFactory$1$1.call(IsolatedClassloaderWorkerFactory.java:75)
    at org.gradle.internal.operations.DefaultBuildOperationExecutor$CallableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:314)
    at org.gradle.internal.operations.DefaultBuildOperationExecutor$CallableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:304)
    at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:174)
    at org.gradle.internal.operations.DefaultBuildOperationExecutor.call(DefaultBuildOperationExecutor.java:100)
    at org.gradle.internal.operations.DelegatingBuildOperationExecutor.call(DelegatingBuildOperationExecutor.java:36)
    at org.gradle.workers.internal.IsolatedClassloaderWorkerFactory$1.execute(IsolatedClassloaderWorkerFactory.java:75)
    at org.gradle.workers.internal.DefaultWorkerExecutor$1.call(DefaultWorkerExecutor.java:102)
    at org.gradle.workers.internal.DefaultWorkerExecutor$1.call(DefaultWorkerExecutor.java:96)
    at org.gradle.internal.work.AbstractConditionalExecution$1.run(AbstractConditionalExecution.java:38)
    at org.gradle.internal.work.DefaultConditionalExecutionQueue$ExecutionRunner.runExecution(DefaultConditionalExecutionQueue.java:212)
    at org.gradle.internal.work.DefaultConditionalExecutionQueue$ExecutionRunner.runBatch(DefaultConditionalExecutionQueue.java:161)
    at org.gradle.internal.work.DefaultConditionalExecutionQueue$ExecutionRunner.run(DefaultConditionalExecutionQueue.java:130)
    … 3 more
    Caused by: java.io.IOException: Error while instrumenting class /Users/admin/android/telus/optikMW/app/build/intermediates/javac/debug/compileDebugJavaWithJavac/classes/com/newrelic/agent/android/NewRelicConfig.class.
    at org.jacoco.core.instr.Instrumenter.instrumentError(Instrumenter.java:166)
    at org.jacoco.core.instr.Instrumenter.instrument(Instrumenter.java:117)
    at org.jacoco.core.instr.Instrumenter.instrument(Instrumenter.java:136)
    at com.android.build.gradle.internal.transforms.JacocoTransform$JacocoWorkerAction.run(JacocoTransform.java:284)
    … 22 more
    Caused by: java.lang.IllegalArgumentException
    at org.objectweb.asm.ClassReader.(ClassReader.java:185)
    at org.objectweb.asm.ClassReader.(ClassReader.java:168)
    at org.jacoco.core.instr.Instrumenter.instrument(Instrumenter.java:114)
    … 24 more

Please describe what you are seeing:
I am not able to buils my project via command line by this command: $ ./gradlew clean assembleDebug

How does that differ from what were you expecting to see?
I have no issue to build and run the project via Android Studio.
Also, I was able to build the project via command line before integrating Newrelic into our project.
Also, I am able to build the project via command line if I comment apply plugin: 'newrelic' out from my :app module.

More details:
I have multi module Android prioject (based on Kotlin). My main module is :app module that depends on rest of lib modules such as :analytics, :network, :log, etc.

build.gradle (in root of the project)

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {

ext.OpticMW_AppId = ‘123’
ext.OpticMW_ClientId = ‘123’

// New Relic Token. If update TOKEN here, do update it in app/newrelic.properties
ext.NewRelic_Token = ‘AAd578452af4e4b7b56d4427721eb95f67fa85d3a4’ // Telus token : AA1ce4b7212a316c4cfd0c57030dd1a75ccbc421c0

ext.kotlin_version = ‘1.3.10’
ext.google_services = ‘4.0.1’
ext.google_play_services = ‘16.0.5’
ext.support_version = ‘1.0.0’
ext.androidx_appcompat_version = ‘1.0.2’
ext.androidx_lifecycle_version = ‘2.0.0’
ext.constraint_layout_version = ‘1.1.3’
ext.square_okhttp3_version = ‘3.11.0’
ext.square_retrofit_version = ‘2.4.0’
ext.square_moshi_version = ‘1.8.0’
ext.glide_version = ‘4.8.0’
ext.koin_version = ‘1.0.1’
ext.coroutines_version = ‘1.0.0’
ext.junit_version = ‘4.12’
ext.logger_version = ‘2.2.0’
ext.newrelic_version = ‘5.21.1’
ext.jacoco_version = ‘0.8.2’
ext.dexcount_version = ‘0.8.4’

repositories {
google()
jcenter()
mavenCentral()
}

dependencies {
classpath ‘com.android.tools.build:gradle:3.2.1’
classpath “org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version”
classpath “com.google.gms:google-services:$google_services”
classpath “com.newrelic.agent.android:agent-gradle-plugin:$newrelic_version”
classpath “com.getkeepsafe.dexcount:dexcount-gradle-plugin:$dexcount_version”
classpath “org.jacoco:org.jacoco.core:$jacoco_version”
}
}

allprojects {
repositories {
google()
jcenter()
maven { url ‘https://jitpack.io’ }
}
}

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

:app/build.gradle

apply plugin: ‘com.android.application’
apply plugin: ‘kotlin-android’
apply plugin: ‘kotlin-kapt’
apply plugin: ‘kotlin-android-extensions’
apply plugin: ‘com.getkeepsafe.dexcount’
apply from: ‘…/scripts/jacoco.gradle’
apply plugin: ‘newrelic’

android {
compileSdkVersion 28

defaultConfig {
applicationId “com.telus.optikmw”
minSdkVersion 24
targetSdkVersion 28
versionCode 1
versionName “1.0”

multiDexEnabled true
}

buildTypes {
debug {
testCoverageEnabled true

buildConfigField “String”, ‘NewRelic_Token’, ‘"$NewRelic_Token"’
}

release {
buildConfigField “String”, ‘NewRelic_Token’, ‘"$NewRelic_Token"’

minifyEnabled false
proguardFiles getDefaultProguardFile(‘proguard-android.txt’), ‘proguard-rules.pro’
}
}

signingConfigs {
debug {
storeFile file("…/debug.keystore")
}
}

sourceSets {
main.java.srcDirs += ‘src/main/kotlin’
}

testOptions {
execution ‘ANDROID_TEST_ORCHESTRATOR’
animationsDisabled true

unitTests {
includeAndroidResources = true
}
}
}

dependencies {
implementation fileTree(include: [’*.jar’], dir: ‘libs’)

api project(’:OpLog’)
implementation project(’:OpNetwork’)
implementation project(’:OpAnalytics’)
implementation project(’:OpStorage’)

implementation “androidx.constraintlayout:constraintlayout:$constraint_layout_version”
implementation “androidx.leanback:leanback:$support_version”
implementation “androidx.recyclerview:recyclerview:$support_version”
implementation “androidx.appcompat:appcompat:$androidx_appcompat_version”
implementation “androidx.lifecycle:lifecycle-extensions:$androidx_lifecycle_version”
kapt “androidx.lifecycle:lifecycle-compiler:$androidx_lifecycle_version”

implementation “org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version”
implementation “org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutines_version”
implementation “org.jetbrains.kotlinx:kotlinx-coroutines-android:$coroutines_version”

implementation “com.github.bumptech.glide:glide:$glide_version”
kapt “com.github.bumptech.glide:compiler:$glide_version”

implementation “org.koin:koin-android:$koin_version”

implementation “com.newrelic.agent.android:android-agent:$newrelic_version”
}

apply plugin: ‘com.google.gms.google-services’

Application (to initialize the Newrelic)

package com.telus.optikmw

import android.app.Application
import com.newrelic.agent.android.NewRelic
import com.newrelic.agent.android.logging.AgentLog

class OptikApplication : Application() {

init {
instance = this
}

companion object {
private var instance: OptikApplication? = null

fun applicationContext() : OptikApplication {
return instance as OptikApplication
}
}

override fun onCreate() {
super.onCreate()

initNewRelic()
}

private fun initNewRelic(){
NewRelic.withApplicationToken(BuildConfig.NewRelic_Token)
.withLoggingEnabled(true)
.withLogLevel(AgentLog.ERROR)
.start(this)
}
}

Any help in this case would be appreciated.
Thanks.


#2

Hi @hesam,

It seems you are initializing the New Relic Android agent in the Application class. This is not supported and may cause unexpected behavior. Would you try initializing the New Relic agent in your default activity (MainActivity) as our doc recommended and see how it works?

https://docs.newrelic.com/docs/mobile-monitoring/new-relic-mobile-android/install-configure/install-android-apps-gradle-android-studio#configuration

Please call the start method directly in the onCreate method of the MainActivity class as below.

NewRelic.withApplicationToken("GENERATED_TOKEN").start(this.getApplication());

#3

Hi Hesam,

Thank you for finding the root cause (uninstall JDK 11 and install JDK 8) and I am glad you have fixed it!

Regarding D8 warning ,
D8: Stripped invalid locals information from 1 method.

I received those same warnings when I built your sample project. I found only a few references to this and all in 2018. From what I’ve seen, it looks like it can be silenced with a tweak to the proguard rules file with no negative side effects.

I hope you were able to see my colleagues note about where you were starting up New Relic in the app. You should start it in the default activity as specified in your manifest, not the Application class. Starting in the Application class can lead to data irregularities.

Have a great day!


#4

Hello guys,

Thanks for your answers.
I just moved Newrelic initialization part from Application level to Activity level (Splash Activity in my case as this is the first screen that is being used).