cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

java.lang.IllegalStateException: auto-instrumentation failed

start
Newcomer

I have been facing the issue of auto instrumentation failed while integrating dynatrace. I have using multidex configuration application. can anyone provide the answer for me earliest. I have look into this issue for past one week. please anyone help on this

java.lang.IllegalStateException: auto-instrumentation failed
at com.dynatrace.tools.android.AutoInstrumentTask.instrument(AutoInstrumentTask.java:153)
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:73)
at org.gradle.api.internal.project.taskfactory.StandardTaskAction.doExecute(StandardTaskAction.java:46)
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.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:780)
at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:747)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$1.run(ExecuteActionsTaskExecuter.java:121)
at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:336)
at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:328)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:199)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:110)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:110)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:92)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:70)
at org.gradle.api.internal.tasks.execution.OutputDirectoryCreatingTaskExecuter.execute(OutputDirectoryCreatingTaskExecuter.java:51)
at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:62)
at org.gradle.api.internal.tasks.execution.ResolveTaskOutputCachingStateExecuter.execute(ResolveTaskOutputCachingStateExecuter.java:54)
at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:60)
at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:97)
at org.gradle.api.internal.tasks.execution.CleanupStaleOutputsExecuter.execute(CleanupStaleOutputsExecuter.java:87)
at org.gradle.api.internal.tasks.execution.ResolveTaskArtifactStateTaskExecuter.execute(ResolveTaskArtifactStateTaskExecuter.java:52)
at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:52)
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.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker$1.run(DefaultTaskGraphExecuter.java:248)
at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:336)
at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:328)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:199)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:110)
at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:241)
at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:230)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.processTask(DefaultTaskPlanExecutor.java:123)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.access$200(DefaultTaskPlanExecutor.java:79)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:104)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:98)
at org.gradle.execution.taskgraph.DefaultTaskExecutionPlan.execute(DefaultTaskExecutionPlan.java:626)
at org.gradle.execution.taskgraph.DefaultTaskExecutionPlan.executeWithTask(DefaultTaskExecutionPlan.java:581)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.run(DefaultTaskPlanExecutor.java:98)
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)


9 REPLIES 9

Thomas_Wirth1
Dynatrace Champion
Dynatrace Champion

Hi ewfefed,

you have to look at the log output to find out why the auto-instrumentor failed. In the latest Android Studio version you can find the log output in the "Build" view (View -> Tool Windows -> Build).

The log output is also stored in a log file. The log files are stored in the directory:

<project>/<module>/build/tmp/autoInstrument<variant>/logs

start
Newcomer

Thanks Thomas. I post the log

2018-07-13 20:00:57.205 INFO: APKit-AdkInstrumentor(1): Dynatrace Auto-Instrumentation version 7.1.8.2306 for Android
2018-07-13 20:00:57.207 INFO: APKit-e(1): Decoding C:\Users\dineshkumar_a\Documents\ttnlc\UAT\android-shoplc\liquidationchannel\build\outputs\apk\debug\liquidationchannel-debug.apk
2018-07-13 20:01:26.482 INFO: APKit-e(1): Updating manifest file C:\Users\dineshkumar_a\Documents\ttnlc\UAT\android-shoplc\liquidationchannel\build\outputs\apk\debug\liquidationchannel-debug\AndroidManifest.xml
2018-07-13 20:01:26.737 INFO: APKit-AdkInstrumentor(1): MinSdkVersion=19 TargetSdkVersion=27
2018-07-13 20:01:26.785 INFO: APKit-AdkInstrumentor(1): C:\Users\dineshkumar_a\Documents\ttnlc\UAT\android-shoplc\liquidationchannel\build\outputs\apk\debug\liquidationchannel-debug/classes.dex ... #methods: 43919
2018-07-13 20:01:26.802 INFO: APKit-AdkInstrumentor(1): C:\Users\dineshkumar_a\Documents\ttnlc\UAT\android-shoplc\liquidationchannel\build\outputs\apk\debug\liquidationchannel-debug\classes2.dex ... #methods: 53767
2018-07-13 20:01:35.481 INFO: APKit-AdkInstrumentor(1): Forcing jumbo string option for classes.dex
2018-07-13 20:01:35.524 INFO: APKit-q(1): Input file: C:\Users\dineshkumar_a\Documents\ttnlc\UAT\android-shoplc\liquidationchannel\build\outputs\apk\debug\liquidationchannel-debug\classes-no-jumbo.dex
2018-07-13 20:01:35.525 INFO: APKit-q(1): Output file: C:\Users\dineshkumar_a\Documents\ttnlc\UAT\android-shoplc\liquidationchannel\build\outputs\apk\debug\liquidationchannel-debug\classes.dex
2018-07-13 20:01:37.837 INFO: APKit-q(1): C:\Users\dineshkumar_a\Documents\ttnlc\UAT\android-shoplc\liquidationchannel\build\outputs\apk\debug\liquidationchannel-debug\classes.dex created
2018-07-13 20:01:37.838 INFO: APKit-q(1): Count: 36979 already jumbo & 0 made jumbo
2018-07-13 20:01:37.838 INFO: APKit-q(1): Strings: 17044 already jumbo & 0 became jumbo
2018-07-13 20:01:37.838 INFO: APKit-q(1): Total string count: 60527
2018-07-13 20:01:37.840 INFO: APKit-q(1): Force-jumbo did not take effect for C:\Users\dineshkumar_a\Documents\ttnlc\UAT\android-shoplc\liquidationchannel\build\outputs\apk\debug\liquidationchannel-debug\classes.dex
2018-07-13 20:01:37.898 SEVERE: APKit-v(1): 912 + 65535 = 66447 fields
2018-07-13 20:01:37.898 SEVERE: APKit-AdkInstrumentor(1): Auto-Instrumentation cannot handle this application - too many fields
Throwable occurred: h: Auto-Instrumentation cannot handle this application - too many fields
at com.dynatrace.android.instrumentation.AdkInstrumentor.a(SourceFile:763)
at com.dynatrace.android.instrumentation.AdkInstrumentor.a(SourceFile:773)
at com.dynatrace.android.instrumentation.AdkInstrumentor.c(SourceFile:447)

