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: regression error #17277

Closed
joeblew99 opened this issue Sep 29, 2016 · 7 comments

Comments

Projects
None yet
3 participants
@joeblew99
Copy link

commented Sep 29, 2016

@eliasnaur

Please answer these questions before submitting your issue. Thanks!

Hey, i hit a nasty regression bug.
It also broke the Android and IOS code too.

I fixed it by removing the offending func call. See below.
But now all the front end code is broken, and i cant work out how the android code should be :)

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

1.7.1
darwin

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

x-MacBook-Pro:mobile-sdk apple$ gomobile version
gomobile version +9640137 Tue Sep 27 16:37:51 2016 +0000 (android,ios); androidSDK=/Users/apple/Library/Android/sdk/platforms/android-24


x-MacBook-Pro:mobile-sdk apple$ go env
GOARCH="amd64"
GOBIN="/Users/apple/workspace/go/bin"
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/apple/workspace/go"
GORACE=""
GOROOT="/usr/local/go"
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64"
CC="clang"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/wp/ff6sz9qs6g71jnm12nj2kbyw0000gp/T/go-build094029375=/tmp/go-build -gno-record-gcc-switches -fno-common"
CXX="clang++"
CGO_ENABLED="1"


JAVA_HOME (exported)            /Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home                                 
ANDROID_HOME (exported)         /Users/apple/Library/Android/sdk                                                   
Android SDK Platform Tools      /Users/apple/Library/Android/sdk/platform-tools 


What did you do?

You can git clone from the tree

This code cause gomobile bind . to fail:
https://github.com/logpacker/mobile-sdk/blob/a1b9b7a16a88b53f23dfd85a66b1127d63672b66/api.go#L52

Removing just that func allows the build to work.

First potential issue i see is that this is very typical legal go code !!! Me and a ton of code sets a value on a struct via a func. Its basically a Set property accessor in the Java world if i remember correctly.
Anyway, this break this git repo, and a fair bit of other code.

Second thing, is that the code now looks very different in the Android world.
This now longer works at all.

import go.logpackermobilesdk.Logpackermobilesdk;
// ...
try {
    client = Logpackermobilesdk.NewClient("https://logpacker.mywebsite.com", "dev", android.os.Build.MODEL);

    msg = client.NewMessage();
    msg.setMessage("Crash is here!");
    // Use another optional setters for msg object

    client.Send(msg); // Send will return Cluster response
} catch (Exception e) {
    // Cannot connect to Cluster or validation error
}
@eliasnaur

This comment has been minimized.

Copy link
Contributor

commented Sep 29, 2016

You say somethings fails, but what is the error message?

If the error is an unexpected crash and you'd like me to investigate further, please try to make a stand alone reproducer I can run (with gradle). One way is to modify the gomobile "bind" example to exercise the problematic code.

@joeblew99

This comment has been minimized.

Copy link
Author

commented Sep 29, 2016

ok i will make a fork of it al for you now..

1 minute

@joeblew99

This comment has been minimized.

Copy link
Author

commented Sep 29, 2016

@eliasnaur

https://github.com/joeblew99/mobile-sdk

just gomobile build from root.

then adjust the build.gradle (Module:logpackermobilesdk)
to have the correct path to the .aar

that shoudl then build. But you wont get an .apk, because i cant work out the correct code to instantiate the code at the android level now. Things have changed a few bit it seems.

Anyway have a look

The 2nd thing i want to remind about is the OLD code regression bug

https://github.com/logpacker/mobile-sdk/blob/a1b9b7a16a88b53f23dfd85a66b1127d63672b66/api.go#L52

This used to work for gomobile, and then broke recently, and i guess it will break lots of others..

Let me knwo if i can help...

@eliasnaur

This comment has been minimized.

Copy link
Contributor

commented Sep 29, 2016

Thank you. You've provided me with an example, but not yet the error message. What is the error message you're seeing that you don't expect? You seem to mention two issues, please provide an error message for each issue.

@joeblew99

This comment has been minimized.

Copy link
Author

commented Sep 29, 2016

in android studio

on build > APK, you get error message


Information:Gradle tasks [:app:assembleDebug]
/Users/apple/workspace/go/src/github.com/logpacker/mobile-sdk/_mobile/android/md01/app/src/main/java/md01/cordova/joeblew/org/md01/MainActivity.java
Error:(54, 39) error: cannot find symbol class Client
Error:(56, 39) error: cannot find symbol class Message
Error:Execution failed for task ':app:compileDebugJavaWithJavac'.
> Compilation failed; see the compiler error output for details.
Information:BUILD FAILED
Information:Total time: 4.166 secs
Information:3 errors
Information:0 warnings
Information:See complete output in console

@eliasnaur

This comment has been minimized.

Copy link
Contributor

commented Sep 29, 2016

Those errors are caused by a recent change to gomobile that moves the generated classes out of the main package class. Replace

    Logpackermobilesdk.Client ...
    Logpackermobilesdk.Message ...

with

    Client ...
    Message ...

and remember to import go.logpackermobilesdk.Client and go.logpackermobilesdk.Message.

This is an unfortunate backwards incompatible change, but not a bug.

@joeblew99

This comment has been minimized.

Copy link
Author

commented Sep 30, 2016

thank you.. Now all works.

I prefer the new structure of the Android Java code... Its much more intuitive. big thankyou...
its pretty neat how you take golang struct, and generate all the Java Get and Set Property Accessors.

The 2nd error message was related to the first. Property Accessors in golang were clashing with the ones you generate in Java.

@joeblew99 joeblew99 closed this Sep 30, 2016

@golang golang locked and limited conversation to collaborators Sep 30, 2017

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.