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

x/mobile: support multiple independent bindings in the same app #15956

Open
yancheng199287 opened this Issue Jun 4, 2016 · 13 comments

Comments

Projects
None yet
10 participants
@yancheng199287

yancheng199287 commented Jun 4, 2016

Please answer these questions before submitting your issue. Thanks!

  1. What version of Go are you using (go version)?
    1.5
  2. What operating system and processor architecture are you using (go env)?
    windows amd64
  3. What did you do?
    I make arr module by use gomobile bind common, but I have two different package hello and halou,so I do this:

as follow
gomobile bind -target=android golang.org/x/mobile/example/bind/hello

gomobile bind -target=android golang.org/x/mobile/example/bind/halou

I get two aar module,then import them by android studio ,

when I build apk,happen erro messsage

Error:Error converting bytecode to dex:
Cause: com.android.dex.DexException: Multiple dex files define Lgo/LoadJNI;
:app:transformClassesWithDexForDebug FAILED
Error:Execution failed for task ':app:transformClassesWithDexForDebug'.

com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'D:\jdk\bin\java.exe'' finished with non-zero exit value 2

I know resason that two arr include two jar file,but them have same LoadJNI.class and Seq.class,

so conflict!

I want to know that how to resolve it by good way?

@yancheng199287

This comment has been minimized.

yancheng199287 commented Jun 4, 2016

when I delete one of them arr module,I build apk successful!

@yancheng199287

This comment has been minimized.

yancheng199287 commented Jun 4, 2016

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ':app:transformNative_libsWithMergeJniLibsForDebug'.

    com.android.build.api.transform.TransformException: com.android.builder.packaging.DuplicateFileException: Duplicate files copied in APK lib/x86/libgojni.so
    File1: D:\golang\gopath\src\golang.org\x\mobile\example\bind\android\app\build\intermediates\exploded-aar\android\mygo\unspecified\jni
    File2: D:\golang\gopath\src\golang.org\x\mobile\example\bind\android\app\build\intermediates\exploded-aar\android\hello\unspecified\jni

@yancheng199287

This comment has been minimized.

yancheng199287 commented Jun 4, 2016

can not use more aar !!!!

@yancheng199287

This comment has been minimized.

yancheng199287 commented Jun 4, 2016

oh my god,very boring

@adg adg changed the title from use gomobile bind make aar to my android project,happend jar conflict to x/mobile: use gomobile bind make aar to my android project, jar conflict Jun 6, 2016

@adg adg added this to the Unplanned milestone Jun 6, 2016

@joeblew99

This comment has been minimized.

joeblew99 commented Sep 28, 2016

got the identical thing today.

enabling MultDex is possible apparently as fix in Android Studio. But dont knwo too much.
I just removed one of the Dependencies and it got rid of the error.

I wonder if devs really need more than one golang dependency in their Android apps ?

@gopherbot gopherbot added the mobile label Jul 20, 2017

@MahmoudB

This comment has been minimized.

MahmoudB commented Aug 30, 2017

Hello, I got the same issue using two go packages that translates into two android modules, but the go directory in the .aar files are identical. Using multidex didn't cut it for me, because I ended up with following error:

Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'.
> com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: go/LoadJNI.class

I tried to exclude the LoadJNI.class from one of the dependencies using gradle without luck :/

Any ideas?

@hyangah

This comment has been minimized.

Contributor

hyangah commented Aug 30, 2017

Is it not a possibility to merge them to one go package and deal with only one .aar?

@eliasnaur

This comment has been minimized.

Contributor

eliasnaur commented Mar 16, 2018

Gomobile doesn't support multiple independent instances in the same app. As @hyangah points out, list multiple packages to gomobile bind or in the "pkg" setting for the gobind gradle plugin. Gomobile will then build one set of bindings covering all the packages list.

@eliasnaur eliasnaur changed the title from x/mobile: use gomobile bind make aar to my android project, jar conflict to x/mobile: support multiple independent bindings in the same app Mar 16, 2018

@pjdufour

This comment has been minimized.

pjdufour commented Jul 2, 2018

This would be nice. Not a great developer experience for Java developers to have to learn Go building tools just 2 use more than 1 go library in their apps. I'd expect to see meteoric growth in the use of Go on Android if this is fixed.

@dinuchiriac

This comment has been minimized.

dinuchiriac commented Sep 13, 2018

Is this going to be fixed anytime soon? This is a really big blocker as the number of go-mobile libraries is growing and it is going to create a lot of compatibility issues in the feature.

@eliasnaur

This comment has been minimized.

Contributor

eliasnaur commented Sep 13, 2018

I don't have plans to work on it, sorry.

@nobeginning

