Bug in Gradle build ( overwrite with 2.1.0)

I was trying to use https://github.com/charmdev/extension-facebook where for build.gradle they use “api” and “implementation” which is not supported in gradle 2.1.0 , so I update ot latest plugin using this in project.xml

<android gradle-version="5.6.3" />
<android gradle-plugin="3.5.1" />

This should works , but two files \bin\android\bin\deps\extesnion-api\build.gradle ( which is ) and \bin\android\bin\build.grade still overwrite with classpath 'com.android.tools.build:gradle:2.1.0' , but correct one is classpath 'com.android.tools.build:gradle:3.5.1' .
I manually add for respository maven.google.com

How to stop to overwrite those files with wrong gradle version ?

P.S. Just as info to works with latest gradle should do this also:

  1. Change wrapper text in lime\7.6.3\templates\android\template\build.gradle with
wrapper {
  gradleVersion = '::ANDROID_GRADLE_VERSION::'
}
  1. Change android.applicationVariants.all in \lime\7.6.3\templates\android\template\app\build.grade with:
	android.applicationVariants.all { variant ->
		variant.outputs.all { output ->
			def outputFile = output.outputFile
			if (outputFile != null && outputFile.name.endsWith('.apk')) {
				outputFileName = new File( "../", "::APP_FILE::-${variant.buildType.name}.apk")
			}
		}
	}
  1. Add in repositories { ... }
 maven {
  url 'https://maven.google.com/'
 }

for the following build.gradle tasks
(–) \templates\android\template
(–) \templates\android\template\app
(–) \dependencies\extension-api\

Just to add something. I search and replace all strings “2.1.0” , also remove anroid folder and compile with openfl test android , but the problem still exist .

The file \bin\android\bin\build.gradle contains classpath 'com.android.tools.build:gradle:2.1.0' .

If this is some kind of cache, I’m not sure how to remove it.

Test with : openfl - 8.9.5 and Lime 7.6.3

Could you share what your complete template file looks like now? Thanks

I found 2.1.0 only in AndroidPlatform.hx , so there I replace with : context.ANDROID_GRADLE_PLUGIN = project.config.getString("android.gradle-plugin", "3.5.1"); , but doesn’t help.
Compiled templates in \bin’android\ folder are :

1) \bin\android\bin\deps\extesnion-api\build.gradle

buildscript {
	repositories {
		jcenter {
			url "http://jcenter.bintray.com/"
		}
	}
	
	dependencies {
		classpath 'com.android.tools.build:gradle:2.1.0'
	}
}

apply plugin: 'com.android.library'

android {
	compileSdkVersion Integer.parseInt(project.ANDROID_BUILD_SDK_VERSION)
	buildToolsVersion project.ANDROID_BUILD_TOOLS_VERSION
}

2) \bin\android\bin\build.grade

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
	repositories {
		jcenter {
			url "http://jcenter.bintray.com/"
		}
	}
	dependencies {
		classpath 'com.android.tools.build:gradle:2.1.0'
		
		// NOTE: Do not place your application dependencies here; they belong
		// in the individual module build.gradle files
	}
}

allprojects {
	repositories {
		jcenter {
			url "http://jcenter.bintray.com/"
		}
		maven {
			url "https://maven.google.com"
		}
	}
}

task clean(type: Delete) {
	delete rootProject.buildDir
}

wrapper {
	gradleVersion = '5.6.3'
}

configure(subprojects.findAll {!it.file('build.gradle').exists() && it.file('build.xml').exists()}) {
	buildscript {
		repositories {
			maven {
				url "http://repo1.maven.org/maven2/"
			}
		}
		
		dependencies {
			classpath 'com.android.tools.build:gradle:2.1.0'
		}
	}
	
	apply plugin: 'android-library'
	
	android {
		compileSdkVersion Integer.parseInt(project.ANDROID_BUILD_SDK_VERSION)
		buildToolsVersion project.ANDROID_BUILD_TOOLS_VERSION
		
		sourceSets {
			main {
				manifest.srcFile 'AndroidManifest.xml'
				java.srcDirs = ['src']
				res.srcDirs = ['res']
			}
		}
	}
	
	dependencies {
		compile fileTree(dir: 'libs', include: ['*.jar'])
		compile project(':deps:extension-api')
	}
}

For both classpath should be classpath 'com.android.tools.build:gradle:3.5.1' not classpath 'com.android.tools.build:gradle:2.1.0' , because I set <android gradle-plugin="3.5.1" />

I removed maven.google.com and all templates in Lime are same as the github version at the moment . Only set gradle versions in project.xml

I just added on PiratePig project in project.xml

	<android gradle-version="5.6.3" />
	<android gradle-plugin="3.5.1" /> 

It’s the same i.e. \PiratePig\Export\android\bin\build.gradle have classpath 'com.android.tools.build:gradle:2.1.0'

Here is the full build.gradle file

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
	repositories {
		jcenter {
			url "http://jcenter.bintray.com/"
		}
	}
	dependencies {
		classpath 'com.android.tools.build:gradle:2.1.0'
		
		// NOTE: Do not place your application dependencies here; they belong
		// in the individual module build.gradle files
	}
}

allprojects {
	repositories {
		jcenter {
			url "http://jcenter.bintray.com/"
		}
		maven {
			url "https://maven.google.com"
		}
	}
}

task clean(type: Delete) {
	delete rootProject.buildDir
}

wrapper {
	gradleVersion = '5.6.3'
}

configure(subprojects.findAll {!it.file('build.gradle').exists() && it.file('build.xml').exists()}) {
	buildscript {
		repositories {
			maven {
				url "http://repo1.maven.org/maven2/"
			}
		}
		
		dependencies {
			classpath 'com.android.tools.build:gradle:2.1.0'
		}
	}
	
	apply plugin: 'android-library'
	
	android {
		compileSdkVersion Integer.parseInt(project.ANDROID_BUILD_SDK_VERSION)
		buildToolsVersion project.ANDROID_BUILD_TOOLS_VERSION
		
		sourceSets {
			main {
				manifest.srcFile 'AndroidManifest.xml'
				java.srcDirs = ['src']
				res.srcDirs = ['res']
			}
		}
	}
	
	dependencies {
		compile fileTree(dir: 'libs', include: ['*.jar'])
		compile project(':deps:extension-api')
	}
}

The problem is with ::ANDROID_GRADLE_PLUGIN:: . You can change it at all and always is 2.1.0

So the correct way to set is :

<config:android gradle-version="5.6.3" />
<config:android gradle-plugin="3.5.1" />

but as I mention earlier , wrapper and applicationVariants also should be changed.
Also I still not sure from where is set 2.1.0 , because I change AndroidPlatforms.hx

I can make a commit to lime repository with wrapper and applicationVariants to support gradle > 4.4 if you want.
The only problem could be this value 2.1.0 if is set from some class.

Thank you that would be appreciated :slight_smile: