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

cordova-android@12 app crashing and not install issu #1619

Closed
3 tasks
hansarajgyaneswar opened this issue May 29, 2023 · 19 comments
Closed
3 tasks

cordova-android@12 app crashing and not install issu #1619

hansarajgyaneswar opened this issue May 29, 2023 · 19 comments

Comments

@hansarajgyaneswar
Copy link

IMG-20230528-WA0010
IMG-20230528-WA0009

Bug Report

Problem

What is expected to happen?

What does actually happen?

Information

Command or Code

Environment, Platform, Device

Version information

Checklist

  • I searched for existing GitHub issues
  • I updated all Cordova tooling to most recent version
  • I included all the necessary information above
@hansarajgyaneswar
Copy link
Author

Many devices opening splash screen and close

@breautek
Copy link
Contributor

Please fill out the form, and include the output of cordova plugin ls

@breautek breautek added the info-needed / awaiting response Further information is requested label May 29, 2023
@hansarajgyaneswar
Copy link
Author

cordova-plugin-admobpro 8.13.1 "AdMob Plugin Pro"
cordova-plugin-contacts-phonenumbers 0.0.12 "Contacts Phone Numbers"
cordova-plugin-device 2.1.0 "Device"
cordova-plugin-extension 1.6.0 "Cordova Plugin Extension"
cordova-plugin-geolocation 4.1.0 "Geolocation"
cordova-plugin-upi 1.0.4 "UPI"

@breautek
Copy link
Contributor

Can you explain the steps that was taken to update to cordova-android@12?

@hansarajgyaneswar
Copy link
Author

First unstall Cordova and fresh install

@hansarajgyaneswar
Copy link
Author

App working fine my emulator and my mobile. But some device app crash and not opening and installing issue

@breautek
Copy link
Contributor

That's not very descriptive. Cordova has several packages with their own version numbers.

For example there is cordova, the command line package, and then there are the platforms (e.g. cordova-android).

To use cordova-android@12, it would be recommended to use the latest CLI version, which is also 12.0.0.

npm install -g cordova@12

The cordova -v command should then print:

cordova -v
12.0.0 (cordova-lib@12.0.1)

Then to upgrade an existing project, you'll need to remove the platform and add the new version:

cordova platform remove android
cordova platform add android@12

If you're upgrading from cordova-android@9 then you should the following plugins if they are installed:

  • cordova-plugin-splashscreen
  • cordova-plugin-whitelist

If you're still having problems, then I'd try removing the plugins folder to forcefully let cordova reinstall everything from scratch:

  1. Delete the <cordova-project>/plugins directory
  2. Delete the <cordova-project>/platforms directory
  3. cordova platform add android@12

@hansarajgyaneswar
Copy link
Author

IMG-20230529-WA0007
My friend device not working

I already did above guide

@hansarajgyaneswar
Copy link
Author

/
Screenshot_2023-05-29-22-26-31-640_com example hello
My device working fine

@hansarajgyaneswar
Copy link
Author

I set also minimum sdk 21

@breautek
Copy link
Contributor

I set also minimum sdk 21

cordova-android@12 is only tested with API 24+.

IMG-20230529-WA0007 My friend device not working

I already did above guide

This looks like a native UI being produced by a plugin given that it has an action bar, which the cordova activity has disabled. The problem here appears to be in one of your installed plugins.

@hansarajgyaneswar
Copy link
Author

I did without any plugin
I make simple hello world app but same problem above screenshot attached

/
Screenshot_2023-05-29-22-26-31-640_com example hello
IMG-20230529-WA0007

@hansarajgyaneswar
Copy link
Author

FATAL EXCEPTION: main
Process: com.example.hello, PID: 4800
java.lang.NoClassDefFoundError: org.apache.cordova.PluginManager$$ExternalSyntheticLambda0
at org.apache.cordova.PluginManager.postMessage(PluginManager.java:355)
at org.apache.cordova.CordovaActivity.init(CordovaActivity.java:161)
at org.apache.cordova.CordovaActivity.loadUrl(CordovaActivity.java:234)
at com.example.hello.MainActivity.onCreate(MainActivity.java:40)
at android.app.Activity.performCreate(Activity.java:6237)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
at android.app.ActivityThread.-wrap11(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)

@hansarajgyaneswar
Copy link
Author

app not ruuning adroid 5 6 on e'4_WVGA_Nexus_S_Edited_API_23 [emulator-5554]'.

