Hi there, I’m using cordova-plugin-x-socialsharing
to share data by WhatsApp, on Android12 it works perfectly but on Android13 it crashes and closes the app, debugging the apk with Android Studio I could rescue this error message:
2023-02-27 11:18:23.413 11744-11744/com.app.name E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.app.name, PID: 11744
android.content.ActivityNotFoundException: Unable to find explicit activity class {com.whatsapp/com.whatsapp.contact.picker.ContactPicker}; have you declared this activity in your AndroidManifest.xml, or does your intent not match its declared <intent-filter>?
at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:2197)
at android.app.Instrumentation.execStartActivity(Instrumentation.java:1839)
at android.app.Activity.startActivityForResult(Activity.java:5471)
at androidx.activity.ComponentActivity.startActivityForResult(ComponentActivity.java:597)
at org.apache.cordova.CordovaActivity.startActivityForResult(CordovaActivity.java:359)
at android.app.Activity.startActivityForResult(Activity.java:5429)
at androidx.activity.ComponentActivity.startActivityForResult(ComponentActivity.java:583)
at org.apache.cordova.CordovaInterfaceImpl.startActivityForResult(CordovaInterfaceImpl.java:69)
at nl.xservices.plugins.SocialSharing$2$1.run(SocialSharing.java:348)
at android.os.Handler.handleCallback(Handler.java:942)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loopOnce(Looper.java:201)
at android.os.Looper.loop(Looper.java:288)
at android.app.ActivityThread.main(ActivityThread.java:7872)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:936)
My plugin invocation from a vue js based app (this works even on Android12):
window.plugins.socialsharing.shareViaWhatsApp(
'',
null,
'some message...',
ok => {
console.log(ok)
},
err => {
console.log(err)
},
)
if I intent to use the shareWhitOptions
method like this (it also works even on Android12):
let options = {
subject: 'Text',
url: null,
message: 'Text',
chooserTitle: 'Text',
}
window.plugins.socialsharing.shareWithOptions(
options,
ok => {
console.log(ok)
},
err => {
console.log(err)
},
)
It doesn’t show the apps to share like WhatsApp or Google Messages, it just show the basic sharing options: Bluetooth, Gmail, Drive, Messages(SMS).
My config.xml data is this:
<?xml version='1.0' encoding='utf-8'?>
<widget id="com.app.name" version="1.0.0" xmlns="http://www.w3.org/ns/widgets" xmlns:android="http://schemas.android.com/apk/res/android" xmlns:cdv="http://cordova.apache.org/ns/1.0">
<name>Company Name</name>
<description>
Company Name
</description>
<author email="company@mail.com" href="https:companysite.com">
Company Name
</author>
<access origin="*" />
<access origin="content:///*" />
<allow-navigation href="https://backendUrl/*" />
<allow-navigation href="http://*/*" />
<allow-navigation href="https://*/*" />
<allow-navigation href="*" />
<allow-intent href="http://*/*" />
<allow-intent href="*" />
<allow-intent href="https://*/*" />
<allow-intent href="tel:*" />
<allow-intent href="sms:*" />
<allow-intent href="mailto:*" />
<allow-intent href="geo:*" />
<allow-intent href="maps:*" />
<allow-intent href="appcustomurl:" />
<content src="index.html" />
<engine name="android" spec="11.0.0" />
<preference name="AndroidLaunchMode" value="singleInstance" />
<preference name="phonegap-version" value="cli-9.0.0" />
<preference name="fullscreen" value="false" />
<preference name="DisallowOverscroll" value="true" />
<preference name="AndroidPersistentFileLocation" value="Compatibility" />
<preference name="SplashMaintainAspectRatio" value="false" />
<preference name="SplashShowOnlyFirstTime" value="false" />
<preference name="android-minSdkVersion" value="26" />
<preference name="android-targetSdkVersion" value="33" />
<preference name="Hostname" value="ss-app" />
<preference name="Scheme" value="https" />
<preference name="iosScheme" value="https" />
<preference name="UIWebViewBounce" value="false" />
<preference name="BackupWebStorage" value="local" />
<preference name="ShowSplashScreenSpinner" value="false" />
<preference name="Suppresses3DTouchGesture" value="true" />
<preference name="Allow3DTouchLinkPreview" value="false" />
<preference name="WKWebViewOnly" value="true" />
<preference name="AllowInlineMediaPlayback" value="true" />
<preference name="SplashScreenDelay" value="2000" />
<preference name="AutoHideSplashScreen" value="true" />
<preference name="AndroidWindowSplashScreenBackground" value="#ffffff" />
<preference name="AndroidWindowSplashScreenAnimatedIcon" value="resources/splashTemplate.png" />
<platform name="android">
<allow-intent href="market:*" />
<edit-config file="app/src/main/AndroidManifest.xml" mode="merge" target="/manifest/application">
<application android:usesCleartextTraffic="true" />
</edit-config>
<edit-config file="app/src/main/AndroidManifest.xml" mode="merge" target="/manifest/application/activity">
<application android:exported="true" />
</edit-config>
<config-file parent="/manifest/application/activity" target="AndroidManifest.xml">
<intent-filter>
<action android:name="com.whatsapp.contact.picker.ContactPicker" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</config-file>
<config-file parent="/manifest" target="AndroidManifest.xml">
<queries>
<package android:name="com.whatsapp" />
<package android:name="com.whatsapp.w4b" />
</queries>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
</config-file>
<preference name="loadUrlTimeoutValue" value="12000000" />
<preference name="SplashMaintainAspectRatio" value="true" />
<preference name="SplashShowOnlyFirstTime" value="true" />
<preference name="AndroidXEnabled" value="true" />
<resource-file src="FCM/google-services.json" target="app/google-services.json" />
</platform>
<plugin name="cordova-plugin-splashscreen" spec="^5.0.3" />
<plugin name="cordova-plugin-dialogs" spec="^2.0.2" />
<plugin name="cordova-plugin-camera" />
<plugin name="cordova-plugin-device" spec="^2.0.3" />
<plugin name="cordova-plugin-app-version" spec="^0.1.9" />
<plugin name="cordova-plugin-inappbrowser" spec="^4.0.0" />
<plugin name="cordova-plugin-statusbar" spec="^2.4.3" />
<plugin name="cordova-plugin-ionic-keyboard" spec="2.1.3" />
<plugin name="cordova-plugin-geolocation" spec="^4.0.2" />
<plugin name="cordova-plugin-ionic-webview" spec="^4.1.2" />
<plugin name="@havesource/cordova-plugin-push@dev" /><!-- use @dev flag if it fails on android 12 when the device recieves a notif-->
<plugin name="cordova-plugin-x-socialsharing-android12" />
<plugin name="cordova-plugin-androidx-adapter" />
<plugin name="cordova-plugin-customurlscheme">
<variable name="URL_SCHEME" value="appcustomurl" />
</plugin>
<feature name="Custom URL scheme">
<param name="id" value="cordova-plugin-customurlscheme" />
<param name="url" value="https://github.com/EddyVerbruggen/Custom-URL-scheme.git" />
<variable name="URL_SCHEME" value="appcustomurl" />
</feature>
<feature name="SocialSharing">
<param name="android-package" value="nl.xservices.plugins.SocialSharing" />
</feature>
</widget>
And when I try to use the Cordova engine “11.1.0” I get this error:
UserError: npm ERR! code ETARGET
npm ERR! notarget No matching version found for cordova-android@11.1.0.
npm ERR! notarget In most cases you or one of your dependencies are requesting
npm ERR! notarget a package version that doesn't exist.
Sorry for the ‘long post’ but I think you may need these details