OneSignal-Cordova-SDK
OneSignal-Cordova-SDK copied to clipboard
Ionic 3 manifest error after upgrade to target-sdk 31
After upgrade target-sdk to 31 I get an error that comes from AndroidManifest.xml file
> Task :app:processDebugMainManifest FAILED
....\platforms\android\app\src\main\AndroidManifest.xml
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.
The only thing that doesn't contain the tag android:exported on AndroidManifest.xml file is
<receiver android:name="com.onesignal.ADMMessageHandler$Receiver" android:permission="com.amazon.device.messaging.permission.SEND">
<intent-filter>
<action android:name="com.amazon.device.messaging.intent.REGISTRATION" />
<action android:name="com.amazon.device.messaging.intent.RECEIVE" />
<category android:name="com.app.testapp" />
</intent-filter>
</receiver>
But after I try to add the tag to the receiver and build again It replicates the receiver without the tag,
i using
"onesignal-cordova-plugin": "^2.11.2",
"ionic-native/onesignal": "^4.18.0",
Thank you for reporting @orelbutbul,
We will update our Amazon SDK Setup documentation under Step 2.3 with android:exported="true"
. I will close this issue when it goes live.
@nan-li Maybe you didn't understand me, but I have an error, it doesn't let me add android:exported="true" to the reciver , when I try to add, it duplicates the receiver code over again without the android:exported="true",
Does anyone know how to solve the problem?
Ahh I see, sorry I did misunderstand.
You are on the previous major version 2.x.x
of onesignal-cordova-plugin. This <receiver>
is coming directly from our SDK here but is no longer included in the current major versions 3.x.x
.
Are you able to upgrade to 3.x.x
?
No I have no option, It's ionic 3, and because this
We would have to make a release here on version 2.x.x
. We would also have to release an older version of OneSignal-Android-SDK
as well and check all of its dependencies. This is because our Cordova plugin relies on our Android native SDK.
There may be a workaround for now where you can overwrite entries for library Manifests. I am able to reproduce your issue and will investigate a solution.
I'm having the same issue. Any expectations to release a version with the fix for 2.x.x
? I tried to modify the plugin.xml
to see if I could do some workaround but I'm still getting an error because there is more declarations with intent-filter without the android:exported
on the merged-manifest
.
Thank you!
i'm having the same problem, we can't update onesignal at the moment to the latest version. To fix it I would need to insert android:exported in the plugin and in the android SDK.
I have the same problem, I use cordova to compile the apps, I've tried all the steps mentioned and it doesn't work. @orelbutbul do you know if there is a fix for this problem?
In my case with Ionic 3 I installed the version
"onesignal-cordova-plugin": "^3.1.0",
"@ionic-native/onesignal": "^5.36.0",
in app.module.ts i change to import { OneSignal } from '@ionic-native/onesignal/ngx';
And instead of using this code to get details
this.oneSignal.startInit(oneSignalAppId, sender_id);
this.oneSignal.inFocusDisplaying(this.oneSignal.OSInFocusDisplayOption.Notification);
this.oneSignal.handleNotificationReceived().subscribe(data => this.onPushReceived(data.payload));
this.oneSignal.handleNotificationOpened().subscribe(data => this.onPushOpened(data.notification.payload));
this.oneSignal.enableSound(false);
this.oneSignal.endInit();
this.oneSignal.getIds().then((id) => {
// use the details
}
I use this code
window['plugins']['OneSignal'].setAppId(app.oneSignalAppId)
window['plugins']['OneSignal'].addSubscriptionObserver(async (event) => {
if (event.to.isSubscribed) {
window['plugins']['OneSignal'].getDeviceState((state) => {
if(state) {
// use the details
}
})
}
});
window['plugins']['OneSignal'].setNotificationOpenedHandler((jsonData: any) => {
this.onPushOpened(jsonData.notification)
});
And it works for me :) I hope I helped some of you, it's just important to note that I'm doing a build from Android Studio
i'm having the same problem, we can't update onesignal at the moment to the latest version. To fix it I would need to insert android:exported in the plugin and in the android SDK. My app only register at Onesignal with 2.11.4 version.
The Play Store is mandatory Android vresion 31.
Help me Please.
In more detail, the problem is quite simple. But I can't insert android:exported in OneSignalAndroidSDK. Only in plugin.xml as shown in the image.
In OneSignalAndroidSDK comes with manifest without android:exported.
Unfortunately, we are currently unable to update OneSignal to version >3.X.X, due to compatibility issues with AndroidX. :(
In more detail, the problem is quite simple. But I can't insert android:exported in OneSignalAndroidSDK. Only in plugin.xml as shown in the image.
In OneSignalAndroidSDK comes with manifest without android:exported.
Unfortunately, we are currently unable to update OneSignal to version >3.X.X, due to compatibility issues with AndroidX. :(
Do you know why all 3.x.x don't run?
@marcioramosilva1 Version 3.X.X is only compatible with projects with androidx enabled. We haven't migrated our app to androidx yet, so OneSignal 3.X.X is not supported. The reason not to migrate yet is because many plugins we use don't support androidx. We tried to use cordova-plugin-androidx-adapter plugin, but onesignal in version 3.X.X causes a runtime error causing the app to not open on Android 12 OS.
I use ionic, but i created a new app empty, and add just onesignal plugin. The app don't register at onesignal.
In more detail, the problem is quite simple. But I can't insert android:exported in OneSignalAndroidSDK. Only in plugin.xml as shown in the image.
In OneSignalAndroidSDK comes with manifest without android:exported.
Unfortunately, we are currently unable to update OneSignal to version >3.X.X, due to compatibility issues with AndroidX. :(
I tried the same workaround, but it fails because the merged-manifest doesn't have all the android:exported needed. @nan-li Any chance to add the missing android:exported
on plugin.xml and on the OneSignalAndroidSDK
?
Hi all, we are investigating the complexity of updating the previous major version to support targeting Android 31.
Updating our own android:exported
property is simple. However, we have to update the OneSignal Android SDK's own dependencies as well and this may pose some challenges. We will follow up on this.
Is there any workaround available till then, It's been a while.
I am in the same situation, I tried the solution proposed by @orelbutbul but with no success, is there any thing else to try ?
Hi,
Did any one have got any work around??
Guys, ANDROID 31 target has mostly broken all cordova projects.
Thanks
I found an alternative.
In order not to migrate to androidx, we use the cordova-plugin-androidx-adapter
plugin.
the latest version of onesignal normally. That way it works.
Add this to config.xml:
<preference name="AndroidXEnabled" value="true" /> <edit-config file="app/src/main/AndroidManifest.xml" target="/manifest/application/activity" mode="merge"> <activity android:exported="true" /> </edit-config>
This should work, but there is an error on android 12 that the app closes. To solve it, I forked the one-signal plugin and made a change in the plugin.xml of the onesignal plugin adding this:
<framework src="androidx.work:work-runtime-ktx:2.7.0" />
The fork was added like this in the config.xml:
<plugin name="onesignal-cordova-pluginfix" spec="git+https://github.com/danialvesb/onesignal-cordova-pluginfix.git" />
This is just a stopgap measure, while the issue is not resolved in version 2.X.X, the issue still persists.
Any update on this issue? @nan-li
Hi everyone, I am very sorry for the delayed response.
After investigating full support of Android 31 on the previous release, we will not be making updates to OneSignal-Cordova-SDK 2.x.x to support this.
Instead, we will aim to help apps upgrade to OneSignal-Cordova-SDK 3.x.x, starting with looking at the compatibility issue with cordova-plugin-androidx-adapter
.
Please post any issues you run into upgrading to version 3.x.x
and we will try to help you resolve them.
I'm on Ionic 6 and I'm still getting the same error even after updating my android target and compile SDK to version 33 as per the OneSignal documentation on upgrading from 2.X.X to 3.X.X
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.
Hi @timonjagi,
To confirm, you are using OneSignal-Cordova-SDK version 3.x.x and you are still getting "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"
? Is that error gone if you remove OneSignal?
@nan-li My bad. I can confirm the error still persists even after removing OneSignal. It must be another other plugin causing the error.
[EDIT] Found the source of the error. It was being caused by social-sharing
plugin, not OneSignal. The fix is here
I found that widget.name in config include any non english letter will cause build error. I change the app name to pure english without space, use plugin cordova-plugin-app-name to rename app name. Everything got well when using ionic 3 with onesignal v3.2.0
For iOS, need OneSignal.promptForPushNotificationsWithUserResponse(); after OneSignal.setAppId();
hy i am facing issue if i use onesignal latest version 3.x.x then that targetsdk 31 issue resolve and i am able to build but onesignal gives "plugin not installed error on inspect" but if i use 2.x.x version of onesignal then on targetsdk 31 i face that merge manifest issue i also try adding export true in plugin.xml file of version 2.x.x
plz help me any workaround
@adeel399 Please remove "@ionic-native/onesignal@4" if exist. Onesignal v3.2.0 can import directly by: import OneSignal from 'onesignal-cordova-plugin'; OneSignal.setAppId("YOUR_ONESIGNAL_APP_ID");
You mean i update onesignal to latest version and add these line directly to app.component file and then i will not get plugin not installed error??
@adeel399 you got error when install plugin or when build apk? copy whole error message and post here.