Android Studio 1.0 and error “Library projects cannot set applicationId”

后端 未结 4 858
北恋
北恋 2020-12-07 19:46

After updating Android Studio to 1.0, I see this error:

Error: Library projects cannot set applicationId. applicationId is set to \'com

4条回答
  •  旧巷少年郎
    2020-12-07 20:23

    You cannot define applicationId for your lib. But incase you want to use an identifier in your build file, which will give you, your library package name, you can define a variable for the module and then use the value as required.

    eg : Library's build.gradle

    apply plugin: 'com.android.library'
    
    def libraryGroupId = 'com.google.example'
    def libraryArtifactId = project.getName()
    def libraryVersion = '1.1'
    

    Also, you can use the value below as needed in your build file itself in lib.

    android {
    compileSdkVersion 28
    
    defaultConfig {
        minSdkVersion 21
        targetSdkVersion 28
        versionCode 1
        versionName "$libraryVersion"
        resValue "string", "Library", libraryGroupId"
     }
    }
    

提交回复
热议问题