Closed Alireza-Ta closed 7 months ago
And this is the output of what command?
Following Android build instructions in Android README example.
When building for arm
and executing ./gradlew assembleDebug
command, it gives me following error in actual Android device:
java.lang.UnsatisfiedLinkError: Unable to load native library
"/data/app/~~3eAjrD7WdwqbBWolWZ6G8w==/com.example.android-
EHfqIoxxoNrUe8SXrq_smA==/base.apk!/lib/armeabi-v7a/libexample.so": dlopen failed: cannot locate symbol
"internal_storage_path" referenced by "/data/app/~~3eAjrD7WdwqbBWolWZ6G8w==/com.example.android-
EHfqIoxxoNrUe8SXrq_smA==/base.apk!/lib/armeabi-v7a/libexample.so"...
at android.app.NativeActivity.onCreate(NativeActivity.java:178)
at android.app.Activity.performCreate(Activity.java:8508)
at android.app.Activity.performCreate(Activity.java:8472)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1417)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3786)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3951)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:101)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2405)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loopOnce(Looper.java:211)
at android.os.Looper.loop(Looper.java:300)
at android.app.ActivityThread.main(ActivityThread.java:8152)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:580)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1028)
As you see in the error it states dlopen failed: cannot locate symbol "internal_storage_path"
.
To find where actually this undefined symbol happens, added -z,defs
flag to compile shared library command(this flag basically throws error when it hits to an undefined symbol) like so -ldflags="-s -w -extldflags=-Wl,-z,defs,-soname,libexample.so"
and it gave me the linker error in the initial post.
CC="F:/Android-SDK/ndk/25.1.8937393/toolchains/llvm/prebuilt/windows-x86_64/bin/armv7a-linux-androideabi31-clang" \
CGO_CFLAGS="-IF:/Android-SDK/ndk/25.1.8937393/toolchains/llvm/prebuilt/windows-x86_64/sysroot/usr/include -IF:/Android-SDK/ndk/25.1.8937393/toolchains/llvm/prebuilt/windows-x86_64/sysroot/usr/include/arm-linux-androideabi --sysroot=F:/Android-SDK/ndk/25.1.8937393/toolchains/llvm/prebuilt/windows-x86_64/sysroot" \
CGO_LDFLAGS="-LF:/Android-SDK/ndk/25.1.8937393/toolchains/llvm/prebuilt/windows-x86_64/sysroot/usr/lib/arm-linux-androideabi/31 -LF:/Android-SDK/ndk/25.1.8937393/toolchains/llvm/prebuilt/windows-x86_64/lib" \
GOOS=android GOARCH=arm CGO_ENABLED=1 go build -buildmode=c-shared -ldflags="-s -w -extldflags=-Wl,-soname,libexample.so" \
-o=android/libs/armeabi-v7a/libexample.so
ld: error: undefined symbol: internal_storage_path
>>> referenced by platform_android.c
>>> ..\..\..\..\AppData\Local\Temp\go-link-3058170194\000014.o:(android_init)
ld: error: undefined symbol: asset_manager
>>> referenced by platform_android.c
>>> ..\..\..\..\AppData\Local\Temp\go-link-3058170194\000014.o:(android_init)
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Thanks, now it is clear what and where the error is, with the first post nobody could guess. Can you try to build a shared library without stripping symbols, i.e., remove -s -w
from ldflags?
Still gives the same error.
This should be fixed in https://github.com/gen2brain/raylib-go/commit/069b39e6886e869cb2b1f1a8a4a7c61ceba5176f, and the example is updated.
Thank you for the quick fix!
Hi There! I'm trying to build one of official examples for Android but I'm getting following errors for both
arm
andarm64
architectures.Thanks!