Skip to content

Conversation

pilz97
Copy link

@pilz97 pilz97 commented Aug 21, 2025

…y with Android < 15

Platforms affected

Motivation and Context

Description

Testing

Checklist

  • I've run the tests to see all new and existing tests pass
  • I added automated test coverage as appropriate for this change
  • Commit is prefixed with (platform) if this change only applies to one platform (e.g. (android))
  • If this Pull Request resolves an issue, I linked to the issue in the text above (and used the correct keyword to close issues using keywords)
  • I've updated the documentation if necessary

@codecov-commenter
Copy link

codecov-commenter commented Aug 21, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 72.24%. Comparing base (e4457f7) to head (06e5711).

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #1838   +/-   ##
=======================================
  Coverage   72.24%   72.24%           
=======================================
  Files          23       23           
  Lines        1841     1841           
=======================================
  Hits         1330     1330           
  Misses        511      511           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@breautek
Copy link
Contributor

Can you explain the rationale and what problem this is fixing?

Both APIs, removeFirst and remove(int) are supported by the Android SDK since API 1 with no deprecation notices.

@breautek breautek closed this Aug 25, 2025
@pilz97
Copy link
Author

pilz97 commented Aug 26, 2025

When i updatet to the latest Cordova-android Version + set the target SDK to 35 my app was crashing on android 11.
With this logcat:

08-21 08:23:15.231 10612 10612 E AndroidRuntime: FATAL EXCEPTION: main 08-21 08:23:15.231 10612 10612 E AndroidRuntime: Process: at.apro.bonierapp.v10, PID: 10612 08-21 08:23:15.231 10612 10612 E AndroidRuntime: java.lang.NoSuchMethodError: No static method removeFirst(Ljava/util/List;)Ljava/lang/Object; in class Lj$/util/List$-EL; or its super classes (declaration of 'j$.util.List$-EL' appears in /data/app/~~K79R36gq8NXVuwgonwlSeA==/at.apro.bonierapp.v10-vS8E1v4DRLJQqnQd6bdrBQ==/base.apk!classes19.dex) 08-21 08:23:15.231 10612 10612 E AndroidRuntime: at org.apache.cordova.NativeToJsMessageQueue.popAndEncodeAsJs(NativeToJsMessageQueue.java:197) 08-21 08:23:15.231 10612 10612 E AndroidRuntime: at org.apache.cordova.NativeToJsMessageQueue$EvalBridgeMode$1.run(NativeToJsMessageQueue.java:378) 08-21 08:23:15.231 10612 10612 E AndroidRuntime: at android.os.Handler.handleCallback(Handler.java:938) 08-21 08:23:15.231 10612 10612 E AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:99) 08-21 08:23:15.231 10612 10612 E AndroidRuntime: at android.os.Looper.loop(Looper.java:223) 08-21 08:23:15.231 10612 10612 E AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:7701) 08-21 08:23:15.231 10612 10612 E AndroidRuntime: at java.lang.reflect.Method.invoke(Native Method) 08-21 08:23:15.231 10612 10612 E AndroidRuntime: at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592) 08-21 08:23:15.231 10612 10612 E AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:952) 08-21 08:23:15.565 10896 10896 E gle.android.tt: Not starting debugger since process cannot load the jdwp agent. 08-21 08:23:15.632 1206 1241 E KernelCpuSpeedReader: Failed to read cpu-freq: /sys/devices/system/cpu/cpu4/cpufreq/stats/time_in_state: open failed: ENOENT (No such file or directory) 08-21 08:23:15.633 1206 1241 E KernelCpuSpeedReader: Failed to read cpu-freq: /sys/devices/system/cpu/cpu0/cpufreq/stats/time_in_state: open failed: ENOENT (No such file or directory) 08-21 08:23:15.645 596 603 E [email protected]: Error opening kernel wakelock stats for: wakeup48: Permission denied

with my fork everything is working again.

@breautek
Copy link
Contributor

breautek commented Aug 26, 2025

I'm keeping this closed for now, because I don't really think removing removeFirst is a real solution, even though it may solve this particular instance of the problem.

java.lang.NoSuchMethodError: No static method removeFirst(Ljava/util/List;)Ljava/lang/Object;

java.util.List.removeFirst as a static method was introduced in API 21. It's not referenced by Cordova directly, likely within the implementation of LinkedList.removeFirst instance method.

The fact that a core API 1 API is using an JDK 21 API suggest that you may have your java source/target compatibility set to 21+... or it may just be enabled due to targeting API 35, which implies a desugaring issue. In my research I couldn't really find a concrete answer.

Your android project should not be using anything higher than JDK 11, which is the default configuration the Android Studio uses when creating new android projects.

There are multiple ways to configure the source/target JDK settings:

  • AndroidJavaSourceCompatibility / AndroidJavaTargetCompatibility - These preferences are undocumented, but would be recommended to remove these preferences if they are present in your config.xml.
  • Via gradle arguments using -pJAVA_SOURCE_COMPATIBILITY / -pJAVA_TARGET_COMPATIBILITY
  • Via hooks to manually manipulate the build gradle configs.

Not to confuse Java Source & Target Compatibility settings with Android Compile & Target SDK which is something completely different.

If you can, can you confirm that your project is configured to use JDK source/target compatibility 11?

The fact that the codebase is trying to JDK 21 API is troublesome and if it's happening inside removeFirst, there may be other core APIs also using JDK 21 and thus would run into similar situation, which is why there might be a broader issue here.

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

Successfully merging this pull request may close these issues.

3 participants