samedi 24 septembre 2016

How to instrument my android app in appdynamics?

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://ift.tt/1dvuuBa

# 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.

I then run my app from android studio, it runs well but it is not getting instrumented. Where I am making the mistake?

Aucun commentaire:

Enregistrer un commentaire