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

Background push notifications on Android cannot be received (Android 12, targetSdkVersion 31, 4.0.0-dev.0 plugin version) #208

Open
davidcopano opened this issue Nov 4, 2022 · 14 comments

Comments

@davidcopano
Copy link

Bug Report

Push notifications on Android cannot be received when the application is closed or in background, in a Android 12 device using targetSdkVersion 31 and plugin version 4.0.0-dev.0 from #185 (comment)

Expected Behaviour

Receive push notifications on Android 12 devices when app is closed or in background

Actual Behaviour

Push notifications on Android cannot be received when the application is closed or in background

Reproduce Scenario (including but not limited to)

Send any push notification to Android 12 device when app is closed or in background

Steps to Reproduce

  1. Install most recent plugin version from feat(android): support targetSdkVersion >= 31 (Android 12) #185 (comment)
  2. Close or exit without closing the app
  3. Send push notification to Android 12 device

Platform and Version (eg. Android 5.0 or iOS 9.2.1)

Android 12 using targetSdkVersion 31

(Android) Device Vendor (e.g. Samsung, HTC, Sony...)

Samsung Galaxy S10

cordova info Printout

Cordova Packages:

    cli: 11.0.0
        common: 4.0.2
        create: 4.0.0
        lib: 11.0.0
            common: 4.0.2
            fetch: 3.0.1
            serve: 4.0.0

Project Installed Platforms:

    android: 10.1.2

Project Installed Plugins:

    @havesource/cordova-plugin-push: 4.0.0-dev.0
    cordova-clipboard: 1.3.0
    cordova-plugin-androidx-adapter: 1.1.3
    cordova-plugin-camera: 6.0.0
    cordova-plugin-device: 2.1.0
    cordova-plugin-file: 6.0.2
    cordova-plugin-googlemaps: 2.7.1
    cordova-plugin-inappbrowser: 5.0.0
    cordova-plugin-ionic-keyboard: 2.2.0
    cordova-plugin-ionic-webview: 5.0.0
    cordova-plugin-photo-library-wkwebview: 3.0.3
    cordova-plugin-qrscanner-11: 3.0.4
    cordova-plugin-splashscreen: 5.0.4
    cordova-plugin-statusbar: 2.4.3
    cordova-plugin-stripe: 1.5.3
    cordova-plugin-x-socialsharing: 6.0.4
    cordova-plugin-x-toast: 2.7.3
    cordova-sqlite-storage: 6.0.0
    es6-promise-plugin: 4.2.2
    phonegap-plugin-multidex: 1.0.0

Environment:

    OS: Microsoft Windows 11 Pro 10.0.22621 (22621) (Windows 10.0.22621) x64
    Node: v10.24.1
    npm: 6.14.12

android Environment:

    android:
ERROR: Command failed with exit code 1: avdmanager list target
"avdmanager" no se reconoce como un comando interno o externo,
programa o archivo por lotes ejecutable.


Project Setting Files:

    config.xml:
