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

Based on this info:

ApplicationId in Library Projects

You cannot use applicationId to customize the package of a library project. The package name has to be fixed in library projects (and specified as packageName in the manifest). The Gradle plugin did not enforce this restriction earlier.

Removing applicationId variable from the library’s build.gradle file should resolve the issue.

Thanks to Joel for his correct answer: I need to remove only 1 line from te .gradle file:

defaultConfig {
        applicationId "com.super.app"   <---- remove this line
        minSdkVersion 15
        targetSdkVersion 19
        versionCode 1
        versionName "1.0"
    }

becomes

defaultConfig {
        minSdkVersion 15
        targetSdkVersion 19
        versionCode 1
        versionName "1.0"
    }

and my AndroidManifest.xml

 <manifest xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools"
        package="com.super.app">
...

This is the right solution if you don’t need to rename the package name of your app. To rename it you need to use “flavours”:

android {
   ...
   productFlavors {
       flavor1 {
           applicationId 'com.super.superapp'
       }
   }

Leave a Comment