20 Dec 2018
	
		
		12:18 AM
	
	
	
	
	
	
	
	
	
	
	
	
	
	
 - last edited on 
    
	
		
		
		10 Dec 2021
	
		
		08:44 AM
	
	
	
	
	
	
	
	
	
	
	
	
	
	
 by 
				
		 MaciejNeumann
		
			MaciejNeumann
		
		
		
		
		
		
		
		
	
			
		
In a react project we are implementing dynatrace, But getting issue in the build.graddle file when running. Below is the build.graddle file.
<code> buildscript {
    ext {
        googlePlayServicesVersion ="16.0.1"}
    repositories {
        jcenter()
        maven {
            url 'https://maven.google.com/'
            name 'Google'}}
    dependencies {
        classpath 'com.android.tools.build:gradle:3.2.1'
        classpath 'com.google.gms:google-services:4.1.0'        
        classpath 'com.dynatrace.tools 7.2.+'// NOTE: Do not place your application dependencies here; they belong// in the individual module build.gradle files}}
7.2.+'// NOTE: Do not place your application dependencies here; they belong// in the individual module build.gradle files}} 
apply plugin:'com.dynatrace.tools.android' 
dynatrace {     
    defaultConfig {         
        applicationId 'App Id'
        environmentId 'EnvId'        
        cluster 'https://bf.dynatrace.com'}}
allprojects {
    repositories {
        mavenLocal()
        google()
        jcenter {
            url "http://jcenter.bintray.com/"}
        maven {// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
            url "$rootDir/../node_modules/react-native/android"}
        maven {
            url 'https://maven.google.com/'
            name 'Google'}
        maven { url "https://jitpack.io"}}} 
 subprojects { 
     afterEvaluate { 
         project ->if(project.hasProperty("android")){ 
             android { 
                compileSdkVersion 28 
                buildToolsVersion '28.0.3'}}}} ext {
    buildToolsVersion ="28.0.3"
    minSdkVersion =16
    compileSdkVersion =28
    targetSdkVersion =28
    supportLibVersion ="28.0.0"}
Below is the error getting:
Scanning folders for symlinks in/Users/Dev/Desktop/app/node_modules (30ms)
JS server already running.Buildingand installing the app on the device (cd android &&./gradlew installDebug)...
FAILURE:Build failed with an exception.*Where:Build file '/Users/Dev/Desktop/appname/android/build.gradle' line:23*What went wrong:
A problem occurred evaluating root project 'ProjectName'.>Failed to apply plugin [id 'com.dynatrace.tools.android']>Extension of type 'AppExtension' does not exist.Currently registered extension types:[ExtraPropertiesExtension,DynatraceConfig_Decorated]*Try:Runwith--stacktrace option to get the stack trace.Runwith--info or--debug option to get more logoutput.Runwith--scan to get full insights.*Get more help at https://help.gradle.org
Solved! Go to Solution.
20 Dec 2018 06:45 AM
Did you include the Android Gradle Plugin? Because that is needed for our plugin to work. Be aware that we are not supporting React native officially. If this doesn't work out instrument the .apk manually over the instrument.cmd.
20 Dec 2018 08:48 AM
Hi @Gourav S.,
I assume that you have added the Dynatrace configuration in the project's build.gradle file instead of the module's build.gradle file. The Dynatrace Gradle plugin must be applied after the Android Gradle plugin.
// first apply the application module from the Android Gradle plugin
apply plugin: 'com.android.application'
...
// somewhere below, apply the Dynatrace Gradle plugin
apply plugin:'com.dynatrace.tools.android'
dynatrace {
defaultConfig {
applicationId 'App Id'
environmentId 'EnvId'
cluster 'https://bf.dynatrace.com'
}
}