<?xml version='1.0' encoding='utf-8'?>
<widget android-versionCode="30" id="com.package.app" version="0.0.5" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
    <name>App name</name>
    <description>App desc</description>
    <author email="email@example.com" href="http://example.com/">Example</author>
    <content src="index.html" />
    <access origin="*" />
    <allow-intent href="http://*/*" />
    <allow-intent href="https://*/*" />
    <allow-intent href="tel:*" />
    <allow-intent href="sms:*" />
    <allow-intent href="mailto:*" />
    <allow-intent href="geo:*" />
    <preference name="ScrollEnabled" value="false" />
    <preference name="android-minSdkVersion" value="22" />
    <preference name="android-targetSdkVersion" value="31" />
    <preference name="android-compileSdkVersion" value="31" />
    <preference name="AndroidXEnabled" value="true" />
    <preference name="GradlePluginGoogleServicesEnabled" value="true" />
    <preference name="GradlePluginGoogleServicesVersion" value="4.3.8" />
    <preference name="BackupWebStorage" value="none" />
    <preference name="SplashMaintainAspectRatio" value="true" />
    <preference name="FadeSplashScreenDuration" value="300" />
    <preference name="SplashShowOnlyFirstTime" value="false" />
    <preference name="orientation" value="portrait" />
    <preference name="SplashScreen" value="screen" />
    <preference name="SplashScreenDelay" value="3000" />
    <preference name="ShowSplashScreenSpinner" value="false" />
    <preference name="WKWebViewOnly" value="true" />
    <preference name="AllowInlineMediaPlayback" value="true" />
    <preference name="GOOGLE_MAPS_ANDROID_API_KEY" value="<API_KEY>" />
    <preference name="GOOGLE_MAPS_IOS_API_KEY" value="<API_KEY>" />
    <platform name="android">
        <resource-file src="google-services.json" target="app/google-services.json" />
        <edit-config file="app/src/main/AndroidManifest.xml" mode="merge" target="/manifest/application" xmlns:android="http://schemas.android.com/apk/res/android">
            <application android:networkSecurityConfig="@xml/network_security_config" />
            <application android:requestLegacyExternalStorage="true" />
        </edit-config>
        <config-file parent="/manifest" target="app/src/main/AndroidManifest.xml" xmlns:android="http://schemas.android.com/apk/res/android">
            <queries>
                <package android:name="com.whatsapp" />
                <package android:name="com.instagram.android" />
                <package android:name="com.twitter.android" />
                <package android:name="com.facebook.katana" />
            </queries>
        </config-file>
        <resource-file src="resources/android/xml/network_security_config.xml" target="app/src/main/res/xml/network_security_config.xml" />
        <allow-intent href="market:*" />
        <icon density="ldpi" src="resources/android/icon/drawable-ldpi-icon.png" />
        <icon density="mdpi" src="resources/android/icon/drawable-mdpi-icon.png" />
        <icon density="hdpi" src="resources/android/icon/drawable-hdpi-icon.png" />
        <icon density="xhdpi" src="resources/android/icon/drawable-xhdpi-icon.png" />
        <icon density="xxhdpi" src="resources/android/icon/drawable-xxhdpi-icon.png" />
        <icon density="xxxhdpi" src="resources/android/icon/drawable-xxxhdpi-icon.png" />
        <splash density="land-ldpi" src="resources/android/splash/drawable-land-ldpi-screen.png" />
        <splash density="land-mdpi" src="resources/android/splash/drawable-land-mdpi-screen.png" />
        <splash density="land-hdpi" src="resources/android/splash/drawable-land-hdpi-screen.png" />
        <splash density="land-xhdpi" src="resources/android/splash/drawable-land-xhdpi-screen.png" />
        <splash density="land-xxhdpi" src="resources/android/splash/drawable-land-xxhdpi-screen.png" />
        <splash density="land-xxxhdpi" src="resources/android/splash/drawable-land-xxxhdpi-screen.png" />
        <splash density="port-ldpi" src="resources/android/splash/drawable-port-ldpi-screen.png" />
        <splash density="port-mdpi" src="resources/android/splash/drawable-port-mdpi-screen.png" />
        <splash density="port-hdpi" src="resources/android/splash/drawable-port-hdpi-screen.png" />
        <splash density="port-xhdpi" src="resources/android/splash/drawable-port-xhdpi-screen.png" />
        <splash density="port-xxhdpi" src="resources/android/splash/drawable-port-xxhdpi-screen.png" />
        <splash density="port-xxxhdpi" src="resources/android/splash/drawable-port-xxxhdpi-screen.png" />
    </platform>
    <platform name="ios">
        <resource-file src="GoogleService-Info.plist" target="GoogleService-Info.plist" />
        <config-file parent="NSCameraUsageDescription" platform="ios" target="*-Info.plist">
            <string>PERMISSION MESSAGE</string>
        </config-file>
        <config-file parent="NSLocationAlwaysUsageDescription" target="*-Info.plist">
            <string>PERMISSION MESSAGE</string>
        </config-file>
        <config-file parent="NSLocationWhenInUseUsageDescription" target="*-Info.plist">
            <string>PERMISSION MESSAGE</string>
        </config-file>
        <resource-file src="GoogleService-Info.plist" />
        <allow-intent href="itms:*" />
        <allow-intent href="itms-apps:*" />
        <icon height="57" src="resources/ios/icon/icon.png" width="57" />
        <icon height="114" src="resources/ios/icon/icon@2x.png" width="114" />
        <icon height="20" src="resources/ios/icon/icon-20.png" width="20" />
        <icon height="40" src="resources/ios/icon/icon-20@2x.png" width="40" />
        <icon height="60" src="resources/ios/icon/icon-20@3x.png" width="60" />
        <icon height="48" src="resources/ios/icon/icon-24@2x.png" width="48" />
        <icon height="55" src="resources/ios/icon/icon-27.5@2x.png" width="55" />
        <icon height="29" src="resources/ios/icon/icon-29.png" width="29" />
        <icon height="58" src="resources/ios/icon/icon-29@2x.png" width="58" />
        <icon height="87" src="resources/ios/icon/icon-29@3x.png" width="87" />
        <icon height="40" src="resources/ios/icon/icon-40.png" width="40" />
        <icon height="80" src="resources/ios/icon/icon-40@2x.png" width="80" />
        <icon height="120" src="resources/ios/icon/icon-40@3x.png" width="120" />
        <icon height="88" src="resources/ios/icon/icon-44@2x.png" width="88" />
        <icon height="50" src="resources/ios/icon/icon-50.png" width="50" />
        <icon height="100" src="resources/ios/icon/icon-50@2x.png" width="100" />
        <icon height="60" src="resources/ios/icon/icon-60.png" width="60" />
        <icon height="120" src="resources/ios/icon/icon-60@2x.png" width="120" />
        <icon height="180" src="resources/ios/icon/icon-60@3x.png" width="180" />
        <icon height="72" src="resources/ios/icon/icon-72.png" width="72" />
        <icon height="144" src="resources/ios/icon/icon-72@2x.png" width="144" />
        <icon height="76" src="resources/ios/icon/icon-76.png" width="76" />
        <icon height="152" src="resources/ios/icon/icon-76@2x.png" width="152" />
        <icon height="167" src="resources/ios/icon/icon-83.5@2x.png" width="167" />
        <icon height="172" src="resources/ios/icon/icon-86@2x.png" width="172" />
        <icon height="196" src="resources/ios/icon/icon-98@2x.png" width="196" />
        <icon height="1024" src="resources/ios/icon/icon-1024.png" width="1024" />
        <splash height="480" src="resources/ios/splash/Default~iphone.png" width="320" />
        <splash height="960" src="resources/ios/splash/Default@2x~iphone.png" width="640" />
        <splash height="1024" src="resources/ios/splash/Default-Portrait~ipad.png" width="768" />
        <splash height="768" src="resources/ios/splash/Default-Landscape~ipad.png" width="1024" />
        <splash height="1125" src="resources/ios/splash/Default-Landscape-2436h.png" width="2436" />
        <splash height="1242" src="resources/ios/splash/Default-Landscape-736h.png" width="2208" />
        <splash height="2048" src="resources/ios/splash/Default-Portrait@2x~ipad.png" width="1536" />
        <splash height="1536" src="resources/ios/splash/Default-Landscape@2x~ipad.png" width="2048" />
        <splash height="2732" src="resources/ios/splash/Default-Portrait@~ipadpro.png" width="2048" />
        <splash height="2048" src="resources/ios/splash/Default-Landscape@~ipadpro.png" width="2732" />
        <splash height="1136" src="resources/ios/splash/Default-568h@2x~iphone.png" width="640" />
        <splash height="1334" src="resources/ios/splash/Default-667h.png" width="750" />
        <splash height="2208" src="resources/ios/splash/Default-736h.png" width="1242" />
        <splash height="2436" src="resources/ios/splash/Default-2436h.png" width="1125" />
        <splash height="2732" src="resources/ios/splash/Default@2x~universal~anyany.png" width="2732" />
        <icon height="57" src="resources/ios/icon/icon.png" width="57" />
        <icon height="114" src="resources/ios/icon/icon@2x.png" width="114" />
        <icon height="20" src="resources/ios/icon/icon-20.png" width="20" />
        <icon height="40" src="resources/ios/icon/icon-20@2x.png" width="40" />
        <icon height="60" src="resources/ios/icon/icon-20@3x.png" width="60" />
        <icon height="29" src="resources/ios/icon/icon-29.png" width="29" />
        <icon height="58" src="resources/ios/icon/icon-29@2x.png" width="58" />
        <icon height="87" src="resources/ios/icon/icon-29@3x.png" width="87" />
        <icon height="48" src="resources/ios/icon/icon-24@2x.png" width="48" />
        <icon height="55" src="resources/ios/icon/icon-27.5@2x.png" width="55" />
        <icon height="88" src="resources/ios/icon/icon-44@2x.png" width="88" />
        <icon height="172" src="resources/ios/icon/icon-86@2x.png" width="172" />
        <icon height="196" src="resources/ios/icon/icon-98@2x.png" width="196" />
        <icon height="216" src="resources/ios/icon/icon-108@2x.png" width="216" />
        <icon height="40" src="resources/ios/icon/icon-40.png" width="40" />
        <icon height="80" src="resources/ios/icon/icon-40@2x.png" width="80" />
        <icon height="120" src="resources/ios/icon/icon-40@3x.png" width="120" />
        <icon height="50" src="resources/ios/icon/icon-50.png" width="50" />
        <icon height="100" src="resources/ios/icon/icon-50@2x.png" width="100" />
        <icon height="60" src="resources/ios/icon/icon-60.png" width="60" />
        <icon height="120" src="resources/ios/icon/icon-60@2x.png" width="120" />
        <icon height="180" src="resources/ios/icon/icon-60@3x.png" width="180" />
        <icon height="72" src="resources/ios/icon/icon-72.png" width="72" />
        <icon height="144" src="resources/ios/icon/icon-72@2x.png" width="144" />
        <icon height="76" src="resources/ios/icon/icon-76.png" width="76" />
        <icon height="152" src="resources/ios/icon/icon-76@2x.png" width="152" />
        <icon height="167" src="resources/ios/icon/icon-83.5@2x.png" width="167" />
        <icon height="1024" src="resources/ios/icon/icon-1024.png" width="1024" />
        <icon height="57" src="resources/ios/icon/icon.png" width="57" />
        <icon height="114" src="resources/ios/icon/icon@2x.png" width="114" />
        <icon height="20" src="resources/ios/icon/icon-20.png" width="20" />
        <icon height="40" src="resources/ios/icon/icon-20@2x.png" width="40" />
        <icon height="60" src="resources/ios/icon/icon-20@3x.png" width="60" />
        <icon height="29" src="resources/ios/icon/icon-29.png" width="29" />
        <icon height="58" src="resources/ios/icon/icon-29@2x.png" width="58" />
        <icon height="87" src="resources/ios/icon/icon-29@3x.png" width="87" />
        <icon height="48" src="resources/ios/icon/icon-24@2x.png" width="48" />
        <icon height="55" src="resources/ios/icon/icon-27.5@2x.png" width="55" />
        <icon height="88" src="resources/ios/icon/icon-44@2x.png" width="88" />
        <icon height="172" src="resources/ios/icon/icon-86@2x.png" width="172" />
        <icon height="196" src="resources/ios/icon/icon-98@2x.png" width="196" />
        <icon height="216" src="resources/ios/icon/icon-108@2x.png" width="216" />
        <icon height="40" src="resources/ios/icon/icon-40.png" width="40" />
        <icon height="80" src="resources/ios/icon/icon-40@2x.png" width="80" />
        <icon height="120" src="resources/ios/icon/icon-40@3x.png" width="120" />
        <icon height="50" src="resources/ios/icon/icon-50.png" width="50" />
        <icon height="100" src="resources/ios/icon/icon-50@2x.png" width="100" />
        <icon height="60" src="resources/ios/icon/icon-60.png" width="60" />
        <icon height="120" src="resources/ios/icon/icon-60@2x.png" width="120" />
        <icon height="180" src="resources/ios/icon/icon-60@3x.png" width="180" />
        <icon height="72" src="resources/ios/icon/icon-72.png" width="72" />
        <icon height="144" src="resources/ios/icon/icon-72@2x.png" width="144" />
        <icon height="76" src="resources/ios/icon/icon-76.png" width="76" />
        <icon height="152" src="resources/ios/icon/icon-76@2x.png" width="152" />
        <icon height="167" src="resources/ios/icon/icon-83.5@2x.png" width="167" />
        <icon height="1024" src="resources/ios/icon/icon-1024.png" width="1024" />
        <splash height="1136" src="resources/ios/splash/Default-568h@2x~iphone.png" width="640" />
        <splash height="1334" src="resources/ios/splash/Default-667h.png" width="750" />
        <splash height="2688" src="resources/ios/splash/Default-2688h~iphone.png" width="1242" />
        <splash height="1242" src="resources/ios/splash/Default-Landscape-2688h~iphone.png" width="2688" />
        <splash height="1792" src="resources/ios/splash/Default-1792h~iphone.png" width="828" />
        <splash height="828" src="resources/ios/splash/Default-Landscape-1792h~iphone.png" width="1792" />
        <splash height="2436" src="resources/ios/splash/Default-2436h.png" width="1125" />
        <splash height="1125" src="resources/ios/splash/Default-Landscape-2436h.png" width="2436" />
        <splash height="2208" src="resources/ios/splash/Default-736h.png" width="1242" />
        <splash height="1242" src="resources/ios/splash/Default-Landscape-736h.png" width="2208" />
        <splash height="1536" src="resources/ios/splash/Default-Landscape@2x~ipad.png" width="2048" />
        <splash height="2048" src="resources/ios/splash/Default-Landscape@~ipadpro.png" width="2732" />
        <splash height="768" src="resources/ios/splash/Default-Landscape~ipad.png" width="1024" />
        <splash height="2048" src="resources/ios/splash/Default-Portrait@2x~ipad.png" width="1536" />
        <splash height="2732" src="resources/ios/splash/Default-Portrait@~ipadpro.png" width="2048" />
        <splash height="1024" src="resources/ios/splash/Default-Portrait~ipad.png" width="768" />
        <splash height="960" src="resources/ios/splash/Default@2x~iphone.png" width="640" />
        <splash height="480" src="resources/ios/splash/Default~iphone.png" width="320" />
        <splash height="2732" src="resources/ios/splash/Default@2x~universal~anyany.png" width="2732" />
    </platform>
    <plugin name="cordova-plugin-ionic-keyboard" spec="^2.0.5" />
    <plugin name="cordova-plugin-x-toast" spec="^2.7.2" />
    <allow-navigation href="http://localhost:8101" sessionid="d7723692" />
    <allow-navigation href="<LOCAL_IP_ADDRESS>" sessionid="c7fbd4d4" />
