tools:replace="package" deadlock. Strange behaviour

3,650 views
Skip to first unread message

Mateusz Grzechociński

unread,
Jun 26, 2014, 5:13:22 PM6/26/14
to adt...@googlegroups.com
Hi,

after upgrading from gradle android plugin v0.11.1 to latex 0.12, manifest merger raises an exception:  

:app:processArmMoDebugManifest

/Users/mateuszgrzechocinski/dev/myProject/app/src/debug/AndroidManifest.xml:3:11 Error:

Attribute manifest@package value=(com.myproject) from AndroidManifest.xml:3:11

is also present at com.android.support:appcompat-v7:19.1.0:17:11 value=(android.support.v7.appcompat)

Suggestion: add 'tools:replace="package"' to <manifest> element at AndroidManifest.xml:2:1 to override


Mt project has both buildTypes and flavours folders with buildType/fllavor specific resources. In buildType folders I have custom AndroidManifest.xml files which provides some additional activities etc. 
Above error message is pretty clear. Since I can imagine appcompat library specifies it's own package attribute, there should be an error that gradle plugin accnot assume which package attributes value user want to use.

Above error message is clear, so I added:

 

diff --git a/app/src/debug/AndroidManifest.xml b/app/src/debug/AndroidManifest.xml

index 71d937a..6df3584 100644

--- a/app/src/debug/AndroidManifest.xml

+++ b/app/src/debug/AndroidManifest.xml

@@ -1,8 +1,11 @@

 <?xml version="1.0" encoding="utf-8"?>

 <manifest xmlns:android="http://schemas.android.com/apk/res/android"

-          package="com.myproject">

+          xmlns:tools="http://schemas.android.com/tools"

+          package="com.myproject"

+          tools:replace="package">

 

-    <application>

+

+<application>


Unfortunately, that raises another error, so I'm stuck

:app:processArmMoDebugManifest

/Users/mateuszgrzechocinski/dev/myProject/app/src/debug/AndroidManifest.xml:2:1 Error:

tools:replace specified at line:2 for attribute tools:package, but no new value specified

/Users/mateuszgrzechocinski/dev/myProject/app/src/debug/AndroidManifest.xml:0:0 Error:

Validation failed, exiting 

Any hints, ideas? Because of this possible bug I can't upgrade my Android Studio to beta 0.8 since it requires Gradle plugin version = 0.12.

M.

Adrian

unread,
Jun 26, 2014, 6:32:33 PM6/26/14
to adt...@googlegroups.com
I get the same problem here. I'm probably going to have to downgrade to 0.11 and studio downgrade also to 0.6.1...

Jerome Dochez

unread,
Jun 26, 2014, 8:25:23 PM6/26/14
to adt...@googlegroups.com
first, if you are stuck you can always revert to the old manifest merger

android {
useOldManifestMerger true
}

now, we should not be merging the manifest attributes coming from libraries. This is obviously a bug we need to fix on our end.

thanks, jerome


--
You received this message because you are subscribed to the Google Groups "adt-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to adt-dev+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Jerome Dochez

unread,
Jun 26, 2014, 9:00:09 PM6/26/14
to adt...@googlegroups.com
some more information, another way you can customize your debug application Id is by following these steps :

1. in your build.gradle
        debug {
            applicationIdSuffix 'debug'
        }

2. in your main manifest file, leave your package declaration but remove it from all the build-type/flavor specific AndroidManifest files.

this is not generating the issue you mentioned above.

Mateusz Grzechociński

unread,
Jun 27, 2014, 3:43:54 AM6/27/14
to adt...@googlegroups.com
W dniu piątek, 27 czerwca 2014 03:00:09 UTC+2 użytkownik Jerome Dochez napisał:
some more information, another way you can customize your debug application Id is by following these steps :

1. in your build.gradle
        debug {
            applicationIdSuffix 'debug'
        }

2. in your main manifest file, leave your package declaration but remove it from all the build-type/flavor specific AndroidManifest files.

