golang/go

x/mobile/bind: Android app with Go library and targetSdkVersion=23 crashes on Android 6

ekrivenja opened this issue · 11 comments

I have some prototype app with Go library, built with gomobile bind command.
Until today I was building it with targetSdkVersion=22 and all worked fine, include Android 6.
Today I decided to rebuild it with targetSdkVersion=23 and got an Exception on my Nexus with Android 6:

E/AndroidRuntime: java.lang.UnsatisfiedLinkError: dlopen failed: /data/app/my.app.package/lib/arm/libgojni.so: has text relocations
E/AndroidRuntime:     at java.lang.Runtime.loadLibrary(Runtime.java:372)
E/AndroidRuntime:     at java.lang.System.loadLibrary(System.java:1076)
E/AndroidRuntime:     at go.LoadJNI.(LoadJNI.java:5)
E/AndroidRuntime:     at java.lang.Class.classForName(Native Method)
E/AndroidRuntime:     at java.lang.Class.forName(Class.java:324)
E/AndroidRuntime:     at java.lang.Class.forName(Class.java:285)
E/AndroidRuntime:     at go.Seq.(Seq.java:23)
-= skipped library calls to have it shortest=-
E/AndroidRuntime:     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
E/AndroidRuntime:     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
E/AndroidRuntime:     at java.lang.Thread.run(Thread.java:818)

I think, the problem is very similar to
http://stackoverflow.com/questions/32346402/libavcodec-so-has-text-relocations

gomobile version +83be1bf Thu Oct 8 21:24:20 2015 +0000 (android); androidSDK=C:\Android\android-sdk\platforms\android-23

In case I run same app, but built with targetSdkVersion=22, on same device, it shows me just warnings:

W/linker: /data/app/my.app.package/lib/arm/libgojni.so: is missing DT_SONAME will use basename as a replacement: "libgojni.so"
W/linker: /data/app/my.app.package/lib/arm/libgojni.so has text relocations. This is wasting memory and prevents security hardening. Please fix.

It seems it's related to #9210 which is blocked by #12581

cc @crawshaw

@ekrivenja I believe this is fixed. Could you run get -u golang.org/x/mobile/cmd/gomobile && gomobile init and rebuild? If that doesn't fix this, please reopen this issue.

gomobile version +82d11f2 Tue Oct 13 19:59:19 2015 +0000 (android); androidSDK=C:\Android\android-sdk\platforms\android-23

Sorry, but the issue is still there, same exception with targetSdkVersion=23, same warnings with with targetSdkVersion=22

@crawshaw, I cannot reopen this issue, because you closed it, I think.

reopened it.

Are you using Go tip?

What do you mean "Go tip"? I don't understand, sorry.

It means the development version which is not released yet.
What does 'go version' command say?

The fix is in the source tree now and will be officially available with 1.6.
To test the fix, you can follow the instruction here
https://golang.org/doc/install/source
And use the master branch.

@hyangah, thank you, now I understand. I thought only gomobile was fixed.
I am using Go 1.5.1 now.

 go version go1.5.1 windows/amd64 

I'll try master branch.

Master branch was used

go version devel +9358f7f Fri Oct 16 15:51:49 2015 +0000 windows/amd64 

In case of targetSdkVersion=22 I see only one warning now

W/linker: /data/app/my.app.package/lib/arm/libgojni.so: is missing DT_SONAME will use basename as a replacement: "libgojni.so"

In case of targetSdkVersion=23, no warnings, no exceptions.
It is fixed, thank you!
Closing this issue.