Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

android 12 fix #1158

Merged
merged 5 commits into from
Sep 7, 2022
Merged

android 12 fix #1158

merged 5 commits into from
Sep 7, 2022

Conversation

FilippiMatteo
Copy link
Contributor

Please merge this small changes for android 12 with build-tools sdk 31.
thank you

plugin.xml Outdated Show resolved Hide resolved
@bhandaribhumin
Copy link

bhandaribhumin commented Feb 14, 2022

@FilippiMatteo @vouillon you need to add android:exported="true/false" at nl.xservices.plugins.ShareChooserPendingIntent

Right now i was handling by adding below code in config.xml

 <edit-config file="app/src/main/AndroidManifest.xml" mode="merge" target="/manifest/application/receiver[@android:name='nl.xservices.plugins.ShareChooserPendingIntent']">
            <activity android:exported="true" />
  </edit-config>

@bhandaribhumin
Copy link

any plan for merge to master?

@jmalfatto
Copy link

any plan for merge to master?

I second this question!

@ucsbricks
Copy link

Thanks @FilippiMatteo

@EddyVerbruggen any plans to merge his PR?

@tomfong
Copy link

tomfong commented Apr 3, 2022

@EddyVerbruggen Please merge this PR asap.

@hanslbua
Copy link

does anyone know, when this will be merged? i need this feature to support android 12

@tomfong
Copy link

tomfong commented Apr 10, 2022

does anyone know, when this will be merged? i need this feature to support android 12

no one knows... I've already tweeted Eddy but not yet got the reply. The temporary solution is to manually change the code according to this PR every time before building the app in Android Studio, if you use capacitor.

@hldh214
Copy link

hldh214 commented Apr 20, 2022

@FilippiMatteo @vouillon you need to add android:exported="true/false" at nl.xservices.plugins.ShareChooserPendingIntent

Right now i was handling by adding below code in config.xml

 <edit-config file="app/src/main/AndroidManifest.xml" mode="merge" target="/manifest/application/receiver[@android:name='nl.xservices.plugins.ShareChooserPendingIntent']">
            <activity android:exported="true" />
  </edit-config>

May I ask which section should this xml stay?
I tried to put it under <widget> in config.xml and when I remove platform/android folder and do cordova platform add android, I got error says this ShareChooserPendingIntent section not found(see below), I guess the plugin's discovery process is after this edit config process, so how do we deal with this situation?

Subproject Path: CordovaLib
Subproject Path: app
Android project created with cordova-android@9.1.0
Unable to graft xml at selector "/manifest/application/receiver[@android:name='nl.xservices.plugins.ShareChooserPendingIntent']" from "/app/platforms/android/app/src/main/AndroidManifest.xml" during config install

@EinfachHans
Copy link

Please merge this!

Copy link

@tomfong tomfong left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@EddyVerbruggen Please approve and merge this PR.

@wata-tomnguyen
Copy link

Hi @EddyVerbruggen
Please merge this PR, it's causing a stuck in my project when i updated it to android 12
Thanks bro!

@whria78
Copy link

whria78 commented Jun 5, 2022

This solution works for me.

@Takkuz
Copy link

Takkuz commented Jul 1, 2022

Due to the lack of PR merge I forked it and published on NPM as cordova-plugin-x-socialsharing-android12 with the commits done by @FilippiMatteo as v6.0.4.

You can use it by installing as npm i cordova-plugin-x-socialsharing-android12 and cordova plugin add cordova-plugin-x-socialsharing-android12

I think I'll remove it as soon as this will be merged.

@tomfong
Copy link

tomfong commented Jul 16, 2022

@Takkuz How about for Capacitor? How to integrate yours to awesome-cordova-plugin?

@Takkuz
Copy link

Takkuz commented Jul 21, 2022

@Takkuz How about for Capacitor? How to integrate yours to awesome-cordova-plugin?

Sorry @tomfong, I'm not used to Capacitor so I don't know how to integrate it.

@bonjourjoel
Copy link

Hi, i have the same problem.

@HarelM
Copy link

HarelM commented Aug 1, 2022

@Takkuz thanks for this! Any chance you can remove the dependency for es6-promise-plugin in your npm version?
@tomfong there's no issue with using @Takkuz plugin with capacitor - npm uninstall "old-one" && npm i "new-one" && npx cap sync, as usual
You can use it with @ionic-native/social-sharing so that it is an angular injectable serivce.

@TomCosta
Copy link

TomCosta commented Aug 2, 2022

Due to the lack of PR merge I forked it and published on NPM as cordova-plugin-x-socialsharing-android12 with the commits done by @FilippiMatteo as v6.0.4.

You can use it by installing as npm i cordova-plugin-x-socialsharing-android12 and cordova plugin add cordova-plugin-x-socialsharing-android12

I think I'll remove it as soon as this will be merged.

It works great, thanks. But if someone else like a team member clones the code, it doesn't install the same plugin again. It install the older version of the plugin instead of the new one.
Please, how may we solve this?

@Takkuz
Copy link

Takkuz commented Aug 5, 2022

Due to the lack of PR merge I forked it and published on NPM as cordova-plugin-x-socialsharing-android12 with the commits done by @FilippiMatteo as v6.0.4.
You can use it by installing as npm i cordova-plugin-x-socialsharing-android12 and cordova plugin add cordova-plugin-x-socialsharing-android12
I think I'll remove it as soon as this will be merged.

It works great, thanks. But if someone else like a team member clones the code, it doesn't install the same plugin again. It install the older version of the plugin instead of the new one. Please, how may we solve this?

Ok, I should have fixed it. It should be due to the ald ID still used inside plugin section. I don't have it because I don't use the plugin section on config.xml.

@HarelM
Copy link

HarelM commented Aug 5, 2022

@Takkuz any chance to remove the es6 plugin dependency while your are at it?

@HarelM
Copy link

HarelM commented Aug 5, 2022

I'm using your plugin without this dependency and it works as expected. I don't think it's needed anymore as all modern browsers supports promises.

@dcxn
Copy link

dcxn commented Aug 11, 2022

Have the same issue. Guess no one can move this along other than @EddyVerbruggen 😓

I tried the solution frequently suggested here #1158 (comment) but that creates the Unable to graft xml at selector error @hldh214 mentioned.

@EltonFaust
Copy link

The android:exported="true" problem on the main activity, was fixed in the newer versions of the android-cordova (check here in release notes).
Install the newest version will prevent the problem, preventing the need of the edit-config option.
You can install de newest version with:

cordova platform remove android
cordova platform add android@11

Be aware that the newer versions use the java 11 instead of the java 8.

@FilippiMatteo I opened a pull on your branch, it's just a fix, since the min SDK version allowed on cordova-android is 22, and the flag FLAG_IMMUTABLE was added only on SKD 23, to prevent some unexpected behaviour on devices with SDK 22, I only added the flag when needed, if you could check the pull and merge into yours.

@bonjourjoel
Copy link

The android:exported="true" problem on the main activity, was fixed in the newer versions of the android-cordova (check here in release notes). Install the newest version will prevent the problem, preventing the need of the edit-config option. You can install de newest version with:

cordova platform remove android
cordova platform add android@11

Hi. I have the latest cordova android, installed like you mentioned. However I do have the problem with android:exported="true".
I had to add an edit-config, plus some weird fix in my prepare hook to make the packaging work.
And I still need a fix on this plugin.

And all this is related to the latest cordova android release AND this plugin not being compatible.

Regards.

@EltonFaust
Copy link

Weird it didn't work on the main activity with the newer version (the newer version don't fix the plugin problem only on the main activity ploblem), i've had a lot of problems adding/removing plugins and the platform itself, I would recommend to remove entirely the node_modules, plugins and platforms directories and try add the platform again, solved a lot of problems with that...

@bonjourjoel
Copy link

Weird it didn't work on the main activity with the newer version (the newer version don't fix the plugin problem only on the main activity ploblem), i've had a lot of problems adding/removing plugins and the platform itself, I would recommend to remove entirely the node_modules, plugins and platforms directories and try add the platform again, solved a lot of problems with that...

The problem is not on the main activity. The problem is on the activity of the plugin.
The main activity is fine and doesn't produce an error.

@EltonFaust
Copy link

My mistake, I thought was understood that only the android:exported="true" wont be enough, this will allow the app to be built, but once the plugin is called, and reaches the PendingIntent without the mutability flag, will crash your app (on devices with SDK 31+).

Since someone provided an alternative npm package with all the changes, and seen the log on one comment showing that was used the cordova-android 9, I assumed that the problem still happening only could be on the main activity not on this plugin receiver.

@luvenan
Copy link

luvenan commented Aug 12, 2022

Since the last comments on this are very recent... I guess no updates. This is really bad, because now googleplay requires you to target sdk 31, so this needs to work for the app to be uploaded.

@HarelM
Copy link

HarelM commented Aug 12, 2022

Android 12 package mentioned here is working as expected and can be used. I have it in production now.

@saggio89
Copy link

saggio89 commented Sep 7, 2022

This fix worked for me. I will also tweet him to merge it

@EddyVerbruggen EddyVerbruggen merged commit 18f6577 into EddyVerbruggen:master Sep 7, 2022
@EddyVerbruggen EddyVerbruggen added this to the 6.0.4 milestone Sep 7, 2022
@HarelM
Copy link

HarelM commented Sep 7, 2022

@EddyVerbruggen can you remove the es6-promise dependency?

@tomfong
Copy link

tomfong commented Sep 9, 2022

finally merged!

@bonjourjoel
Copy link

Awesome news!

@idrisAd
Copy link

idrisAd commented Sep 9, 2022

Hi !
As @hldh214 I have the problem below
Android project created with cordova-android@11.0.0 Unable to graft xml at selector "/manifest/application/receiver[@android:name='nl.xservices.plugins.ShareChooserPendingIntent']" from "/Users/vagrant/git/platforms/android/app/src/main/AndroidManifest.xml" during config install

I added the differents for activity and receiver in my config.xml
<edit-config file="app/src/main/AndroidManifest.xml" mode="merge" target="/manifest/application/activity[@android:name='MainActivity']" xmlns:android="http://schemas.android.com/apk/res/android"> <activity android:exported="true" /> </edit-config> <edit-config file="app/src/main/AndroidManifest.xml" mode="merge" target="/manifest/application/receiver[@android:name='nl.xservices.plugins.ShareChooserPendingIntent']"> <activity android:exported="false" /> </edit-config>
I also add cordova-plugin-x-socialsharing but the problem is still here.

Do you have an idea for a solution?

@saggio89
Copy link

saggio89 commented Sep 9, 2022

@idrisAd with version 6.0.4 you should be able to delete those "edit-config" lines you added and it should work without them. Also when upping your target SDK to 31 for android make sure you have Java 11 installed. I had Java 1.8 and it was causing issues building for me.

@idrisAd
Copy link

idrisAd commented Sep 12, 2022

Thx @saggio89 !
I got errors like error: cannot find symbol import android.support.v4.app.NotificationCompat; but with cordova plugin add cordova-plugin-androidx-adapter I solved them.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.