golang / go

The Go programming language
https://go.dev
BSD 3-Clause "New" or "Revised" License
122.88k stars 17.52k forks source link

x/mobile: enable to import multiple aar files compiled by gomobile for one Android Studio project #63483

Open MrKrisYu opened 11 months ago

MrKrisYu commented 11 months ago

The goal of this issue

Intended to fix issuse #56567

What do I modify for gomobile

  1. modify mobile/bind/java/Seq.java for extracting the java dependency(common Java dependencies later used for multiple AARs);
  2. mkdir a directory named "libs" for storing common java dependencies;
  3. modify mobile/cmd/gomobile/bind_androidapp.go to not cover go module in the class.jar of the final aar file.
  4. add some descriptions for how to using the new feature.

Details

more details, please see my fork : https://github.com/MrKrisYu/mobile

dmitshur commented 11 months ago

CC @hajimehoshi.

hajimehoshi commented 11 months ago

Does iOS have the same issue?

viktorstrate commented 9 months ago

@hajimehoshi

iOS gives the following warnings but it works:

objc[16342]: Class GoSeqRef is implemented in both /private/var/containers/Bundle/Application/77FA4478-30D1-4F07-BBA9-24F0DCDBD12F/Example.app/Frameworks/GoLib.framework/GoLib (0x10708fc08) and /private/var/containers/Bundle/Application/77FA4478-30D1-4F07-BBA9-24F0DCDBD12F/Example.app/Example (0x10551fa40).
One of the two will be used. Which one is undefined.

A similar warning is printed for following classes: Universeerror, goSeqDictionary, GoSeqRef, RefCounter, RefTracker.

khayyamov commented 3 months ago

@MrKrisYu

Hey! thank you for this changes but when I completely do all steps which you are mention in your repository and run the below command it show me the error:

My last command: gomobile bind -target=android wrapTun -v

OUTPUT:
gomobile: /Users/zama/GoSdk/go1.19.2/bin/gobind -lang=go,java -outdir=/var/folders/dw/89x7xd492lz7s6v5dyhvstyh0000gn/T/gomobile-work-698989858 wrapTun -v failed: exit status 1

no exported names in the package "wrapTun" no exported names in the package "-v" no exported names in the package "wrapTun" no exported names in the package "wrapTun" no exported names in the package "wrapTun" no exported names in the package "-v" no exported names in the package "-v" no exported names in the package "-v"

musqdp commented 3 months ago

After when I tried to compile https://github.com/2dust/AndroidLibXrayLite with https://github.com/MrKrisYu/mobile I got an error message: error: package go does not exist import go.Seq;

banStayUpLate commented 2 months ago

@hajimehoshi

iOS 给出了以下警告但它可以正常工作:

objc[16342]: Class GoSeqRef is implemented in both /private/var/containers/Bundle/Application/77FA4478-30D1-4F07-BBA9-24F0DCDBD12F/Example.app/Frameworks/GoLib.framework/GoLib (0x10708fc08) and /private/var/containers/Bundle/Application/77FA4478-30D1-4F07-BBA9-24F0DCDBD12F/Example.app/Example (0x10551fa40).
One of the two will be used. Which one is undefined.

以下类会打印类似的警告:Universeerror、goSeqDictionary、GoSeqRef、RefCounter、RefTracker。

Have you solved the problem that Class GoSeqRef is implemented in both

khayyamov commented 2 months ago

banStayUpLate

https://github.com/khayyamov/mobile/tree/sagernet_editation_palestine Please see the changes in my branch. I managed to fix this issue. The app runs like a normal one, but there are still some problems. I came to the conclusion that Go Mobile has no way to manage multiple AARs.

banStayUpLate commented 2 months ago

禁止熬夜

https://github.com/khayyamov/mobile/tree/wireguardwarp 请查看我的分支中的更改。我设法修复了这个问题。应用程序运行起来像普通应用程序一样,但仍然存在一些问题。我得出的结论是 Go Mobile 无法管理多个 AAR。

I compiled the xcframework, but the Class RefTracker is implemented in both also appeared in the iOS project

khayyamov commented 2 months ago

acctually this repo is pease of shit not working at all I change in my repo alll go refs to palestine still it not work https://github.com/MrKrisYu/mobile

banStayUpLate commented 2 months ago

iOS 有同样的问题吗?

iOS also has the problem of multiple implementations of the same class:goSeqDictionary、GoSeqRef、RefCounter、RefTracker