this is not generating the issue you mentioned above.

I already modify applicationIdSuffix in my debug buildType. I followed your instructions (see below diff) but still:

:app:processArmMoDebugManifest
/Users/mateuszgrzechocinski/dev/myProject/app/src/debug/AndroidManifest.xml:2:1 Error:
  Attribute manifest@package value=(com.myproject) from AndroidManifest.xml:3:11
  is also present at com.android.support:appcompat-v7:19.1.0:17:11 value=(android.support.v7.appcompat)
  Suggestion: add 'tools:replace="package"' to <manifest> element at AndroidManifest.xml:2:1 to override
:app:processArmMoDebugManifest FAILED

Here is my full diff:

09:35:29] in ~/d/p/i/android(2.X|ae08ba5|✚3)                                                                                                                                                                                               
↪  git diff
diff --git a/app/src/debug/AndroidManifest.xml b/app/src/debug/AndroidManifest.xml
index 71d937a..249ff8d 100644
--- a/app/src/debug/AndroidManifest.xml
+++ b/app/src/debug/AndroidManifest.xml
@@ -1,8 +1,8 @@
 <?xml version="1.0" encoding="utf-8"?>
-          package="com.myproject">
+<manifest xmlns:android="http://schemas.android.com/apk/res/android">
 
-    <application>
-        <activity android:name=".devopts.DevOptionsActivity" android:screenOrientation="portrait"/>
+
+<application>
+        <activity android:name="com.myproject.devopts.DevOptionsActivity" android:screenOrientation="portrait"/>
     </application>
 </manifest>
diff --git a/build.gradle b/build.gradle
index 4fd53f3..150ffec 100644
--- a/build.gradle
+++ b/build.gradle
@@ -3,7 +3,7 @@ buildscript {
         mavenCentral()
     }
     dependencies {
-        classpath 'com.android.tools.build:gradle:0.11.+'
+        classpath 'com.android.tools.build:gradle:0.12.+'
         classpath 'org.ajoberstar:gradle-git:0.8.0'
     }
 }

Thanks in advance for fixing this issue.

M.

 

On Thu, Jun 26, 2014 at 5:25 PM, Jerome Dochez <je...@google.com> wrote:
first, if you are stuck you can always revert to the old manifest merger

android {
useOldManifestMerger true
}
now, we should not be merging the manifest attributes coming from libraries. This is obviously a bug we need to fix on our end.

