codenameone / CodenameOne

Cross-platform framework for building truly native mobile apps with Java or Kotlin. Write Once Run Anywhere support for iOS, Android, Desktop & Web.

Home Page:https://www.codenameone.com/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

App crash since manifest support of Android 12

kutoman opened this issue · comments

Describe the bug
CN1 seems to use deprecated Android API which isn't supported on Android 12 anymore

To Reproduce
Steps to reproduce the behavior:
Just check the specific line of the AndroidLocationManager mentioned in the stacktrace

Expected behavior
No crash

Smartphone (please complete the following information):

  • Device: Emulator
  • OS: Android 12

Additional context

2022-12-25 14:56:16.217 2188-2188/org.igmg.android E/AndroidRuntime: FATAL EXCEPTION: main
    Process: org.igmg.android, PID: 2188
    java.lang.UnsupportedOperationException: GpsStatus APIs not supported, please use GnssStatus APIs instead
        at android.location.LocationManager.addGpsStatusListener(LocationManager.java:2344)
        at com.codename1.location.AndroidLocationManager$2.run(AndroidLocationManager.java:150)
        at android.os.Handler.handleCallback(Handler.java:938)
        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:7839)
        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:1003)

hmm weird. Actually I was surprised that it wasn't fixed yet supposedly. I did update CN1 via the maven command "Update Codename One" and then rebuilt the gradle build. Do I have to do anything else? It's been a while I last touched this project..

the pom props after the CN1 update:

  <properties>
    <java.version>1.8</java.version>
    <cn1app.name>app</cn1app.name>
    <maven-compiler-plugin.version>3.8.0</maven-compiler-plugin.version>
    <rhino.version>1.7.11</rhino.version>
    <cn1.plugin.version>7.0.95</cn1.plugin.version>
    <maven.compiler.target>1.8</maven.compiler.target>
    <java-tests.version>11</java-tests.version>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <cn1.version>7.0.95</cn1.version>
    <maven.compiler.source>1.8</maven.compiler.source>
  </properties>

Do I have to do anything else?

yes indeed... I noticed that the gradle project was not regenerated due to:

[INFO] Android gradle project already exists.  Checking to see if it needs updating...
[INFO] Sources have not changed.  Skipping android gradle project generation
[INFO] Trying to open project in Android studio

therefore I forcefully had to make at least one modification to my code in order to force a regeneration, even though imho the recent CN1 update (prior to the "Gradle Android Project" command) should be sufficient at least to sync the CN1 libs when trying to regenerate the gradle project.