</widget>

    package.json:
--- Start of Cordova JSON Snippet ---
{
  "plugins": {
    "cordova-plugin-x-toast": {},
    "cordova-plugin-ionic-keyboard": {},
    "cordova-plugin-stripe": {},
    "cordova-plugin-device": {},
    "cordova-plugin-statusbar": {},
    "cordova-sqlite-storage": {},
    "cordova-plugin-file": {},
    "cordova-plugin-splashscreen": {},
    "cordova-plugin-qrscanner-11": {},
    "cordova-plugin-androidx-adapter": {},
    "cordova-plugin-photo-library-wkwebview": {
      "PHOTO_LIBRARY_USAGE_DESCRIPTION": "PERMISSION TEXT"
    },
    "cordova-clipboard": {},
    "cordova-plugin-inappbrowser": {},
    "cordova-plugin-camera": {
      "ANDROIDX_CORE_VERSION": "1.6.+"
    },
    "cordova-plugin-ionic-webview": {},
    "cordova-plugin-googlemaps": {},
    "cordova-plugin-x-socialsharing": {},
    "@havesource/cordova-plugin-push": {
      "ANDROIDX_CORE_VERSION": "1.6.+",
      "FCM_VERSION": "23.+"
    }
  },
  "platforms": [
    "browser",
    "ios"
  ]
}
--- End of Cordova JSON Snippet ---