Yep, I know about that, but it's not so easy just to turn it off since I'm using new merger features like ${packageName{, which BTW seems to change to ${applicationId} 

 

Jerome Dochez

unread,
Jun 27, 2014, 10:17:43 AM6/27/14
to adt...@googlegroups.com
Ok I have a fix which I am about to send for review. 

In the meantime, if I am not mistaken you have package definitions in your build-type specific Android Manifests (with the same value as in the main manifest file), correct ? if so, remove all the build-type and flavors package definitions, leave the main manifest package definition of course. 

Use the build.gradle applicationIdSuffix to specialize your package per build type. 

Thanks for your patience.
Jerome


--

Mateusz Grzechociński

unread,
Jun 27, 2014, 10:41:18 AM6/27/14
to adt...@googlegroups.com
Cool, waiting for the fix. 

You're correct, I have had packageName specified in buildType-specific AndroidManifest.xml.

Look at my diff:
diff --git a/app/src/apph/AndroidManifest.xml b/app/src/apph/AndroidManifest.xml
index eb9275a..8f043dd 100644
--- a/app/src/apph/AndroidManifest.xml
+++ b/app/src/apph/AndroidManifest.xml
@@ -1,11 +1,10 @@
 <?xml version="1.0" encoding="utf-8"?>
 <manifest xmlns:android="http://schemas.android.com/apk/res/android"
-          xmlns:tools="http://schemas.android.com/tools"
-          package="com.myproject">
+          xmlns:tools="http://schemas.android.com/tools">
 
     <application android:label="@string/app_name" tools:replace="label">
 
-        <activity android:name=".devopts.DevOptionsActivity" android:screenOrientation="portrait"/>
+        <activity android:name="com.myproject.devopts.DevOptionsActivity" android:screenOrientation="portrait"/>
 
         <activity
diff --git a/app/src/debug/AndroidManifest.xml b/app/src/debug/AndroidManifest.xml
index 71d937a..28e961f 100644
--- a/app/src/debug/AndroidManifest.xml
+++ b/app/src/debug/AndroidManifest.xml
@@ -1,8 +1,8 @@
 <?xml version="1.0" encoding="utf-8"?>
-          package="com.myproject">
+<manifest xmlns:android="http://schemas.android.com/apk/res/android">
+
 
     <application>
-        <activity android:name=".devopts.DevOptionsActivity" android:screenOrientation="portrait"/>
+        <activity android:name="com.myproject.devopts.DevOptionsActivity" android:screenOrientation="portrait"/>
     </application>
 </manifest>
diff --git a/app/src/qa/AndroidManifest.xml b/app/src/qa/AndroidManifest.xml
index 80dc3fd..35946aa 100644
--- a/app/src/qa/AndroidManifest.xml
+++ b/app/src/qa/AndroidManifest.xml
@@ -1,7 +1,6 @@
 <?xml version="1.0" encoding="utf-8"?>
 <manifest xmlns:android="http://schemas.android.com/apk/res/android"
-          xmlns:tools="http://schemas.android.com/tools"
-          package="com.myproject">
+          xmlns:tools="http://schemas.android.com/tools">
 
     <application android:label="@string/app_name" tools:replace="label">

diff --git a/build.gradle b/build.gradle
index 4fd53f3..150ffec 100644
--- a/build.gradle
+++ b/build.gradle
@@ -3,7 +3,7 @@ buildscript {
         mavenCentral()
     }
     dependencies {
-        classpath 'com.android.tools.build:gradle:0.11.+'
+        classpath 'com.android.tools.build:gradle:0.12.+'
         classpath 'org.ajoberstar:gradle-git:0.8.0'
     }
 }

Now, I have only packageName specified in my main AndroidManifest.xml file:

↪  grep -ri "package=" . --include "AndroidManifest.xml"
./src/main/AndroidManifest.xml:          package="com.myproject">

I also use applicationIdSuffix in my build.gradle:
[16:36:28] in ~/d/p/i/a/app(:ecbc29c|ecbc29c|✚4)                                                                                                                                                                                                                              
↪  grep -ri -B 4 "applicationIdSuffix" .
./build.gradle-    buildTypes {
./build.gradle-        debug {
./build.gradle-            debuggable true
./build.gradle-            buildConfigField "boolean", "USE_JAVA_LOGS", "true"
./build.gradle:            applicationIdSuffix ".debug"
--
./build.gradle-        }
./build.gradle-        apph {
./build.gradle-            debuggable true
./build.gradle-            buildConfigField "boolean", "USE_JAVA_LOGS", "true"
./build.gradle:            applicationIdSuffix ".apph"

In spite of that, error still occurs:
:app:processArmMoDebugManifest
/Users/mateuszgrzechocinski/dev/myProject/app/src/debug/AndroidManifest.xml:2:1 Error:
Attribute manifest@package value=(com.myproject) from AndroidManifest.xml:3:11
is also present at com.android.support:appcompat-v7:19.1.0:17:11 value=(android.support.v7.appcompat)
Suggestion: add 'tools:replace="package"' to <manifest> element at AndroidManifest.xml:2:1 to override
:app:processArmMoDebugManifest FAILED

Seems like we're doing sth differently, or my setup is somehow different than yours.
M.

Jerome Dochez

unread,
Jun 27, 2014, 10:55:22 AM6/27/14
to adt...@googlegroups.com
Yep, do you have any flavors with some package declaration by any chance ? If so remove those too

Jerome Dochez

unread,
Jun 27, 2014, 11:05:02 AM6/27/14
to adt...@googlegroups.com

OK I got the same setting. Only the fix will do at this point unfortunately.

Jerome

To unsubscribe from this group and stop receiving emails from it, send an email to adt-dev+unsubscribe@googlegroups.com.

Mateusz Grzechociński

unread,
Jun 27, 2014, 11:05:23 AM6/27/14
to adt...@googlegroups.com

I do have flavors, even in 2 dimensions, but none of them introduce their own AndroidManifest.xml files.

Here is the list of all my AndroidManifest.xml files with head of first few lines. As you can see, only one, main AndroidManifest.xml has package specified.

bash-3.2$  find . -name "*AndroidManifest.xml" -exec head -n 3 {} +
==> ./src/apph/AndroidManifest.xml <==

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
          xmlns:tools="http://schemas.android.com/tools">

==> ./src/debug/AndroidManifest.xml <==

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">


==> ./src/main/AndroidManifest.xml <==

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
          package="com.myproject">

==> ./src/qa/AndroidManifest.xml <==

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
          xmlns:tools="http://schemas.android.com/tools">

M.
You received this message because you are subscribed to a topic in the Google Groups "adt-dev" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/adt-dev/2g7s42cp39c/unsubscribe.
To unsubscribe from this group and all its topics, send an email to adt-dev+u...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.


--
Mateusz Grzechociński
http://grzechocinski.net

Mateusz Grzechociński

unread,
Jun 30, 2014, 5:52:39 AM6/30/14
to adt...@googlegroups.com
Hi Jerome, 

when to you plan to submit a fix for that (i guess in v0.12.1) ? I'd like to upgrade to AS 0.8, but it requires gradle plugin 0.12, buggy in my case.

M.

Mitch Miller

unread,
Jun 30, 2014, 10:31:13 AM6/30/14
to adt...@googlegroups.com
I'm also interested in this. Any place we can watch for updates?

Jake Wharton

unread,
Jun 30, 2014, 11:55:57 AM6/30/14
to adt...@googlegroups.com
The fix is already on AOSP master. If you are truly blocked you can follow the instructions to clone and build the plugin yourself.


--

Xavier Ducrohet

unread,
Jun 30, 2014, 9:07:48 PM6/30/14
to adt...@googlegroups.com
I'll push 0.12.1 tomorrow.
--
Xavier Ducrohet
Android SDK Tech Lead
Google Inc.
http://developer.android.com | http://tools.android.com

Please do not send me questions directly. Thanks!

Ashok Raju

unread,
Jun 30, 2014, 9:30:42 PM6/30/14
to adt...@googlegroups.com
I really don't want to have to build the plugin myself.  Is this update out yet?  I updated to Android Studio 0.8.1 but that didn't fix it.  Is there something else I need to update?

Jake Wharton

unread,
Jun 30, 2014, 9:35:22 PM6/30/14
to adt...@googlegroups.com
The plugin. Tomorrow.


​​

Ashok Raju

unread,
Jun 30, 2014, 9:45:50 PM6/30/14
to adt...@googlegroups.com
My mistake. Didn't know what he was talking about when he said 0.12.1.  I just switched to Android Studio today, so still trying to understand the lingo.  I just connected all the dots. The plugin, as in the gradle plugin, will be updated to 0.12.1 tomorrow.

Thanks!

Mateusz Grzechociński

unread,
Jul 2, 2014, 5:11:59 AM7/2/14
to adt...@googlegroups.com
Hereby, I confirm that 0.12.1 fixes the issue. Thanks a lot!

M.

Jerome Dochez

unread,
Jul 2, 2014, 7:02:31 AM7/2/14
to adt...@googlegroups.com
cool ! thanks for the report and patience !

jerome

Mitch Miller

unread,
Jul 2, 2014, 8:12:01 AM7/2/14
to adt...@googlegroups.com
It does indeed work! Thanks alot guys.
Reply all
Reply to author
Forward
0 new messages