at com.dynatrace.android.instrumentation.AdkInstrumentor.main(SourceFile:251)


Thomas_Wirth1
Dynatrace Champion
Dynatrace Champion

Hi ewfefed,

You primary dex file contains to many fields and therefore the auto-instrumentor can't add the agent library to the primary dex file. Unfortunately the auto-instrumentor has no customize option for fields. The only option is to adjust the method limit and thereby reduce the number of fields in the pirmary dex file.

In your case the primary dex file has 43919 referenced methods. I think auto-instrumentation should work, when you use

DTXPrimaryDexLimit=40000

start
Newcomer

agentProperties 'DTXLogLevel': 'debug', 'DTXPrimaryDexLimit': '40000', 'DTXSecondaryDexLimit': '65535'


start
Newcomer

'DTXSecondaryDexLimit': '65535' is correct value?


Thomas_Wirth1
Dynatrace Champion
Dynatrace Champion

If you don't have to adjust the property DTXSecondaryDexLimit, then you should not do it. I would recommend you that you rebuild the app without modifying the property DTXSecondaryDexLimit. If the default value does not suit your application, then the auto-instumentor will recommend a proper value in the error message.

The value 65535 is NOT appropriate. With this value you overide the default setting and the auto-instrumentor will not ensure that there is enough space for the instrumentation instructions. You find more information about these properties in the official documentation.


start
Newcomer

Thanks Thomas for your timely help. Now working fine ... How to adjust the value 43919 the values is 40000 . if value i have some values like #methods: 65480 what will be values any calculation or round off the values


Thomas_Wirth1
Dynatrace Champion
Dynatrace Champion

In this special case (where the number of referenced field is too high) the value depends on the distribution of the fields and the current number of methods as your goal is to move some fields from the primary dex file to a secondary dex file.

You should always choose a value that allows you to modify your
application without adjusting the property values. Therefore we
recommend to use a slightly lower value as the given one (by the
auto-instrumentor or current number of referenced methods).


Thomas_Wirth1
Dynatrace Champion
Dynatrace Champion

I'm not sure, what you mean. Normally you should use the default values for the properties DTXPrimaryDexLimit and DTXSecondaryDexLimit. If the default values do not suit your application, then the auto-instrumentor recommends a different setting. In this case we recommend to use a slightly lower value to avoid future adaptions. If you find a value that allows you to modify the app without adjusting the properties, then you should stick to this value.

The properties DTXPrimaryDexLimit and DTXSecondaryDexLimit are based on the referenced method count. But in your initial scenario the number of referenced fields was too high (the number of referenced methods is fine). We can force the auto-instrumentor to move some classes from the primary dex file into a secondary dex file by manually reducing the DTXPrimaryDexLimit value. I do not know the structure of your application and therefore I recommended a very low value. But higher values like 4300 should/can also work.


Featured Posts