I want to configure AndroidManifest in different build types. For example, in debug mode, I just want the operation to be exported.
Assume the main manifest:
/main/AndroidManifest.xml <application> <activity android:name="com.example.MainActivity" /> </application>
Debugging:
/debug/AndroidManifest.xml <application> <activity android:name="com.example.MainActivity" android:exported="true" /> </application>
Example manifest (same as debugging):
/example/AndroidManifest.xml <application> <activity android:name="com.example.MainActivity" android:exported="true" /> </application>
In the debug manifest, I get Duplicate registration for activity com.example.MainActivity
This is why I created an example of an assembly type.
/build.gradle android { buildTypes { example.initWith(buildTypes.debug) } }
But it also does not work.
[AndroidManifest.xml:17, AndroidManifest.xml:4] Trying to merge incompatible /manifest/application/activity[@name=com.example.MainActivity] element: <activity -- @android:name="com.example.MainActivity"> --</activity> --(end reached) <activity ++ @android:exported="true" ++ @android:name="com.example.MainActivity"> ++</activity>
I am wondering if this will be a bug, a missing function (will be implemented in the future), or am I doing something wrong?
I know I can provide a different manifest in release and debugging (without it in /main ), but I don't think this is a good solution.
EDIT: The solution so far is to define a bool in resources and use it inside the main manifest. In debug resources, bool will be true , and in release false . This solution seems much better than duplicate manifests, but the question is still relevant.