Manifest merger failed after adding Gurux in dependence - android

I'm trying to add Gurux to my android project by adding implementation 'org.gurux:gurux.serial.android:1.0.1' to my build.gradle-file, but I got an error saying "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."

Looking at the source manifest there are two activity components that do not have explicit android:exported value that is required when targeting Android 12 or above.
You can override the manifest entries in your own application-level manifest and provide the missing attributes, e.g.
<application>
<activity
android:name="USBAccessoryActivity"
android:label="#string/app_name"
android:launchMode="singleInstance"
android:taskAffinity=""
android:exported="true">
<intent-filter>
<action android:name="android.hardware.usb.action.USB_ACCESSORY_ATTACHED" />
</intent-filter>
</activity>
<activity
android:name="gurux.serial.GXProperties"
android:exported="true"/>
</application>

Related

Flutter fix android:exported error on android project

I used this repository on github on our project and when i try to run or getting build application I get this error:
android:exported needs to be explicitly specified for element <activity#de.blinkt.openvpn.LaunchVPN>.
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.
in that library we have this AndroidManifest.xml without android:exported element
<service
android:name="de.blinkt.openvpn.core.OpenVPNService"
android:permission="android.permission.BIND_VPN_SERVICE">
<intent-filter>
<action android:name="android.net.VpnService"/>
</intent-filter>
</service>
<activity
android:name="de.blinkt.openvpn.LaunchVPN"
android:excludeFromRecents="true"
android:label="#string/vpn_launch_title"
android:theme="#android:style/Theme.DeviceDefault.Light.Panel">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
</activity>
the library owner don't added this element on that and this library implemented by this code:
implementation 'com.github.Topfreelancerdeveloperr:flutter_openvpn_library_updated:3361996fa1'
i think i should fork this project to add this element but i don't know how can i use forked project on github in gradle
Now when creating new Flutter project, a property android:exported="true" is now automatically added in AndroidManifest.xml. I faced similar issue with my one of old project during building. I just added it in <activitiy> of AndroidManifest and it worked fine.
Your <activity block should look like this.
<activity
android:name=".MainActivity"
android:exported="true"
android:launchMode="singleTop"
android:theme="#style/LaunchTheme"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
android:hardwareAccelerated="true"
android:windowSoftInputMode="adjustResize">

Manifest Merger failed with multiple errors in Android Studio for react native

Manifest Merger failed with multiple errors in Android Studio.
->Error: 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. SVBasketball.app main manifest (this file)
As the message have stated, property android:exported must be defined for an component that has an intent filter
<?xml version="1.0" encoding="utf-8"?>
<manifest>
<application>
<activity
android:name=".MainActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>

Android How can i override exported tag in manifest?

I want to upgrade target sdk from 30 to 31. But i'm getting that 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.
When i'm look around in manifest merger. I see one of the third party library which i use in the app didn't add android:exported tag.
<service android:name="com.****.MessagingService" >
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT" />
</intent-filter>
</service>
So here is my question. How can i override this service as exported false like below ?
<service android:exported="false"
android:name="com.****.MessagingService" >
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT" />
</intent-filter>
</service>
Android Studio will merge all manifest files of your project and its dependencies.
The upper level manifests can always take priority and overwrite the values in the dependencies. Check this paragraph in the documentation.
Since the dependencies do not specify the exported value at all, you can overwrite each service in your top level manifest file like this:
<service android:exported="false"
android:name="com.****.MessagingService" />
This will merge the values for the service tag for com.****.MessagingService and apply the exported value.
You can either replace the whole node
<service
tools:node="replace"
android:name=".MessagingService"
android:exported="false">
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT" />
</intent-filter>
</service>
Or just the attribute you need to replace
<service
tools:replace="exported"
android:name=".MessagingService"
android:exported="false"/>
You can find more information about this topic here

Manifest merger failed : android:exported needs to be explicitly specified for <service> even if there were no services in my AndroidManifest.xml file

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.
There are no <services in my app's AndroidManifest.xml file, I also looked for each AndroidManifest.xml file and they also don't have any <service element, so why am I getting this error?
There are no errors in my merged manifest tab, however, the first manifest has two <receiver and I've already added android:exported property manually in them.
In app -> src -> main -> AndroidManifest.xml you need to explicitly add the Tag of android:exported="true" in each <Activity> under <Application>
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:roundIcon="#mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="#style/Theme.Eynetic">
<activity android:name=".Splash_Screen"
android:theme="#style/SplashTheme"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".MainActivity"
android:theme="#style/MainTheme"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
See the Activity Tag in the code...
<activity android:name=".Splash_Screen"
android:theme="#style/SplashTheme"
android:exported="true">
Currently i am doing it with each activity as that was the error given by Android studio but maybe there is a better way to add it only once somewhere in the code.
Try adding android:exported = false pr android:exported = true in your own manifest file and compile the code. I hope this should solve you issue. As adding manually in notification will not work.

Manifest merger failed targeting Android 12 [duplicate]

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.

Categories

Resources