@breautek
Copy link
Contributor

I did without any plugin I make simple hello world app but same problem above screenshot attached

/ Screenshot_2023-05-29-22-26-31-640_com example hello IMG-20230529-WA0007

The first screenshot does like the cordova hello world template. The second screenshot that says "App not installed." is not something cordova produces.

app not ruuning adroid 5 6 on e'4_WVGA_Nexus_S_Edited_API_23 [emulator-5554]'.

API 23 is not supported by the cordova framework so your mileage may vary if you try to force it (by overriding the android-minSdkVersion for example). On cordova-android@12, the minimum SDK is 24. For the purposes of figuring out the issue, we should be testing no earlier than API 24 to rule out the possibility that the problem is not a problem due to using an unsupported API.

FATAL EXCEPTION: main
Process: com.example.hello, PID: 4800
java.lang.NoClassDefFoundError: org.apache.cordova.PluginManager$$ExternalSyntheticLambda0
at org.apache.cordova.PluginManager.postMessage(PluginManager.java:355)
at org.apache.cordova.CordovaActivity.init(CordovaActivity.java:161)
at org.apache.cordova.CordovaActivity.loadUrl(CordovaActivity.java:234)
at com.example.hello.MainActivity.onCreate(MainActivity.java:40)
at android.app.Activity.performCreate(Activity.java:6237)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
at android.app.ActivityThread.-wrap11(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)

I've tested the hello world app with your plugins installed. API 24 works (as in it launches without issues)
API 23 produces the above stacktrace. This is because API 23 doesn't have support for lambda functions on a collection.forEach API which the framework uses. As I mentioned before, the Cordova Framework supports API 24+. (See the PR and Mail Thread for the rationale behind bumping to API 24).

If you truly need API 23 support, you'll have to fork the cordova framework and refactor out anything that requires API 24+.

Note that I also did some testing on API 33 devices and some of your plugins doesn't appear to support API 31+ either (they require changes in their usage of PendingIntent). This includes

  1. cordova-plugin-admobpro which triggers a crash on startup because it needs to explicitly set a FLAG_MUTABLE or FLAG_IMMUTABLE on the PendingIntent it creates.
  2. cordova-plugin-upi also has the same issue on the version released to NPM, but it does appear to be fixed in their main branch.

None of the issues discovered are bugs with Cordova, so I'll be closing this issue.

@breautek breautek closed this as not planned Won't fix, can't repro, duplicate, stale May 30, 2023
@hansarajgyaneswar
Copy link
Author

Simple hello world app not installing

@hansarajgyaneswar
Copy link
Author

On Android 9

@kosbar
Copy link

kosbar commented Aug 11, 2023

But PluginManager has this code to prevent problems with Lambda (@breautek):

            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
                this.pluginMap.forEach((s, plugin) -> {
                    if (plugin != null) {
                        plugin.onMessage(id, data);
                    }
                });
            } else {
                for (CordovaPlugin plugin : this.pluginMap.values()) {
                    if (plugin != null) {
                        Object obj = plugin.onMessage(id, data);
                        if (obj != null) {
                            return obj;
                        }
                    }
                }
            }

We use cordova-android 11 with
<preference name="android-minSdkVersion" value="21" />
Some time it works on 21 API (debug version from AS) sometimes crashes (cordova build debug with signature)...

@breautek
Copy link
Contributor

But PluginManager has this code to prevent problems with Lambda (@breautek):

            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
                this.pluginMap.forEach((s, plugin) -> {
                    if (plugin != null) {
                        plugin.onMessage(id, data);
                    }
                });
            } else {
                for (CordovaPlugin plugin : this.pluginMap.values()) {
                    if (plugin != null) {
                        Object obj = plugin.onMessage(id, data);
                        if (obj != null) {
                            return obj;
                        }
                    }
                }
            }

We use cordova-android 11 with <preference name="android-minSdkVersion" value="21" /> Some time it works on 21 API (debug version from AS) sometimes crashes (cordova build debug with signature)...

cordova-android@12 has the check removed to simplify the codebase so it only has the lambda usage. Cordova-android@11 has the SDK version check to support both.

This is getting off-topic now so I'm locking the thread.

TL;DR; is don't use a minimum SDK less than 24 on cordova-android@12.

@apache apache locked as off-topic and limited conversation to collaborators Aug 14, 2023
@breautek breautek removed the info-needed / awaiting response Further information is requested label Aug 14, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants