Cannot get property 'compileSdkVersion' on extra properties extension as it does not exist Open File Cannot get property 'compileSdkVersion' on extra properties extension as it does not exist Open File android android

Cannot get property 'compileSdkVersion' on extra properties extension as it does not exist Open File


In your top-level file use:

ext {    compileSdkVersion = 26}

In your module/build.gradle file use:

android {  compileSdkVersion rootProject.ext.compileSdkVersion  ...}


Another way:

Your build.gradle in top-level module

ext {    minSdk = 21    targetSdk = 29    compileSdk = 29    buildTools = '29.0.3'}

Your build.gradle in app module

android {    def buildConfig = rootProject.extensions.getByName("ext")    compileSdkVersion buildConfig.compileSdk    buildToolsVersion buildConfig.buildTools    defaultConfig {        minSdkVersion buildConfig.minSdk        targetSdkVersion buildConfig.targetSdk    }    // ...}


In build.gradle you need to write compilesdkversion under android tag as in this example:

android {.. compileSdkVersion 26 // 26 is an example..}

By the way. You can build that module as library then import it into your project as .aar file.