Appdynamics implementation

2019-07-01 11:09发布

问题:

I'm trying to add Appdynamics into my application, I'm doing those steps: https://docs.appdynamics.com/display/PRO40/Instrument+an+Android+Application#InstrumentanAndroidApplication-ToaddtheAppDynamicsAndroidagentrepositorytoyourproject but after all I have error:

Error:(15, 13) Failed to resolve: com.appdynamics:appdynamics-runtime:1.0

This is how my build.gradle (for all project) looks like:

buildscript {
  configurations.classpath.resolutionStrategy.force('com.android.tools.build:gradle:1.2.3')
  repositories {
      maven { url uri("adeum-maven-repo") }
      mavenCentral()
  }
  dependencies {
      classpath 'com.android.tools.build:gradle:1.2.3', 'com.appdynamics:appdynamics-gradle-plugin:2.0'
  }
}

  allprojects {
    repositories {
        mavenCentral()
  }
}

and build.gradle (from app module):

apply plugin: 'adeum'

repositories {
  flatDir {
      dirs 'lib'
  }
  maven {
      url uri('adeum-maven-repo')
  }
}
dependencies {
compile 'com.appdynamics:appdynamics-runtime:1.0'

and adeum-maven-repo paste into project. Any idea what am I doing wrong?

回答1:

That error means that gradle is unable to resolve the dependency on com.appdynamics:appdynamics-runtime. The easiest way to fix this problem is to use the AppDynamics libraries from maven central rather than the adeum-maven-repo directory. You can do that by editing your top level gradle file to look like this:

buildscript {
    configurations.classpath.resolutionStrategy.force('com.android.tools.build:gradle:1.2.3')
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:1.2.3'
        classpath 'com.appdynamics:appdynamics-gradle-plugin:4.+'
    }
}

allprojects {
    repositories {
        mavenCentral()
    }
}

Then your project-level gradle file would look like:

apply plugin: 'adeum'

repositories {
    flatDir {
        dirs 'lib'
    }
}

dependencies {
    compile 'com.appdynamics:appdynamics-runtime:4.+'
}

Note that I have removed the references to adeum-maven-repo, and changed the version numbers on the AppDynamics artifacts to refer to them as they exist in maven central. Once you've done this, you no longer need adeum-maven-repo in your project, since gradle is now downloading these dependencies automatically.