Logs taken while reproducing problem

adb logcat output

11-04 11:44:07.485   976  1036 I ActivityManager: Start proc 2986:com.package.app/u0a3654 for broadcast {com.package.app/com.google.firebase.iid.FirebaseInstanceIdReceiver}
11-04 11:44:07.485   976  1036 D ActivityManager: [SecIpm] it's a ML_TYPE_EMPTYPROCESS protected process com.package.app
11-04 11:44:07.570  2986  2986 E USNET   : USNET: appName: com.package.app
11-04 11:44:07.584   976  4931 I ActivityManager: DSS OFF for com.package.app
11-04 11:44:07.595   976  4931 D ActivityManager: attachApplicationLocked() app=ProcessRecord{272c9db 2986:com.package.app/u0a3654} app.isolatedEntryPoint=null instr2=null
11-04 11:44:07.613  2986  2986 D ActivityThread: handleBindApplication()++ app=com.package.app
11-04 11:44:07.718  2986  2986 V GraphicsEnvironment: ANGLE Developer option for 'com.package.app' set to: 'default'
11-04 11:44:07.722  2986  2986 D LoadedApk: LoadedApk::makeApplication() appContext.mOpPackageName=com.package.app appContext.mBasePackageName=com.package.app
11-04 11:44:07.934 28220 28220 I BadgeCountReceiver: packageName: com.package.app, className: com.package.app.MainActivity, count: 1
11-04 11:44:08.008  2986  3020 E AndroidRuntime: Process: com.package.app, PID: 2986
11-04 11:44:08.020   976  4856 W ActivityManager: crash : com.package.app,13654
11-04 11:44:08.042  4859  4859 I SDHMS:BarTender:Gatherer:AppError: update AppError : uid=13654, pkg=com.package.app, errorType=crash
11-04 11:44:08.053  4859  4859 I SDHMS:BarTender:Analyzer:AppError: analyze app error : uid=13654, pkg=com.package.app, appErrorCount=4
11-04 11:44:08.137   976  4887 I ActivityManager: Process com.package.app (pid 2986) has died: picked CEM (452,2784)
@matheusssoares
Copy link