This comment has been minimized.

nobeginning commented Oct 26, 2018

I got the same problem on Android(The two aar supported by different team).

First, I think it is just the problem of .so conflict. So, I modify the source of go-mobile and changed the name of .so just like "libgojniX.so".

Then I got another problem: "duplicate class go.Seq".

Continue to modify the source of go-mobile, change the default package "go" to "go.xxx". Then I got the class go.xxx.Seq.

Import the new aar to the project, It was compiled successfully.

But, when I run the app. It throws some go-runtime error:

2018-10-26 13:44:12.902 26549-0/? E/Go: fatal error: runtime: cannot reserve arena virtual address space
2018-10-26 13:44:12.902 26549-0/? E/Go: runtime: panic before malloc heap initialized
2018-10-26 13:44:12.902 26549-26570/? E/GoLog: fatal error: runtime: cannot reserve arena virtual address space
2018-10-26 13:44:12.902 26549-26570/? E/GoLog: runtime: panic before malloc heap initialized
2018-10-26 13:44:12.904 26549-0/? E/Go: runtime stack:
2018-10-26 13:44:12.904 26549-26570/? E/GoLog: runtime stack:
2018-10-26 13:44:12.904 26549-0/? E/Go: runtime.throw(0x71bbc3a33c, 0x33)
2018-10-26 13:44:12.904 26549-26570/? E/GoLog: runtime.throw(0x71bbc3a33c, 0x33)
2018-10-26 13:44:12.904 26549-0/? E/Go: 	/usr/local/go/src/runtime/panic.go:605 +0x70 fp=0x71bb8c6390 sp=0x71bb8c6370 pc=0x71bba2fd40
2018-10-26 13:44:12.904 26549-0/? E/Go: runtime.mallocinit()
2018-10-26 13:44:12.904 26549-26570/? E/GoLog: 	/usr/local/go/src/runtime/panic.go:605 +0x70 fp=0x71bb8c6390 sp=0x71bb8c6370 pc=0x71bba2fd40
2018-10-26 13:44:12.904 26549-26570/? E/GoLog: runtime.mallocinit()
2018-10-26 13:44:12.904 26549-0/? E/Go: 	/usr/local/go/src/runtime/malloc.go:360 +0x368 fp=0x71bb8c6430 sp=0x71bb8c6390 pc=0x71bba16248
2018-10-26 13:44:12.904 26549-26570/? E/GoLog: 	/usr/local/go/src/runtime/malloc.go:360 +0x368 fp=0x71bb8c6430 sp=0x71bb8c6390 pc=0x71bba16248
2018-10-26 13:44:12.904 26549-0/? E/Go: runtime.schedinit()
2018-10-26 13:44:12.904 26549-26570/? E/GoLog: runtime.schedinit()
2018-10-26 13:44:12.904 26549-0/? E/Go: 	/usr/local/go/src/runtime/proc.go:481 +0x38 fp=0x71bb8c6470 sp=0x71bb8c6430 pc=0x71bba322a8
2018-10-26 13:44:12.904 26549-26570/? E/GoLog: 	/usr/local/go/src/runtime/proc.go:481 +0x38 fp=0x71bb8c6470 sp=0x71bb8c6430 pc=0x71bba322a8
2018-10-26 13:44:12.904 26549-0/? E/Go: runtime.rt0_go(0x0, 0x71bb8c64e0, 0x7255aa63c0, 0x7259662548, 0x0, 0x72596625e0, 0x72596625f0, 0x0, 0x0, 0x71bc0114f0, ...)
2018-10-26 13:44:12.904 26549-26570/? E/GoLog: runtime.rt0_go(0x0, 0x71bb8c64e0, 0x7255aa63c0, 0x7259662548, 0x0, 0x72596625e0, 0x72596625f0, 0x0, 0x0, 0x71bc0114f0, ...)
2018-10-26 13:44:12.904 26549-0/? E/Go: 	/usr/local/go/src/runtime/asm_arm64.s:70 +0xbc fp=0x71bb8c64a0 sp=0x71bb8c6470 pc=0x71bba56b7c
2018-10-26 13:44:12.904 26549-26570/? E/GoLog: 	/usr/local/go/src/runtime/asm_arm64.s:70 +0xbc fp=0x71bb8c64a0 sp=0x71bb8c6470 pc=0x71bba56b7c

Is there any way to decouple them(go-runtime&logic.so)?
I don't know how to fix it. Need Help!

@eliasnaur

This comment has been minimized.

Contributor

eliasnaur commented Oct 26, 2018

There is no easy fix for two instances of the Go runtime in one process. Even if you could get it to work it would be wasteful.

Why not build the two projects together into one aar?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment