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

This product reached the end of support date on March 31, 2021.

Android app instrumentation

yakov_a_sobolev
Newcomer

We are trying to instrument android application.

We followed instructions at Dynatrace wiki

https://community.dynatrace.com/community/display/...

However, we do not see anything in DT server 6.3

We were able to instrument iOS app. In iOS app the trick was to set cpwrUEM_startup.agentPath

What about Android app. Should we do the same?

Where should we put it?

15 REPLIES 15

Babar_Qayyum
Leader

Hello Yakov,

Watch the below video to understand the instrumentation of Android Application.

https://www.youtube.com/watch?v=uLIuPeFbXBA&index=...

You can also follow the simple steps from the below link:

https://github.com/Dynatrace/Android-Hybrid-App-Sa...

Regards,

Babar

I don't think he's talking about a Hybrid Android app so I'm not really sure how this would help.

arihant_polavar
Dynatrace Pro
Dynatrace Pro

Hello Yakov,

Since you linked the auto-instrumentation doc, I am assuming you tried to instrument your Android App using the Auto Instrumentator?

If that is the case, you do need to set the cpwrUEM_startup.agentPath argument to your Web Server agent. You need to edit the APK-Instr properties file (should be inside the ../Android/auto-instrumentor folder of the ADK) for this. You should see that field right away.

If you are not using auto instrumentation and manually instrumenting the app, you need to call DynatraceUEM.startup method and provide the agentpath (amongst other things) in the argument for that method. More info on that here but I do suspect that you are using auto-instrumentation -> https://community.dynatrace.com/community/display/...)

Let me know if any of this helps, we'll get this working for you!

Thanks,

Ari

Thanks Ari,

Are there any benefits of using auto-instrumentation vs. not using auto-instrumentation?

I would strongly recommend using auto-instrumentation. Its easier to deploy and maintain, and you also don't need to make any changes to your code base.

yakov_a_sobolev
Newcomer

I tried to auto-instrument APK.

$ ./instrument.sh apk=androidApp.apk prop=APK-Instr.properties

INFO: APKit-Instor(1): Starting Dynatrace Auto-Instrumentation for Android version 5.1

INFO: APKit-Logger(1): Log file: A_2017-02-25_16-08-56.log

INFO: APKit-Instor(1): Dynatrace Auto-Instrumentation for Android version 5.1

INFO: caa-jApkRecomp(1): Decoding androidApp.apk

INFO: caa-jApkRecomp(1): Updating manifest file AndroidManifest.xml

INFO: APKit-ApkRecomp(1): Current versionCode=700001406

INFO: APKit-ApkRecomp(1): New versionCode=700001406

INFO: APKit-ApkRecomp(1): Current versionName=1.600

INFO: APKit-ApkRecomp(1): New versionName=1.600

INFO: APKit-Instor(1): MinSdkVersion=16 TargetSdkVersion=23

INFO: APKit-Instor(1): dynatrace-mobile-adk-6.3.16.1014/Android/auto-instrumentor/androidApp/classes.dex ... #methods: 65385

INFO: APKit-Instor(1): Caught TooManyMethodsException: Primary dex contains too many methods: 65385 ... starting multidex preprocessor.

Exception in thread "main" java.lang.RuntimeException: Failed to perform multidex preprocess for 'dynatrace-mobile-adk-6.3.16.1014/Android/auto-instrumentor/androidApp.apk'

at com.cpwr.apm.android.common.multidex.MultidexTools.a(Unknown Source)

at com.cpwr.apm.android.adk.AdkInstrumentor.main(SourceFile:1146)

Instrumentation failed

Ok this happens when the auto instrumentation causes the number of methods to go over 65k limit, try adding two more attributes to the APK-Instr file, these are DTXMaxDexMethods and DTXMultidexMoveMethodCount. Try setting them in the properties and running the auto-instrumentation again. You might have to try a few different numbers before you find the one that works. Can you attach the complete log file? Usually it tells you what numbers to use. Should be something like "Please adjust the DTXMultidexMoveMethodCount property to......"

Here's the link to some more info on this issue -> https://community.dynatrace.com/community/display/DOCDT63/Auto-Instrumentation+for+Android#Auto-InstrumentationforAndroid-Multi-dexapplications

Hope this helps,

Ari

yakov_a_sobolev
Newcomer

Thanks Ari,

I added to APK-Instr.properties:

DTXMaxDexMethods=65000

DTXMultidexMoveMethodCount=65152

But still get an exception:

Exception in thread "main" com.cpwr.apm.android.common.f: classes2.dex contains too many methods: 65152

at com.cpwr.apm.android.adk.AdkInstrumentor.a(SourceFile:219)

