How to define common android properties for all modules using gradle

前端 未结 8 2048
走了就别回头了
走了就别回头了 2020-12-04 14:20

I create a simple project in AndroidStudio with a few modules. Each module\'s gradle script contains the following code:

android {
    compileSdkVersion 18
          


        
8条回答
  •  隐瞒了意图╮
    2020-12-04 14:49

    Hmm interesting that I did not find solution that works as I expet it should in Android Studio. But only this solution I present here works so there is no warning in Android Studio editor and works.

    define in root build.gradle as everybody do:

    buildscript {
        ext {
            projectAppCompatVersion = 'com.android.support:appcompat-v7:23.3.0'
            projectSupportVersion = 'com.android.support:support-v4:23.3.0'
            projectCompileSdkVersion = 23
            projectMinSdkVersion = 22      // 15 android 4.0.3 for release
            projectTargetSdkVersion = 23   //23 requires permission requests , 22 for release
            projectBuildToolsVersion = "24.0.0rc2"
        }
     }
    

    and to access without warnings:

    compileSdkVersion project.properties.projectCompileSdkVersion
    buildToolsVersion project.properties.projectBuildToolsVersion
    

    but code completion and variables resolution is not working as I would expect for android studio.

提交回复
热议问题