constants.gradle
project.ext {
minSdkVersion = 19
compileSdkVersion = 28
targetSdkVersion = 28
buildToolsVersion = '28.0.3'
supportLibraryVersion = '28.0.0'
}
build.gradle of the app
apply plugin: 'com.android.application'
apply from: '../constants.gradle'
android {
compileSdkVersion project.ext.compileSdkVersion
buildToolsVersion project.ext.buildToolsVersion
defaultConfig {
...

What is wrong here?
Though it works fine for libraries in the same project:

Also everything is fine for the next lines in defaultConfig block
minSdkVersion project.ext.minSdkVersion
targetSdkVersion project.ext.targetSdkVersion

Android Studio 3.2, classpath 'com.android.tools.build:gradle:3.2.0', distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip
Seems it didn't show such warnings with the previous Gradle or Studio
It's just a warning and It should work.
Because when you use project inside android scope, Gradle tries to find the invocation location of project.

You have two options to fix this warning.
Get your constants outside of android scope.
def compileSdkVersion = project.ext.compileSdkVersion
def buildToolsVersion = project.ext.buildToolsVersion
android {
compileSdkVersion compileSdkVersion
buildToolsVersion buildToolsVersion
...
Or update your constants.gradle:
ext {
buildVersions = [
minSdkVersion : 19,
compileSdkVersion : 28,
targetSdkVersion : 28,
buildToolsVersion : '28.0.3',
supportLibraryVersion : '28.0.0',
]
}
and use it in your build.gradle like:
apply plugin: 'com.android.application'
apply from: '../constants.gradle'
android {
compileSdkVersion buildVersions.compileSdkVersion
buildToolsVersion buildVersions.buildToolsVersion
...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With