at com.cpwr.apm.android.adk.AdkInstrumentor.a(SourceFile:150)

at com.cpwr.apm.android.adk.AdkInstrumentor.main(SourceFile:1150)

Instrumentation failed

Try increasing the count to something higher than 65152. Can you also post the entire log from the instrumentation too?

zengsinan
Inactive

In my App,I uset crosswalk-webview ,and DynatraceUEM.registerWebView(super.appView); didn't work.

Caused by: java.lang.ClassCastException: org.crosswalk.engine.XWalkCordovaView cannot be cast to android.webkit.WebView
at com.ionicframework.ionicapp985585.MainActivity.init(MainActivity.java:55)
at org.apache.cordova.CordovaActivity.loadUrl(CordovaActivity.java:214)
at com.ionicframework.ionicapp985585.MainActivity.onCreate(MainActivity.java:45)

any answer for this?

Afraid I don't. I would recommend opening a support ticket for something like this.

yakov_a_sobolev
Newcomer

I am using version 6.3

I changed DTXMultidexMoveMethodCount to different values? What should it be?

70000 or 80000 or 165000?

I added following flags:

DTXMaxDexMethods=65000 

DTXMultidexMoveMethodCount=65385

DTXLogLevel=debug

Got following error this time:

017-03-19 11:57:09.519 INFO: APKit-Instor(1): Starting Dynatrace Auto-Instrumentation for Android version 5.1

2017-03-19 11:57:09.522 INFO: APKit-Logger(1): Log file: /Users/v003116/Downloads/dynatrace-mobile-adk-6.3.16.1014/Android/auto-instrumentor/logs/AIA_2017-03-19_11-57-09.log

2017-03-19 11:57:09.531 INFO: APKit-Instor(1): Dynatrace Auto-Instrumentation for Android version 5.1

2017-03-19 11:57:09.533 INFO: caa-jApkRecomp(1): Decoding ./androidApp.apk

2017-03-19 11:57:17.614 INFO: caa-jApkRecomp(1): Updating manifest file /Users/v003116/Downloads/dynatrace-mobile-adk-6.3.16.1014/Android/auto-instrumentor/./androidApp/AndroidManifest.xml

2017-03-19 11:57:17.640 INFO: APKit-ApkRecomp(1): Current versionCode=700001406

2017-03-19 11:57:17.640 INFO: APKit-ApkRecomp(1): New versionCode=700001406

2017-03-19 11:57:17.640 INFO: APKit-ApkRecomp(1): Current versionName=1.600

2017-03-19 11:57:17.640 INFO: APKit-ApkRecomp(1): New versionName=1.600

2017-03-19 11:57:17.681 INFO: APKit-Instor(1): MinSdkVersion=16 TargetSdkVersion=23

2017-03-19 11:57:20.947 INFO: APKit-Instor(1): /Users/v003116/Downloads/dynatrace-mobile-adk-6.3.16.1014/Android/auto-instrumentor/./androidApp/classes.dex ... #methods: 65385

2017-03-19 11:57:20.947 INFO: APKit-Instor(1): Caught TooManyMethodsException: Primary dex contains too many methods: 65385 ... starting multidex preprocessor.

2017-03-19 11:57:59.356 INFO: APKit-Instor(1): Dynatrace Auto-Instrumentation for Android version 5.1

2017-03-19 11:57:59.356 INFO: caa-jApkRecomp(1): Decoding /Users/v003116/Downloads/dynatrace-mobile-adk-6.3.16.1014/Android/auto-instrumentor/androidApp-multidexPreprocess.apk

2017-03-19 11:58:07.442 INFO: caa-jApkRecomp(1): Updating manifest file /Users/v003116/Downloads/dynatrace-mobile-adk-6.3.16.1014/Android/auto-instrumentor/androidApp-multidexPreprocess/AndroidManifest.xml

2017-03-19 11:58:07.447 INFO: APKit-ApkRecomp(1): Current versionCode=700001406

2017-03-19 11:58:07.447 INFO: APKit-ApkRecomp(1): New versionCode=700001406

2017-03-19 11:58:07.448 INFO: APKit-ApkRecomp(1): Current versionName=1.600

2017-03-19 11:58:07.448 INFO: APKit-ApkRecomp(1): New versionName=1.600

2017-03-19 11:58:07.453 INFO: APKit-Instor(1): MinSdkVersion=16 TargetSdkVersion=23

2017-03-19 11:58:07.454 INFO: APKit-Instor(1): /Users/v003116/Downloads/dynatrace-mobile-adk-6.3.16.1014/Android/auto-instrumentor/androidApp-multidexPreprocess/classes.dex ... #methods: 0

