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

Cannot locate symbol "JNI_OnLoad_awt" #970

Closed
mipastgt opened this issue Jul 28, 2021 · 14 comments · Fixed by #971 or #972
Closed

Cannot locate symbol "JNI_OnLoad_awt" #970

mipastgt opened this issue Jul 28, 2021 · 14 comments · Fixed by #971 or #972
Labels
android Android bug Something isn't working nosymbol Linker cannot locate symbol

Comments

@mipastgt
Copy link

mipastgt commented Jul 28, 2021

I can build my app for Android without problem on a cloud Linux server and install it on my phone locally on a Mac but when I try to run it, it immediately crashes with the following message:

07-27 18:21:47.474 27745 27745 D AndroidRuntime: Shutting down VM
07-27 18:21:47.480 27745 27745 E AndroidRuntime: FATAL EXCEPTION: main
07-27 18:21:47.480 27745 27745 E AndroidRuntime: Process: de.mpmediasoft.de.mpmediasoft.mpcopilot.main.mobile, PID: 27745
07-27 18:21:47.480 27745 27745 E AndroidRuntime: java.lang.UnsatisfiedLinkError: dlopen failed: cannot locate symbol "JNI_OnLoad_awt" referenced by "/data/app/de.mpmediasoft.de.mpmediasoft.mpcopilot.main.mobile-1w1DHRwQS_1dYQSHw19ouw==/lib/arm64/libsubstrate.so"...
07-27 18:21:47.480 27745 27745 E AndroidRuntime: 	at java.lang.Runtime.loadLibrary0(Runtime.java:1016)
07-27 18:21:47.480 27745 27745 E AndroidRuntime: 	at java.lang.System.loadLibrary(System.java:1657)
07-27 18:21:47.480 27745 27745 E AndroidRuntime: 	at com.gluonhq.helloandroid.MainActivity.surfaceCreated(MainActivity.java:104)
07-27 18:21:47.480 27745 27745 E AndroidRuntime: 	at android.view.SurfaceView.updateSurface(SurfaceView.java:753)
07-27 18:21:47.480 27745 27745 E AndroidRuntime: 	at android.view.SurfaceView$2.onPreDraw(SurfaceView.java:154)
07-27 18:21:47.480 27745 27745 E AndroidRuntime: 	at android.view.ViewTreeObserver.dispatchOnPreDraw(ViewTreeObserver.java:1045)
07-27 18:21:47.480 27745 27745 E AndroidRuntime: 	at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2808)
07-27 18:21:47.480 27745 27745 E AndroidRuntime: 	at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1780)
07-27 18:21:47.480 27745 27745 E AndroidRuntime: 	at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:7827)
07-27 18:21:47.480 27745 27745 E AndroidRuntime: 	at android.view.Choreographer$CallbackRecord.run(Choreographer.java:911)
07-27 18:21:47.480 27745 27745 E AndroidRuntime: 	at android.view.Choreographer.doCallbacks(Choreographer.java:723)
07-27 18:21:47.480 27745 27745 E AndroidRuntime: 	at android.view.Choreographer.doFrame(Choreographer.java:658)
07-27 18:21:47.480 27745 27745 E AndroidRuntime: 	at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:897)
07-27 18:21:47.480 27745 27745 E AndroidRuntime: 	at android.os.Handler.handleCallback(Handler.java:789)
07-27 18:21:47.480 27745 27745 E AndroidRuntime: 	at android.os.Handler.dispatchMessage(Handler.java:98)
07-27 18:21:47.480 27745 27745 E AndroidRuntime: 	at android.os.Looper.loop(Looper.java:164)
07-27 18:21:47.480 27745 27745 E AndroidRuntime: 	at android.app.ActivityThread.main(ActivityThread.java:6944)
07-27 18:21:47.480 27745 27745 E AndroidRuntime: 	at java.lang.reflect.Method.invoke(Native Method)
07-27 18:21:47.480 27745 27745 E AndroidRuntime: 	at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:327)
07-27 18:21:47.480 27745 27745 E AndroidRuntime: 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1374)

This looks very much like the bug reported here: oracle/graal#3406
This stops me from creating and using any Android app with JavaFX. Is there any solution or workaround for this problem?

Expected Behavior

It should run and not crash.

Current Behavior

It crashes.

Steps to Reproduce

I cannot provide a simple example myself but see link above.

Your Environment

Built on a cloud instance of Ubuntu at Hetzner with gluonfx-maven-plugin 1.0.3 and graalvm-svm-linux-gluon-21.2.0-dev. APK copied to macOS and installed via adb on a Samsung Galaxy S7.

@mipastgt mipastgt added the bug Something isn't working label Jul 28, 2021
@mipastgt
Copy link
Author

