gluonhq / gluonfx-gradle-plugin

Plugin that simplifies using Gluon Client for Java/JavaFX gradle projects
BSD 3-Clause "New" or "Revised" License
100 stars 22 forks source link

Crash Android App #158

Closed websystemtechnology closed 2 years ago

websystemtechnology commented 2 years ago

When I start my app, I get the following error and the app crashes immediately:

AndroidRuntime: FATAL EXCEPTION: main AndroidRuntime: Process: it.wstech.projecttest, PID: 30953 java.lang.NullPointerException: Attempt to invoke virtual method 'android.content.ClipData$Item android.content.ClipData.getItemAt(int)' on a null object reference at com.gluonhq.helloandroid.Util$1$1.run(Util.java:93) at android.os.Handler.handleCallback(Handler.java:938) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:236) at android.app.ActivityThread.main(ActivityThread.java:7861) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:600) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:967) ActivityTaskManager: Force finishing activity it.wstech.projecttest/com.gluonhq.helloandroid.MainActivity

I am attaching the code of the test project. project_test.zip and the apk https://drive.google.com/file/d/1MJEg5oF8e_LGY-mAjY2xx6775b9xgmyP/view?usp=sharing

Note the build.gradle and AndroidManifest.xml files mirror those of the "original" app.

jperedadnr commented 2 years ago

And does the "original" app work for you without any modification?

websystemtechnology commented 2 years ago

No, on Android neither the original app nor the test project (the attached one) work. While on ios everything is ok. If it can be useful I attach the build.gradle?

jperedadnr commented 2 years ago

default HelloFX app (or any other for that matter) works fine for me. You don't post any logs, so I can't see what is it that it is failing for you. I'd say that you are using the wrong GraalVM...

websystemtechnology commented 2 years ago

I use graalvm-svm-java17-linux-gluon-22.1.0.1-Final.tar.gz, latest version available from https://github.com/gluonhq/graal/releases. Starting the apk attached in the first comment, I get this error when there is an app crash: AndroidRuntime: FATAL EXCEPTION: main AndroidRuntime: Process: it.wstech.projecttest, PID: 30953 java.lang.NullPointerException: Attempt to invoke virtual method 'android.content.ClipData$Item android.content.ClipData.getItemAt(int)' on a null object reference at com.gluonhq.helloandroid.Util$1$1.run(Util.java:93) at android.os.Handler.handleCallback(Handler.java:938) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:236) at android.app.ActivityThread.main(ActivityThread.java:7861) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:600) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:967) ActivityTaskManager: Force finishing activity it.wstech.projecttest/com.gluonhq.helloandroid.MainActivity

As already mentioned, starting the run on desktop or ios there are no problems. The only crash is on Android.

jperedadnr commented 2 years ago

Can you attach your full logs?

websystemtechnology commented 2 years ago

In the following link the txt file with the log. In roga 560 the error reported above:

https://drive.google.com/file/d/1-JZM8Q6dI0nA558qt9wRXpBxSE_NHdU6/view?usp=sharing

jperedadnr commented 2 years ago

Ah, I see know, you are using the Attach Snapshot 4.10.15-SNAPSHOT that includes a change to sync the Clipboard. This the line that causes your crash: https://github.com/gluonhq/attach/pull/313/files#diff-c32b7ca42ea4417a085f21b36ab444fb4b88a1ff2462312110587c331a7b9564R93

It looks like it is missing a null check in data. I'll fix that in Attach. In the meantime, can you run with Attach 4.0.14?

jperedadnr commented 2 years ago

That should fix it: https://github.com/gluonhq/attach/pull/315

websystemtechnology commented 2 years ago

Ok, I ran the app with 4.0.14 and the function. I am waiting for the resolution of the bug on 4.0.15-Snapshot. Thank you

jperedadnr commented 2 years ago

Snapshot is ready, can you try again?

websystemtechnology commented 2 years ago

Ok, everything works. I close this problem. Thank you

I can ask you, if you can check issue number 156 (https://github.com/gluonhq/gluonfx-gradle-plugin/issues/156)