Hi I'm same problems.

@JeremyMrn
Copy link

Hello !

You probably have an error in the console.
Using "logcat" from Android Studio to check the logs when you receive a notification, on Android 12 you need to specify "FLAG_INMUTABLE" tag, I currently have the same error, but not the solution.

@mgesuitti
Copy link

@bluetech Do you have plans to upload the 4.0.0 version to NPM?

@phillipplum
Copy link

In this comment you can read how to use the current solution: #185 (comment)

@tpneumat
Copy link

tpneumat commented Dec 1, 2022

Same issue here. Android 13, targetSdkVersion 32, 4.0.0-dev.0 plugin version

@JoJo-Bear
Copy link

I was able to fix it by using targetSdkVersion 32, 4.0.0-dev.0. However it caused a crash if my push body was send. by passing "icon": "ic_launcher" it did not crash and the push also showed in the background

@giuseppelanzi
Copy link

I encounter something similar that I want to share with you.
In my case the cordova app wasn't the issue, nor the plugin. It was simply the structure of the notification sent to it.

Simply, a Message with a not null Notification object won't be notified via onMessageReceived(). In my case the solution was to change the structure of the message, putting title and body in the data object.

https://firebase.google.com/docs/cloud-messaging/android/receive?hl=en#handling_messages

Hope it helps other with the same (non)issue.

@ademir10
Copy link

https://firebase.google.com/docs/cloud-messaging/android/receive?hl=en#handling_messages

hello!
could you share your code after to make this changes?
i'm facing the same problem here, i can't receive foreground messages in Android and IOS devices.

Thanks!

@lordStrider
Copy link

Until the beginning of March I was using the @dev version and yesterday when I went to perform a build this error occurred annotation.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.7.1, expected version is 1.5.1.

@ademir10
Copy link

Until the beginning of March I was using the @dev version and yesterday when I went to perform a build this error occurred annotation.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.7.1, expected version is 1.5.1.

We had the same error here.
You need to change the kotlin version manually in one file inside your project.
When I arrive in my home I can share what I did to fix it.

@ademir10
Copy link

Até o início de março eu estava usando o@devversão e ontem quando fui realizar uma compilação ocorreu este erro annotation.kotlin_module: O módulo foi compilado com uma versão incompatível do Kotlin. A versão binária de seus metadados é 1.7.1, a versão esperada é 1.5.1.

Until the beginning of March I was using the @dev version and yesterday when I went to perform a build this error occurred annotation.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.7.1, expected version is 1.5.1.

To fix it i did exactly what you see in my attachment:
Captura de Tela 2023-03-19 às 18 42 10

You need to open the build.gradle file inside the platforms/android and change the classpath org.jetbrains.kotlin:kotlin-gradle-plugin:

Just remove the variable inside the path and let this way:
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.10"

Hope it help you! hugs.

@lordStrider
Copy link

Obrigado pela ajuda.

@kenfouo
Copy link

kenfouo commented May 18, 2023

Jusqu’au début du mois de mars, j’utilisais la version et hier, lorsque je suis allé effectuer une construction, cette erreur s’est produite annotation.kotlin_module: Le module a été compilé avec une version incompatible de Kotlin. La version binaire de ses métadonnées est 1.7.1, la version attendue est 1.5.1.

What I find out about this problem; the channels do not work on this version of the plugin:

1:- Message notifications without payload display correctly; the disadvantage is that, when clicking on this type of notification, the application opens without receiving the notification data. this is the solution proposed by @lordStrider
example:

Payload

{
"to": "'+DeviceToken+'",
"notification":{
"title":"Title",
"body":"Here Body",
"image": "https://www.furthermarket.com/Pictures/Users/User_1_Thumb4_26.jpg"
},
"data":{},
"priority":"normal"
}

Client Initialization :

const push = PushNotification.init({
android: {
},
browser: {
pushServiceURL: 'http://push.api.phonegap.com/v1/push'
},
ios: {
alert: "true",
badge: "true",
sound: "true"
},
windows: {}
});

push.on('registration', (data) => {
tokenInput.value = data.registrationId;
});

push.on('notification', (data) => {
logMsg.innerHTML += '

Notification: ' + JSON.stringify(data);
});

push.on('error', (e) => {
logMsg.innerHTML += '

Erro: ' + JSON.stringify(e);
});

2:- Message notifications with payload (on clicking on this type of notification the application opens by receiving the notification data.)

With this payload the notifications will only be displayed if we comment out the "channel_id":"Important" property afterwards, on the client side we simply initialize the plugin without creating any channel. example:

{
"to": "'+DeviceToken+'",
"data":{
"title": "Title",
"body": "Body",
"show_notification": "true",
//"android_channel_id":"Important",
"picture": "https://www.furthermarket.com/Pictures/Users/User_1_Thumb4_26.jpg"
"force-start": "1",
"style": "picture",
"notId": '+ IntToStr(Random(1000))
},
"data":{},
"priority":"normal"
}

If we add a channel in the payload or on the client, the notification will not be received if the application is killed or in the background

@lordStrider
Copy link

lordStrider commented Jun 2, 2023

@kenfouo in file config.xml add
<preference name="GradlePluginKotlinVersion" value="1.7.10" />

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

No branches or pull requests

12 participants