A little update:

I ran my program on desktop with the VM option -verbose:class and could not find any AWT reference in the log. So, I have no idea what triggers loading the AWT library.

I also tried the tiny reproducer here. After updating it to use the latest version of the gluonfx-maven-plugin I can confirm that it still reproduces the error.

@jperedadnr
Copy link
Contributor

jperedadnr commented Jul 29, 2021

@mipastgt Can you test if your issue gets solved with the plugin snapshot?

version: 1.0.4-SNAPSHOT
repository:

    <pluginRepositories>
        <pluginRepository>
            <id>Snapshots</id>
            <url>http://oss.sonatype.org/content/repositories/snapshots/</url>
        </pluginRepository>
    </pluginRepositories>

@mipastgt
Copy link
Author

The plugin has not yet been uploaded to https://oss.sonatype.org/content/repositories/snapshots/com/gluonhq/gluonfx-maven-plugin/
(Shouldn't it be https in your snippet above?)

@jperedadnr
Copy link
Contributor

Right, it wasn’t published yet. It is now

@mipastgt
Copy link
Author

It doesn't work yet but at least I get another error message :-( (Again AWT related.)

07-29 18:32:51.936  4847  4847 E AndroidRuntime: java.lang.UnsatisfiedLinkError: dlopen failed: cannot locate symbol "Java_java_awt_Font_initIDs" referenced by "/data/app/de.mpmediasoft.de.mpmediasoft.mpcopilot.main.mobile-uir4D9szOSEZgGTfmQVWKw==/lib/arm64/libsubstrate.so"...
07-29 18:32:51.936  4847  4847 E AndroidRuntime: 	at java.lang.Runtime.loadLibrary0(Runtime.java:1016)
07-29 18:32:51.936  4847  4847 E AndroidRuntime: 	at java.lang.System.loadLibrary(System.java:1657)
07-29 18:32:51.936  4847  4847 E AndroidRuntime: 	at com.gluonhq.helloandroid.MainActivity.surfaceCreated(MainActivity.java:104)
07-29 18:32:51.936  4847  4847 E AndroidRuntime: 	at android.view.SurfaceView.updateSurface(SurfaceView.java:753)
07-29 18:32:51.936  4847  4847 E AndroidRuntime: 	at android.view.SurfaceView$2.onPreDraw(SurfaceView.java:154)
07-29 18:32:51.936  4847  4847 E AndroidRuntime: 	at android.view.ViewTreeObserver.dispatchOnPreDraw(ViewTreeObserver.java:1045)
07-29 18:32:51.936  4847  4847 E AndroidRuntime: 	at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2808)
07-29 18:32:51.936  4847  4847 E AndroidRuntime: 	at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1780)
07-29 18:32:51.936  4847  4847 E AndroidRuntime: 	at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:7827)
07-29 18:32:51.936  4847  4847 E AndroidRuntime: 	at android.view.Choreographer$CallbackRecord.run(Choreographer.java:911)
07-29 18:32:51.936  4847  4847 E AndroidRuntime: 	at android.view.Choreographer.doCallbacks(Choreographer.java:723)
07-29 18:32:51.936  4847  4847 E AndroidRuntime: 	at android.view.Choreographer.doFrame(Choreographer.java:658)
07-29 18:32:51.936  4847  4847 E AndroidRuntime: 	at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:897)
07-29 18:32:51.936  4847  4847 E AndroidRuntime: 	at android.os.Handler.handleCallback(Handler.java:789)
07-29 18:32:51.936  4847  4847 E AndroidRuntime: 	at android.os.Handler.dispatchMessage(Handler.java:98)
07-29 18:32:51.936  4847  4847 E AndroidRuntime: 	at android.os.Looper.loop(Looper.java:164)
07-29 18:32:51.936  4847  4847 E AndroidRuntime: 	at android.app.ActivityThread.main(ActivityThread.java:6944)
07-29 18:32:51.936  4847  4847 E AndroidRuntime: 	at java.lang.reflect.Method.invoke(Native Method)
07-29 18:32:51.936  4847  4847 E AndroidRuntime: 	at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:327)
07-29 18:32:51.936  4847  4847 E AndroidRuntime: 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1374)

@jperedadnr
Copy link
Contributor

Ok, that was somehow expected.
Can you find libsubstrate.so under target/gluonfx and run and post the output of:
nm libsubstrate.so | grep -i awt

@mipastgt
Copy link
Author

Do you really mean libsubstrate.so? I only have a libmpCoPilotApp2.so in target/gluonfx/aarch64-android.
In case you mean that, the output is:

mpaus@mpMediaSoft1:~/builds/mpCoPilotApps/mpCoPilot-main-mobile/target/gluonfx/aarch64-android$ nm libmpCoPilotApp2.so | grep -i awt
0000000000133970 t AnnotatedClass_getRawType_a497ca92df89bb4ff7ceb873a75a3f0367e23d1d
0000000000136d20 t AnnotatedConstructor_getRawType_f9933e69bfc0c3ad3cfc0946bc8ec9c198ad5469
000000000013a160 t AnnotatedField_getRawType_2b12e634f940a454c8c6d1f4137925443d41238d
000000000013d1e0 t AnnotatedMethod_getRawType_07b4219dda78c41cde7880b7f21493f9eaac0ab7
000000000013f9e0 t AnnotatedParameter_getRawType_7dbf72ab19240ac3a048204c8f891c352d085c02
00000000019cb800 t AWTAccessor_<clinit>_6a5e338697a558fed00fe27e8aa4fda28011f1b4
0000000000f01f50 t AWTEvent_<clinit>_212a3b91ffab82e4af54384ede478fa1e9a479e3
0000000000f02060 t AWTKeyStroke_<clinit>_cf26f3609bd7fccaf55f7aadb736843556947447
0000000000f02200 t AWTKeyStroke_equals_829c52fcf2e3912468b493d9c7622c49987df3d5
0000000000f022f0 t AWTKeyStroke_getModifiersText_b2e02e8ee78f9c016232cdfbe46943d8fc54b865
0000000000f02520 t AWTKeyStroke_getVKText_0b1988c68b7e443257b0ac5e4548a7c5427c2888
0000000000f02e10 t AWTKeyStroke_hashCode_46cb5d8c29684392205ca95ec389d661b7c7bdb1
0000000000f02e90 t AWTKeyStroke_toString_6626a14534f1d923c30de67bbe633cda4616c6c0
0000000000da1cc0 t BaseGraphics_drawTexture_3dcf28111e283f222252efd9dcaa104cffbb7f55
0000000000da1f70 t BaseGraphics_drawTexture3SliceH_d0d86ef0205a319397a5af7766c20be5f19efbe3
0000000000da2390 t BaseGraphics_drawTexture3SliceV_5caba36c877484ca4ee6f4ee9e1b68756775d1fe
0000000000da27f0 t BaseGraphics_drawTexture9Slice_42b0f8b234fb0cb10ac3b1bd9e14b5a8c00c519e
0000000000da2ed0 t BaseGraphics_drawTextureRaw_9e1b8e79f2b4ebc609343b42e2c1c9878b084773
0000000000dd6eb0 t BaseShaderGraphics_drawTextureRaw2_f6413cbe7f75188e14515ff7f53e291e824221e4
0000000000d8a3b0 t ES2SwapChain_drawTexture_6a30e3e346790d71b50fba320c347a6ec816be27
                 U Java_java_awt_Font_initIDs
0000000000003860 T Java_java_awt_Toolkit_initIDs
00000000003dc0a0 t JNIJavaCallWrappers_jniInvoke_ARRAY:Ljava_awt_GraphicsEnvironment_2_0002eisHeadless_00028_00029Z_e522280fb24d54000d0bc746a9e4b88fba6faf73
0000000000448de0 t JNIJavaCallWrappers_jniInvoke_VA_LIST:Ljava_awt_GraphicsEnvironment_2_0002eisHeadless_00028_00029Z_95ad8e4ddc6e222c9b3031ef5ff451f93735666e
0000000000411cf0 t JNIJavaCallWrappers_jniInvoke_VARARGS:Ljava_awt_GraphicsEnvironment_2_0002eisHeadless_00028_00029Z_ff07e3eef324a147213d3ae4d9fad56148c79062
0000000000003888 T JNI_OnLoad_awt
00000000000038b0 T JNI_OnLoad_awt_headless
0000000000f25ae0 t MetaData$java_awt_AWTKeyStroke_PersistenceDelegate_instantiate_7aae4c82b0b6afdf7909dc12fd1a33a3b1586dac
0000000000f26810 t MetaData$java_awt_AWTKeyStroke_PersistenceDelegate_mutatesTo_cfb4c0c787687d752a4859a7d45db01941a17713
0000000000f26880 t MetaData$java_awt_Font_PersistenceDelegate_instantiate_cf2014cb11bc023a66a0c57fcdf9bf28c235eec0
0000000000f27710 t MetaData$java_awt_Font_PersistenceDelegate_mutatesTo_0319ad57db16d385644c05d51e8425aeff65d76f
0000000000d40ec0 t ToStream$CharacterBuffer_addRawText_4ec264625709bf96c4156b2b2bf3b913e70e924c
0000000001cdb570 t Utilities_rawToSNIHostName_a3e626874b0973477349caab1deaab81eeef1a03
00000000001601c0 t VirtualAnnotatedMember_getRawType_e25fb476c76ad3917606b874614a322a7858b356

