Please help me with a problem
When I try to install the application after building it on Android 12 emulator, AndroidStudio throws errors for some services:
Failure [INSTALL_PARSE_FAILED_MANIFEST_MALFORMED: Failed pars e during installPackageLI: /data/app/vmdl1492588574.tmp/base.apk (at Binary XML file line #105): com.adobe.phonegap.push.FCMService: Targeting S+ (version 31 and above) requires that a n explicit value for android:exported be defined when intent filters are present]
To avoid this error I add android:exported="false" Like this
<service android:exported="false" android:name="com.adobe.phonegap.push.FCMService">
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT" />
</intent-filter>
</service>
But because of this, an error appears already at the time of building the apk and the service is duplicated in the AndroidManifest below:
Element service#com.adobe.phonegap.push.FCMService at AndroidManifest.xml:29:9-33:19 duplicated with element declared at AndroidManifest.xml:19:9-23:19
It looks like the plugin you are using is not compatible with Android SDK 31.
Either change the build target to SDK 30, or ask the maintainer to update the plugin.
<preference name="android-targetSdkVersion" value="30" />
Everytime you change some code you have to check your manifest and remove duplicate lines from it. It happens when you add the exported value='true/false'.
Related
We have an app developed using IONIC CORDOVA. When I am trying to upload app on the play store then it gives an error
"Apps targeting Android 12 and higher are required to specify an explicit value for android:exported"
I am using cordova-android: 8.0.0
If I am using cordova-android:10.1.0 then I am unable to build app.
I was having the same issues. Im not sure what causes the issues I think it is an cordova one. But you can resolve it by going to the platforms/android/app/manifests/androidManifest.xml there is a section <activity. Add android:exported="true".
It should look like this <activity android:exported="true" ....(other variables)
Add android:exported="true", in your AndroidManifest.xml
eg:
<activity
android:name=".MainActivity"
android:exported="true">
</activity>
You should update to cordova-android 11. This release features support for Android 12 and the latest play store requirements.
https://cordova.apache.org/announcements/2022/07/12/cordova-android-release-11.0.0.html
I have solved this by adding android:exported: true to manifest.xml
<intent-filter android:exported="true" android:label="#string/launcher_name">
Please note that this error is related to launcher activity intent only
I am getting this error when I am upgrading my react-native version from 0.66.2 to 0.68.2.
Error
Manifest merger failed : android:exported needs to be explicitly specified for . Apps targeting Android 12 and higher are required to specify an explicit value for android:exported when the corresponding component has an intent filter defined. See https://developer.android.com/guide/topics/manifest/activity-element#exported for details.
In the latest version of Android, we need to explicitly define the value for android:exported for all the service and activity in AndroidManifest.xml file.
For example:
<service android:exported="false" android:name="serviceName" />
If you setting android:exported but it doesn't work, when you open AndroidManifest.xml in Android Studio, you will see a tab called Merged Manifest. If you click the tab, the error contents are displayed.
error message for example
Merging Errors: Error: android:exported needs to be explicitly specified for element <receiver#androidx.media.session.MediaButtonReceiver>. Apps targeting Android 12 and higher are required to specify an explicit value for `android:exported` when the corresponding component has an intent filter defined. See https://developer.android.com/guide/topics/manifest/activity-element#exported for details.
In my case, it was difficult because this error was displayed, but when I additionally inserted the code below in the AndroidManifest.xml file, the error disappeared.
...
<receiver android:name="androidx.media.session.MediaButtonReceiver" android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MEDIA_BUTTON" />
</intent-filter>
</receiver>
...
https://developer.android.com/reference/androidx/media/session/MediaButtonReceiver
Hope this helps you!
This question already has answers here:
android:exported needs to be explicitly specified for <activity>. Apps targeting Android 12 and higher are required to specify
(35 answers)
Closed 7 months ago.
Using Android Studio 4.2.1, after changing sdk target to Android 12 in my build.gradle file, I am getting a Manifest merger failed with multiple errors, see logs error.
The errors shown in the Merged Manifest tab are as follows:
Merging Errors:
Error: Apps targeting Android 12 and higher are required to specify an explicit value for `android:exported` when the corresponding component has an intent filter defined. See https://developer.android.com/guide/topics/manifest/activity-element#exported for details. My_App.app main manifest (this file)
Error: Apps targeting Android 12 and higher are required to specify an explicit value for `android:exported` when the corresponding component has an intent filter defined. See https://developer.android.com/guide/topics/manifest/activity-element#exported for details. My_App.app main manifest (this file)
Error: Apps targeting Android 12 and higher are required to specify an explicit value for `android:exported` when the corresponding component has an intent filter defined. See https://developer.android.com/guide/topics/manifest/activity-element#exported for details. My_App.app main manifest (this file)
However the android:exported tag is already applied in my AndroidManifest.xml file. I only have one activity. No services or broadcast receivers. See below:
<?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.mydomain.myapp">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.VIBRATE" />
<application
android:name="com.mydomain.myapp.MyApplication"
android:allowBackup="false"
tools:replace="allowBackup"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:roundIcon="#mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity
android:name="com.mydomain.myapp.ui.MainActivity"
android:exported="true">
<intent-filter >
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<meta-data
android:name="preloaded_fonts"
android:resource="#array/preloaded_fonts" />
</application>
</manifest>
My build.gradle(:app) file:
android {
compileSdkVersion("android-S")
buildToolsVersion "30.0.3"
defaultConfig {
...
minSdkVersion 23
targetSdkVersion("S")
...
}
Any idea how I could resolve this issue?
The issue was caused by 3 activities missing the android:exported attribute in the androidx.test:core library version 1.3.0. Upgrading to version 1.4.0-beta01 fixed the issue.
If you are getting errors after targeting Android 12, the easiest way to debug this is to:
downgrade to a prior sdk version
rebuild project
after a successful build, open your project's AndroidManifest.xml.
at the bottom of the window, click on the Merged Manifest tab
look for any <activity> that includes an <intent-filter> tag and is missing the android:exported attribute
If you want to make sure these activities are the issue, add them directly to your project's AndroidManifest.xml file with the missing android:exported attribute added and try rebuilding the project.
So if <activity android:name="com.domain.ProblemActivity"> is missing the android:exported attribute, add it to your AndroidManifest.xml file like so:
<activity
android:name="com.domain.ProblemActivity"
android:exported="true" >
Rebuild targeting Android 12 and if it works, then you found the bug!
Thanks #MikePenz for pointing me in the right direction.
If your app targets Android 12 or higher and contains activities, services, or broadcast receivers that use intent filters, you must explicitly declare the android:exported attribute for these app components. In order to solve this we need to follow these steps:
We need to locate the AndroidManifest.xml in the main folder.
android>app>src>main>AndroidManifest.xml
We have to add android:exported="" and set a boolean value inside these quotation marks. Now you might ask when do I need to add android:exported="true" or android:exported="false" to the activities, services, or broadcast receivers that use intent filters.
If the app component includes the LAUNCHER category, set android:exported to true. In most other cases, set android:exported to false.
This is an example of how it should look like in your AndroidManifest.xml
<service android:name="com.example.app.backgroundService"
android:exported="false">
<intent-filter>
<action android:name="com.example.app.START_BACKGROUND" />
</intent-filter>
</service>
You can check out more info about this topic by following this link:
Safer component exporting for Android 12
If you upgrade your android studio to Bumblebee 2021.1.1.
The below changes are required to do:
Step 1: Your targetSdkVersion must be 30 or higher
Step 2: Update your appcompat library to implementation 'androidx.appcompat:appcompat:1.4.1'
Step 3: In the AndroidManifest file add android:exported = true to your activity launcher.
I had this issue, find it by:
if there's any activity, service, receiver, or provider that does not have exported attribute in your AndroidManifest file then add the below attribute in that activity, service, receiver, or provider
android:exported="false or true"
I had my Activity setup correctly with 'exported=true' and still had the following issue:
Installation failed due to [...] androidx.test.core.app.InstrumentationActivityInvoker$BootstrapActivity: Targeting S+ (version 31 and above) requires that an explicit value for android:exported be defined when intent filters are present
So I came across this Github post, which could explain why this happens, and applied the workaround yogurtearl suggests and it worked for me.
https://github.com/android/android-test/issues/832
It basically goes like this:
As a workaround, putting this in the app/src/debug/AndroidManifest.xml it will force the these to launch in the same test process.
<activity
android:name="androidx.test.core.app.InstrumentationActivityInvoker$BootstrapActivity"
android:exported="true"
android:theme="#android:style/Theme" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
</intent-filter>
</activity>
<activity
android:name="androidx.test.core.app.InstrumentationActivityInvoker$EmptyActivity"
android:exported="true"
android:theme="#android:style/Theme" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
</intent-filter>
</activity>
<activity
android:name="androidx.test.core.app.InstrumentationActivityInvoker$EmptyFloatingActivity"
android:exported="true"
android:theme="#android:style/Theme.Dialog" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
</intent-filter>
</activity>
And added the 'exported=true' to them.
Don't forget to put it also into service tag
<service
android:name=".service.MyIME"
android:exported="true"
android:permission="android.permission.BIND_INPUT_METHOD">
<meta-data
android:name="android.view.im"
android:resource="#xml/method" />
<intent-filter>
<action android:name="android.view.InputMethod" />
</intent-filter>
</service>
Cleaning and rebuilding the project worked for me
If you're using DexGuard you should update to the latest version which is 9.2.11 (19-01-2022) at the moment.
Quote from the release notes:
Add default configuration for keeping the exported attribute as required by applications targeting Android 12.
As specified in the following link-
https://developer.android.com/about/versions/12/behavior-changes-12#exported ,the components of android that use intent filters must explicitly define component exporting, failing to which your app can't be installed on a device that runs on Android 12 or higher. The app components include activities, services, broadcast receivers and content providers.
If the app component includes the LAUNCHER category, set android:exported to true. In most other cases, set android:exported to false.
Even after setting the android:exported tag, if you are facing the Manifest Merger failed issue, then check all the libraries that you are using in your app. Open the external libraries in the project view of the Android Studio and try to check all the manifests files of the libraries that you have included in your project. Any one of those libraries might have not updated according to Android 12. So if you find any manifest file of the library with exported tag missing, try to edit the file and add this tag there too. Hope that could help in removing Manifest Merger Error.
NOTICE: Please do not post this "android.enableAapt2=false" as an answer. It is not a solution. It is just ignoring the real error which is not causing any problem on runtime.
Solution was simple, just removed mistakenly placed action tag outside of an intent filter in the manifest file.
Have an application which was building by Android Studio 2.3 fine.
After updating Android Studio 3.0 Stable, started to having this error and unable to build my project.
Here my manifest.xml
<application
android:name=".ApplicationClass"
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:largeHeap="true"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<!--other unrelated stuff-->
<action android:name="com.google.android.c2dm.intent.REGISTRATION" />
<receiver
android:name="com.google.android.gms.gcm.GcmReceiver"
android:exported="true"
android:permission="com.google.android.c2dm.permission.SEND">
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
<category android:name="com.xxx.xxx" />
</intent-filter>
</receiver>
</application>
Error shows this line:
<action android:name="com.google.android.c2dm.intent.REGISTRATION" />
If I comment/remove this action tag line, the project builds fine but it is necessary for GCM and I cannot remove it.
As you see the logs, The error not occurs at main manifest file, occurs at /build/intermediates/manifests/full/debug/AndroidManifest.xml
Tried cleaning, rebuilding, disabling instant run. Is there any solution?
The Error Logs:
/THE_PROJECT_PATH/app/build/intermediates/manifests/full/debug/AndroidManifest.xml
Error:(99) error: unknown element <action> found.
Error:(99) unknown element <action> found.
Error:java.util.concurrent.ExecutionException: java.util.concurrent.ExecutionException: com.android.tools.aapt2.Aapt2Exception: AAPT2 error: check logs for details
Error:java.util.concurrent.ExecutionException: com.android.tools.aapt2.Aapt2Exception: AAPT2 error: check logs for details
Error:com.android.tools.aapt2.Aapt2Exception: AAPT2 error: check logs for details
Error:Execution failed for task ':app:processDebugResources'.
> Failed to execute aapt
Information:BUILD FAILED in 1s
Information:6 errors
Information:0 warnings
Information:See complete output in console
You have a misplaced tag. The new AAPT (AAPT2) now throws an error on this.
From the docs in here: https://developer.android.com/studio/build/gradle-plugin-3-0-0-migration.html
Behavior changes when using AAPT2
To improve incremental resource processing, Android plugin 3.0.0 enables AAPT2 by default. Although AAPT2 should immediately work with older projects, this section describes some behavior changes that you should be aware of.
Element hierarchies in the Android manifest
In previous versions of AAPT, elements nested in incorrect nodes in the Android manifest are either ignored or result in a warning. For example, consider the following sample:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.myname.myapplication">
<application
...
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<action android:name="android.intent.action.CUSTOM" />
</activity>
</application>
</manifest>
Previous versions of AAPT would simply ignore the misplaced tag. However, with AAPT2, you get the following error:
AndroidManifest.xml:15: error: unknown element <action> found.
To resolve the issue, make sure your manifest elements are nested correctly. For more information, read Manifest file structure.
add this code in gradle.properties in the root project:
android.enableAapt2=false
this worked for me
root
|
|--gradle.properties
Put action content in intent-filter like below as per Manifest file structure.
<intent-filter>
<action android:name="com.google.android.c2dm.intent.REGISTRATION" />
</intent-filter>
In order to summarize and simplify: you should just concentrate on your main AndroidManifest.xml file and check whether it strictly follows the sequence as well as nesting of XML tags as described in https://developer.android.com/guide/topics/manifest/manifest-intro.html. Otherwise the IDE will open up the debug-level AndroidManifest.xml showing a lot of error every time you try to clean/build the project and make you confused!
Just rename your manifest file like this: AndroidManifest.xmlold, then create a new XML file and give name: AndoridManifest.xml. Then just copy the content of the old file after you remove line with tag . Build>Clean Project and then Run>debug app again. Then the problem will be disappeared.
We have the solution of this problem and solution is that service always comes under child form of <Application <service>>
when we write the code outside of <Application> then issue occur. Services are the child part of Application in Manifest...
okay... It will sure work..do it
In my app in AndroidManifest.xml tag receiver was under the application tag and this was cause of build fail with message .../android/app/build/intermediates/manifests/full/debug/AndroidManifest.xml:25: AAPT: error: unknown element <receiver> found. After i have put it in application tag then the project has been compiled successfully. That's all
I recently had this fix on my gradle.properties but a warning saying that "The option 'android.enableAapt2' is deprecated..." kept on coming and the solution was to change it to true instead.
So I was doing some refactoring of package names in my project and now i'm no longer able to install my app. Right around the same time that I updated to the most current version of android studio. I believe that may be the problem because I think i did the refactoring before the upgrade, I just don't remember 100%
Here is my manifest
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.dodgingfire" >
<application
android:allowBackup="true"
android:icon="#mipmap/dodging_fire_icon"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name=".gamemain.GameMainActivity"
android:label="#string/app_name"
android:screenOrientation="sensorLandscape">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
This is how I have my packages organized
http://prntscr.com/gcrw99
This is the full error message when I try to run my app
Installation failed with message Failed to finalize session : INSTALL_PARSE_FAILED_BAD_PACKAGE_NAME: Invalid manifest package: must have at least one '.' separator.
It is possible that this issue is resolved by uninstalling an existing version of the apk if it is present, and then re-installing.
WARNING: Uninstalling will remove the application data!
Do you want to uninstall the existing application?
Even when I accept to delete the existing application, It still gives me an error and doesn't install my app let alone run it.
The package name in your source manifest file is not actually the one that ends up in the APK being installed. During manifest merging process, the final package name is based on the applicationId value in your app's build.gradle file.
As the error message says, you need at least one . in the package name.
Other reasons for INSTALL_PARSE_FAILED_BAD_PACKAGE_NAME can be found in PackageParser#validateName() source.