Hello
I want to instrument my android app in appdynamics. I created the app in android studio. It is a simple 'hello world' app. Below is the java code:
package com.example.adit.myapplication; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import com.appdynamics.eumagent.runtime.AgentConfiguration; import com.appdynamics.eumagent.runtime.Instrumentation; public class MainActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); Instrumentation.start("xx-xxx-xxx-xxx", getApplicationContext()); //Instrumentation.start(AgentConfiguration.builder().withContext(this).withAppKey("xx-xxx-xxx-xxx").withLoggingEnabled(true).withCollectorURL("http://10.0.0.27:7001").build()); } }
My top-level project build.gradle file is:
// Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { repositories { jcenter() //mavenCentral() } dependencies { classpath 'com.android.tools.build:gradle:2.1.3' classpath 'com.appdynamics:appdynamics-gradle-plugin:4.+' // this line added for AppDynamics // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files } } allprojects { repositories { jcenter() //mavenCentral() } }
My module build.gradle file is:
apply plugin: 'com.android.application' apply plugin: 'adeum' // this line added for AppDynamics android { compileSdkVersion 24 buildToolsVersion "24.0.2" defaultConfig { applicationId "com.example.adit.myapplication" minSdkVersion 15 targetSdkVersion 24 versionCode 1 versionName "1.0" } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } } repositories { flatDir { dirs 'lib' } } dependencies { compile 'com.appdynamics:appdynamics-runtime:4.+' // this line added for AppDynamics compile fileTree(dir: 'libs', include: ['*.jar']) testCompile 'junit:junit:4.12' compile 'com.android.support:appcompat-v7:24.2.1' } adeum { // this section added for AppDynamics account { name '281215-ss-Ogilvy-net8du5zsh4i' licenseKey 'You must request this key from an Admin.' } proguardMappingFileUpload { failBuildOnUploadFailure true //should build fail if upload fails? Defaults to false. enabled true //enables automatic uploads. Defaults to true. } }
My proguard-rules.pro file is:
# Add project specific ProGuard rules here. # By default, the flags in this file are appended to flags specified # in C:\Users\Adit\AppData\Local\Android\Sdk/tools/proguard/proguard- android.txt # You can edit the include path and order by changing the proguardFiles # directive in build.gradle. # # For more details, see # http://developer.android.com/guide/developing/tools/proguard.html # Add any project specific keep options here: # If your project uses WebView with JS, uncomment the following # and specify the fully qualified class name to the JavaScript interface # class: #-keepclassmembers class fqcn.of.javascript.interface.for.webview { # public *; #} -keep class com.appdynamics.eumagent.runtime.DontObfuscate -keep @com.appdynamics.eumagent.runtime.DontObfuscate class * { *; }
I have added necessary permissions in the manifest.xml file.
I am using Samsung SM-T585(Android 6.0.1,API 23) to run my app from android studio. I have connected my device to my pc with usb cable and configured my device network's proxy settings so that both my pc and my device are in the same network.
When I try to build the app using "gradle -i" command in the terminal in android studio I get the following error:
Appdynamics will use Transform API to inject. Parsing the SDK, no caching allowed Parsing C:\Users\Adit\AppData\Local\Android\Sdk\build- tools\24.0.2\package.xml Parsing C:\Users\Adit\AppData\Local\Android\Sdk\extras\android\m2repository\package.xml Parsing C:\Users\Adit\AppData\Local\Android\Sdk\extras\google\m2repository\package.xml Parsing C:\Users\Adit\AppData\Local\Android\Sdk\extras\intel\Hardware_Accelerated_Execut ion_Manager\package.xml Parsing C:\Users\Adit\AppData\Local\Android\Sdk\platform-tools\package.xml Parsing C:\Users\Adit\AppData\Local\Android\Sdk\platforms\android-24\package.xml Parsing C:\Users\Adit\AppData\Local\Android\Sdk\sources\android- 24\package.xml Parsing C:\Users\Adit\AppData\Local\Android\Sdk\system-images\android-22\google_apis\x86_64\package.xml Parsing C:\Users\Adit\AppData\Local\Android\Sdk\tools\package.xml Using incremental javac compilation. Incremental java compilation is an incubating feature. Using incremental javac compilation. FAILURE: Build failed with an exception. * What went wrong: A problem occurred configuring project ':app'. > org.gradle.api.internal.tasks.DefaultTaskInputs$TaskInputUnionFileCollection cannot be cast to org.gradle.api.internal.file.collections.DefaultConfigurableFileCollection * Try: Run with --stacktrace option to get the stack trace. Run with --debug option to get more log output.
I then run my app from android studio, it runs well but it is not getting instrumented. Where I am making the mistake?