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

x/mobile: flutter' app crash met with gomobile package .aar #24468

Closed
hjlp20150803 opened this issue Mar 21, 2018 · 12 comments

Comments

Projects
None yet
5 participants
@hjlp20150803
Copy link

commented Mar 21, 2018

Please answer these questions before submitting your issue. Thanks!

What version of Go are you using (go version)?

go version go1.10 darwin/amd64

Does this issue reproduce with the latest release?

yes

What operating system and processor architecture are you using (go env)?

GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"

What did you do?

I test .aar by:
gomobile bind -target=android
put into Android studio project's libs, and test the package.

When I test with android's app alone, it works; when I test with the flutter app platform channel alone, it works too.When I put them together, when the call happened, it crashed.

It looks like the 2 bridge there and they are not match.I don't know which team in google would answer me, flutter or golang,gomobile?

If possible, provide a recipe for reproducing the error.
A complete runnable program is good.
A link on play.golang.org is best.

What did you expect to see?

What did you see instead?

flutter' app crash met with gomobile package .aar

  1. I follow the guidence https://flutter.io/platform-channels/ ... It works; I can see the result in Simulator.

  2. I write a simple code in Golang, Gomobile bind -target=android, get .aar file, put into libs, the app stopped when the call happened. The code is very simple:

package bond

import (

)

func FirstCall() int{
return 20180311
}

func SecondCall() string{
return "20180311"
}

func ThirdCall() {
}

type Counter struct {
Value int
}

func (c *Counter) Inc() { c.Value++ }

func NewCounter() *Counter { return &Counter{ 5 } }
3) I create app with Android Studio, put the .aar file in, and call, it gets the right return.

final String stext=Bond.secondCall();
4) So the problem is, there are 2 bridges here; each of them work, but put together, it crashes.

Anybody could give me a solution? Is the problem in Flutter or Gomobile?

@gopherbot gopherbot added this to the Unreleased milestone Mar 21, 2018

@gopherbot gopherbot added the mobile label Mar 21, 2018

@bcmills

This comment has been minimized.

Copy link
Member

commented Mar 22, 2018

Is the problem in Flutter or Gomobile?

If you're not sure whether it's a Flutter issue or a Go one, please start at the
golang-nuts mailing list.

(You'll reach a broader audience there, and we don't use the Go issue tracker for general questions.)

@bcmills bcmills closed this Mar 22, 2018

@hjlp20150803

This comment has been minimized.

Copy link
Author

commented Mar 22, 2018

I asked on golang-nuts(https://groups.google.com/forum/#!forum/golang-nuts),but got no reply, what can I do next? Flutter is good,gomobile is good, but not work when put them together

@bcmills

This comment has been minimized.

Copy link
Member

commented Mar 23, 2018

I see instructions for using Flutter with various languages, but not Go. I suspect it's not a configuration they support.

(See flutter/flutter#14816.)

@gedw99

This comment has been minimized.

Copy link

commented Apr 10, 2018

@hjlp20150803 can you put the project on github as its too tricky to help without the full project.
Then i will take a look.

i have done this using protobuf as the type being shared between golang and flutter

@hjlp20150803

This comment has been minimized.

Copy link
Author

commented Apr 24, 2018

Sorry I just saw the response, thanks for your reply.
I have solved the problem.The whole project is too big to upload, flutter side are huge.
I have report this in other place, so I write it again here:
I found the reason. First time I saw the '20180311' came out from screen,'20180311' is the response from gomobile package bond.aar.
"gomobile bind -target=android",this is what I built the bond.aar, and my 'flutter doctor -v' was:
"[✓] Connected devices (1 available)
• Android SDK built for x86 • emulator-5554 • android-x86 • Android 8.1.0 (API 27) (emulator)"
This is x86 type, so I change the gomobile to
"gomobile bind -target=android/x86"
and then put .aar into lib again, then it works.
I can't explain why they work independently, when the java program of android works and flutter project failed, but I solved the problem. In this period I really want to switch to other tools ,react native, Xamarin. "

@gedw99

This comment has been minimized.

Copy link

commented Apr 24, 2018

It does not make sense though.
I build golong and flutter.

A standard flutter app compiled is only 8 mb to start.
The golang part of it it not much.

I think you need to understand that with react and xamamin you will have much bigger issues with integration. Much bigger...

@hjlp20150803

This comment has been minimized.

Copy link
Author

commented Apr 24, 2018

I don't think the executed file is enough, you need to know how I config,mainfest,..,. I have tried before, just now I checked it again, the whole directory is more than 100M. And I haven't done anything else except inject the .aar file. In one word that is :"In a terminal run: flutter create batterylevel"(https://flutter.io/platform-channels/), and drag the .aar file into lib. So I hope you could repeat my experience as I met.
And in golang side, I put the source out there, and I told you the way I build.

I don't know why you think it does not make sense, I can't find reason but I temporarily fixed the crash, if you can I hope you do it as do exactly, that is simple than I upload the project.

Correct one thing, instruction should be:
gomobile bind -target=android/386
not
gomobile bind -target=android/x86

@gedw99

This comment has been minimized.

Copy link

commented Apr 24, 2018

@hjlp20150803

This comment has been minimized.

Copy link
Author

commented Apr 25, 2018

I put this issue aside for a while, and today I tried the project, I can't repeat the crash again!
I do remember it must be crashed, I tried again and again, it can't work or can work, but not crash.
I reserved the old project in zip file and the date was last month, it was 151.7 MB and I couldn't upload that time, so this must be.
I update the config, change the program, and it works no matter whether android with or without 386, other different is emulator.
But the whole thing is really different, you can see the post :flutter/flutter#15781 (comment)

The project is huge for "blender/build/app/intermediates",and the .apk. I delete them,you can take a look.
blender.zip

@gedw99

This comment has been minimized.

Copy link

commented Apr 25, 2018

@hjlp20150803

The zip is just a normal flutter project. thats not going to help:)

Just put up a github repo with the code and a makefile if you want help.

@hjlp20150803

This comment has been minimized.

Copy link
Author

commented Apr 25, 2018

I haven't done anything more than that and I have give all the file I can give, I really don't understand what you expect, I am a fresh of flutter.
I just followed the guidance of flutter's channel to communicate with golang part, but it crashed all the time, I have no any makefile.
And now it disappeared, I don't know why, and zip file is the old state. Flutter is upgraded, emulator is new version, I can't try all the options.
I hope maybe you could find out why it crashed through the zip. Right now I can carry on my job , no crash anymore.
Thanks a lot for your help and faith on flutter.

If you mean the makefile for golang? no , there are no, the code is very simple, with
gomobile bind -target=android

package bond

import (

)

func FirstCall() int{
return 20180311
}

func SecondCall() string{
return "20180311"
}

func ThirdCall() {
}

type Counter struct {
Value int
}

@chaim1986

This comment has been minimized.

Copy link

commented May 3, 2018

@gedw99
I find this bug must happen to a android 7.x x86 simulator (both API 24 and API 25 will crash),

I upload a project here , can you have a look and help to fix it.... Thanks..

https://github.com/chaim1986/flutter-go

bug similar :
https://stackoverflow.com/questions/44080809/android-7-native-crash-libc-so-tgkill

@golang golang locked and limited conversation to collaborators May 3, 2019

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
You can’t perform that action at this time.