2017-03-19 11:58:10.087 INFO: APKit-Instor(1): /Users/v003116/Downloads/dynatrace-mobile-adk-6.3.16.1014/Android/auto-instrumentor/androidApp-multidexPreprocess/classes2.dex ... #methods: 65152

Exception in thread "main" com.cpwr.apm.android.common.f: classes2.dex contains too many methods: 65152

at com.cpwr.apm.android.adk.AdkInstrumentor.a(SourceFile:219)

at com.cpwr.apm.android.adk.AdkInstrumentor.a(SourceFile:150)

at com.cpwr.apm.android.adk.AdkInstrumentor.main(SourceFile:1150)

Instrumentation failed

At this point, I would recommend opening a support ticket. They can look at this more closely and get it working.

bhargav_garimel
Newcomer

Can you please look onto this we are getting error while doinf auto instrumentation

Here i am adding the error logs

2017-05-09 12:32:32.192 INFO: APKit-Instor(1): Starting Dynatrace Auto-Instrumentation for Android version 4.2
2017-05-09 12:32:32.192 INFO: APKit-Logger(1): Log file: C:\Program Files\dynaTrace\dynaTrace Client 6.2 (x64)\client\logs\AIA_2017-05-09_12-32-32.log
2017-05-09 12:32:32.208 SEVERE: APKit-Logger(1): Failed to create a log file handler
Throwable occurred: java.nio.file.NoSuchFileException: C:\Program Files\dynaTrace\dynaTrace Client 6.2 (x64)\client\logs\AIA_2017-05-09_12-32-32.log.lck
at sun.nio.fs.WindowsException.translateToIOException(WindowsException.java:79)
at sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:97)
at sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:102)
at sun.nio.fs.WindowsFileSystemProvider.newFileChannel(WindowsFileSystemProvider.java:115)
at java.nio.channels.FileChannel.open(FileChannel.java:287)
at java.nio.channels.FileChannel.open(FileChannel.java:335)
at java.util.logging.FileHandler.openFiles(FileHandler.java:459)
at java.util.logging.FileHandler.<init>(FileHandler.java:292)
at com.cpwr.apm.android.adk.diag.logging.AdkLogger.getFileHandler(SourceFile:42)
at com.cpwr.apm.common.diag.logging.BaseLogger.init(Unknown Source)
at com.cpwr.apm.common.diag.logging.BaseLogger.<init>(Unknown Source)
at com.cpwr.apm.android.adk.diag.logging.AdkLogger.<init>(SourceFile:26)
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.lang.Class.newInstance(Class.java:442)
at com.cpwr.apm.common.control.BaseController.initLogger(Unknown Source)
at com.cpwr.apm.common.control.BaseController.updateConfig(Unknown Source)
at com.cpwr.apm.android.adk.AdkInstrumentor.<init>(SourceFile:76)
at com.cpwr.apm.android.adk.AdkInstrumentor.a(SourceFile:984)
at com.cpwr.apm.android.adk.AdkInstrumentor.main(SourceFile:1002)
2017-05-09 12:32:32.208 INFO: APKit-Instor(1): Dynatrace Auto-Instrumentation for Android version 4.2
2017-05-09 12:32:32.208 INFO: caa-jApkRecomp(1): Decoding D:\Manjunath\Build\New folder (2)\Housejoy-release.apk
Exception in thread "main" com.cpwr.apm.android.common.a: Failed to extract the APK.
at com.cpwr.apm.android.common.b.f(Unknown Source)
at com.cpwr.apm.android.common.b.<init>(Unknown Source)
at com.cpwr.apm.android.adk.AdkApkRecompiler.<init>(SourceFile:49)
at com.cpwr.apm.android.adk.AdkInstrumentor.a(SourceFile:93)
at com.cpwr.apm.android.adk.AdkInstrumentor.main(SourceFile:1006)
Unable to instrument "D:\Manjunath\Build\New folder (2)\Housejoy-release.apk". See log for details.

'

deepak_unnikri1
Newcomer

Hi Team,

We are getting the below error while we are trying to instrument the android app. Kindly do the needful

org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':liquidationchannel:autoInstrumentDebug'.
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:100)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:70)
at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:63)
at org.gradle.api.internal.tasks.execution.ResolveTaskOutputCachingStateExecuter.execute(ResolveTaskOutputCachingStateExecuter.java:54)
at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:58)
at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:88)
at org.gradle.api.internal.tasks.execution.ResolveTaskArtifactStateTaskExecuter.execute(ResolveTaskArtifactStateTaskExecuter.java:52)
at org.gradle.api.internal.tasks.execution.SkipTaskWit

Thanks,

Deepak U