Unity android 12 with android:exported attribute issue - android

I would like to build the game in android 12. I know I need to add the android:exported="true" into activity tag which included intent-filter.
So I already added the android:exported="true" into activity tag in my AndroidManifest.xml. But I built on the android 12 device is still has error.
Installation failed due to: 'Failed to commit install session 1567366667 with command cmd package install-commit 1567366667. Error: INSTALL_PARSE_FAILED_MANIFEST_MALFORMED: Failed parse during installPackageLI: /data/app/vmdl1567366667.tmp/base.apk (at Binary XML file line #136): com.unity.purchasing.googleplay.VRPurchaseActivity: Targeting S+ (version 31 and above) requires that an explicit value for android:exported be defined when intent filters are present'
But I don't know what is VRPurchaseActivity and I don't add this activity to my AndroidManifest.xml.
So anyone know how to fix this issue. Thank a lots.

The activity comes from Unity but there is a way to override its attributes. Put this inside your manifest:
<activity android:name="com.unity.purchasing.googleplay.VRPurchaseActivity">
android:exported="false"
tools:node="merge" />

Related

INSTALL_PARSE_FAILED_MANIFEST_MALFORMED: Failed parse during installPackageLI

Following error appearing while installing app on emulator.
'''Failed to commit install session 27757417 with command package install-commit 27757417. Error: INSTALL_PARSE_FAILED_MANIFEST_MALFORMED: Failed parse during installPackageLI: /data/app/vmdl27757417.tmp/base.apk (at Binary XML file line #57): com.nfs.mobility.myapp.activities.SplashActivity: Targeting S+ (version 31 and above) requires that an explicit value for android:exported be defined when intent filters are present''''
This error message "INSTALL_PARSE_FAILED_MANIFEST_MALFORMED: Failed parse during installPackageLI" appears when there is a problem with the AndroidManifest.xml file of the app.
In this particular case, the error message mentions that there is an issue with the com.nfs.mobility.myapp.activities.SplashActivity activity in the AndroidManifest.xml file, specifically that it is targeting Android 11 (S+) and above but doesn't have an explicit value for android:exported when intent filters are present.
Here are some of the solutions:
Check the AndroidManifest.xml file for errors such as missing tags,
incorrect formatting, or missing permissions
Make sure that the android:exported attribute is set to "true" for activities that should be accessible from other apps, or to "false" for activities that should not be.
Make sure that the activity's intent filters are correctly defined.
Try cleaning and rebuilding the project in Android Studio.
Try uninstalling the older version of the app from your device
before installing the new version.

I can't find this error when I make API 31, there are these 3 errors in each of my projects

Merging Errors:
Error: android:exported needs to be explicitly specified for element <receiver#com.onesignal.GcmBroadcastReceiver>. 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. app main manifest (this file), line 57
Error: android:exported needs to be explicitly specified for element <receiver#com.onesignal.BootUpReceiver>. 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. .app main manifest (this file), line 93
Error: android:exported needs to be explicitly specified for element <receiver#com.onesignal.UpgradeReceiver>. 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.
.app main manifest (this file), line 100
It explains itself s you need to add android:exported="true or false" for your Receiver GcmBroadcastReceiver
If u don't intend to upload your app to play Store you can downgrade your API to 30 and it will work without you adding android:exported for every activity.

I have problem when I want debug my app in Flutter

Error:
adb: failed to install C:\Users\legion\Desktop\nojoum-application\build\app\outputs\flutter-apk\app.apk: Failure [INSTALL_PARSE_FAILED_MANIFEST_MALFORMED: Failed parse during installPackageLI: /data/app/vmdl764320653.tmp/base.apk (at Binary XML file line #79): com.ryanheise.audioservice.AudioService: Targeting S+ (version 31 and above) requires that an explicit value for android:exported be defined when intent filters are present]
Error launching application on sdk gphone64 x86 64.
This is my error log:
Please add the
android:exported="true"
to your Main Activity's activity tag in the AndroidManifest.xml file, like this:
Open Your Project's Android manifest, located at android/app/src/main/AndroidManifest.xml
Go to this line: android:name=".MainActivity"
Below this line, add android:exported="true"
The code should now look like this:
android:name=".MainActivity" // this must be the main activity
android:exported="true"
android:launchMode="singleTop" // this line can be something else, no worries
Explanation
What this does is that it tells Android to make this activity available to be accessed by another app, so that it can open your App. As the launcher (the app drawer/home screen) can be a normal app in android, the Main Activity must be exported to allow it to launch your app.
Go to android/app/src/main/AndroidManifest.xml and paste android:exported="true" after android:name=".MainActivity" like this:

Android Studio: package name conflict and BIND_JOB_SERVICE permission error

I receive the following error in logcat when app crashes:
The app's package name is com.todo.quickcards
Somehow the RebootReceiver and RebootService classes have a reference to an old package name (see yellow highlights where the package name says "com.wimso.v118.RebootReceiver" and "com.example.jdw.v118/com.wimso.v118.RebootService). The logcat error suggests the BIND_JOB_SERVICE permission is needed in RebootService class but the Android Manifest already has that permission added for the RebootService:
AndroidManifest.xml
...
<service
android:name="com.todo.quickcards.RebootService"
android:permission="android.permission.BIND_JOB_SERVICE"
android:exported="false"
android:description="#string/rebootservicedesc" >
</service>
How can I remove the erroneous, old package name reference and have Android Studio reference the current com.todo.quickcards package name for the RebootReceiver and RebootService classes?
Turns out the issue was that I had an earlier version of the app on my device and that version did not have the android:permission="android.permission.BIND_JOB_SERVICE" in the Manifest. So when the device was re-booted the Receiver and Service in the earlier version app were generating the permission error. I updated the earlier version app with the BIND permission and no errors were generated.

ApplicationId versus PackageName issue with new flavor

I have developed a new flavor of my application. Now when uploading it on the store, I have an error : "You need to use a different package name..." because the first version of the app is already on the store.
I have followed this recommendation.
http://tools.android.com/tech-docs/new-build-system/applicationid-vs-packagename
I need a new manifest file for this new flavor, so I deleted the <manifest> attribute package="..." in the manifest of my new flavor.
As stated at the bottom of the above mentioned page:
NOTE 2:
The package name must always be specified in the default AndroidManifest.xml file. If you have multiple manifests (e.g. a flavor specific manifest or a buildType specific manifest), the package name is optional, but if it is specified it must be identical to the package specified d in the main manifest.
So now I run into this problem:
Error:Execution failed for task ':app:process***Manifest'.
Manifest merger failed : Attribute application#name value=(.Application) from AndroidManifest.xml:25:9-49
is also present at AndroidManifest.xml:25:9-49 value=(.HomeOnTheSpotApplication).
Suggestion: add 'tools:replace="android:name"' to element at AndroidManifest.xml:25:5-147:19 to override.
So I tried to add tools:replace="android:name" to the application application element but then I had this error (app crashing when starting):
FATAL EXCEPTION: main java.lang.RuntimeException: Unable to instantiate application newFlavor.Application: java.lang.ClassNotFoundException: Didn't find class "*.Application" on path: /data/app/.apk
I also tried to add 'tools:node="replace"' to the application element
But then it throws this message when trying to start the application:
Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp="flavor2"./"flavor1"..activity.splash.SplashActivity_ }
Error type 3
Error: Activity class {"flavor2"./"flavor1"..activity.splash.SplashActivity_} does not exist.
I'm out of ideas now :/

Categories

Resources