@jperedadnr
Copy link
Contributor

Yes, that’s what I need, thanks. We need to remove that U(ndefined) symbol

@mipastgt
Copy link
Author

That's what I thought. There seems to be only this single one in there.

@jperedadnr jperedadnr mentioned this issue Jul 29, 2021
3 tasks
@jperedadnr
Copy link
Contributor

Can you try again?

@mipastgt
Copy link
Author

And again a new one:

07-29 21:49:14.298 16452 16452 D AndroidRuntime: Shutting down VM
07-29 21:49:14.300 16452 16452 E AndroidRuntime: FATAL EXCEPTION: main
07-29 21:49:14.300 16452 16452 E AndroidRuntime: Process: de.mpmediasoft.de.mpmediasoft.mpcopilot.main.mobile, PID: 16452
07-29 21:49:14.300 16452 16452 E AndroidRuntime: java.lang.UnsatisfiedLinkError: dlopen failed: cannot locate symbol "JVM_GetStackAccessControlContext" referenced by "/data/app/de.mpmediasoft.de.mpmediasoft.mpcopilot.main.mobile-inn5hLFgPt65JyYiWxe7sA==/lib/arm64/libsubstrate.so"...
07-29 21:49:14.300 16452 16452 E AndroidRuntime: 	at java.lang.Runtime.loadLibrary0(Runtime.java:1016)
07-29 21:49:14.300 16452 16452 E AndroidRuntime: 	at java.lang.System.loadLibrary(System.java:1657)
07-29 21:49:14.300 16452 16452 E AndroidRuntime: 	at com.gluonhq.helloandroid.MainActivity.surfaceCreated(MainActivity.java:104)
07-29 21:49:14.300 16452 16452 E AndroidRuntime: 	at android.view.SurfaceView.updateSurface(SurfaceView.java:753)
07-29 21:49:14.300 16452 16452 E AndroidRuntime: 	at android.view.SurfaceView$2.onPreDraw(SurfaceView.java:154)
07-29 21:49:14.300 16452 16452 E AndroidRuntime: 	at android.view.ViewTreeObserver.dispatchOnPreDraw(ViewTreeObserver.java:1045)
07-29 21:49:14.300 16452 16452 E AndroidRuntime: 	at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2808)
07-29 21:49:14.300 16452 16452 E AndroidRuntime: 	at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1780)
07-29 21:49:14.300 16452 16452 E AndroidRuntime: 	at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:7827)
07-29 21:49:14.300 16452 16452 E AndroidRuntime: 	at android.view.Choreographer$CallbackRecord.run(Choreographer.java:911)
07-29 21:49:14.300 16452 16452 E AndroidRuntime: 	at android.view.Choreographer.doCallbacks(Choreographer.java:723)
07-29 21:49:14.300 16452 16452 E AndroidRuntime: 	at android.view.Choreographer.doFrame(Choreographer.java:658)
07-29 21:49:14.300 16452 16452 E AndroidRuntime: 	at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:897)
07-29 21:49:14.300 16452 16452 E AndroidRuntime: 	at android.os.Handler.handleCallback(Handler.java:789)
07-29 21:49:14.300 16452 16452 E AndroidRuntime: 	at android.os.Handler.dispatchMessage(Handler.java:98)
07-29 21:49:14.300 16452 16452 E AndroidRuntime: 	at android.os.Looper.loop(Looper.java:164)
07-29 21:49:14.300 16452 16452 E AndroidRuntime: 	at android.app.ActivityThread.main(ActivityThread.java:6944)
07-29 21:49:14.300 16452 16452 E AndroidRuntime: 	at java.lang.reflect.Method.invoke(Native Method)
07-29 21:49:14.300 16452 16452 E AndroidRuntime: 	at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:327)
07-29 21:49:14.300 16452 16452 E AndroidRuntime: 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1374)

@mipastgt
Copy link
Author

mipastgt commented Aug 1, 2021

Should we reopen this issue so that the new problem does not get forgotten or would you rather create some new (umbrella ?) issue?

@johanvos johanvos added the nosymbol Linker cannot locate symbol label Aug 1, 2021
@johanvos
Copy link
Contributor

johanvos commented Aug 1, 2021

Probably best to open a new issue, as this is something that might happen more frequently when using new GraalVM versions.
I created a new label "nosymbol" for this that can be applied to similar issues.

@mipastgt
Copy link
Author

mipastgt commented Aug 2, 2021

@johanvos I did as you suggested but it seems only repo-owners are able to add labels. (Verified agains my own repos, where I can do that.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
android Android bug Something isn't working nosymbol Linker cannot locate symbol
Projects
None yet
3 participants