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: gomobile bind fails for Android targets. It cant find the javac that Android Studio has already installed #33220

Open
joeblew99 opened this issue Jul 22, 2019 · 2 comments

Comments

@joeblew99
Copy link

commented Jul 22, 2019

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

go version go1.12.7 darwin/amd64

Does this issue reproduce with the latest release?

YES

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

go env Output
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/apple/Library/Caches/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/apple/workspace/go"
GOPROXY=""
GORACE=""
GOROOT="/usr/local/opt/go/libexec"
GOTMPDIR=""
GOTOOLDIR="/usr/local/opt/go/libexec/pkg/tool/darwin_amd64"
GCCGO="gccgo"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/wp/ff6sz9qs6g71jnm12nj2kbyw0000gp/T/go-build261080551=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

FULLY REPRODUCIBLE HERE:
0. Setup env your mac.

a. Manually install Android studio
https://developer.android.com/studio/install

b. .bash_profile:

### Java
# We use the java installed with Android Studio because it seems to work best with everything else.
export JAVA_HOME="/Applications/Android\ Studio.app/Contents/jre/jdk/Contents/Home"
export PATH=$PATH:$JAVA_HOME/bin
export ANDROID_SDK=/Users/apple/Library/Android/sdk

# For Gomobile.
export ANDROID_HOME=$ANDROID_SDK 

export ANDROID_NDK=$ANDROID_SDK/ndk-bundle
export ANDROID_PLATFORM_TOOLS=$ANDROID_SDK/platform-tools
export ANDROID_TOOLS=$ANDROID_SDK/tools


  1. git clone: gitlab.com/vocdoni/go-dvote-mobile
  2. make init. Will install gomobile.
  3. make android. Will kick of build

What did you expect to see?

compile the android

What did you see instead?


Cleaning ./build
Compiling Android
runtime/cgo
golang.org/x/mobile/internal/mobileinit
github.com/ethereum/go-ethereum/crypto/secp256k1
golang.org/x/mobile/bind/java
gobind
runtime/cgo
golang.org/x/mobile/internal/mobileinit
github.com/ethereum/go-ethereum/crypto/secp256k1
golang.org/x/mobile/bind/java
gobind
runtime/cgo
github.com/ethereum/go-ethereum/crypto/secp256k1
golang.org/x/mobile/internal/mobileinit
golang.org/x/mobile/bind/java
gobind
runtime/cgo
golang.org/x/mobile/internal/mobileinit
github.com/ethereum/go-ethereum/crypto/secp256k1
golang.org/x/mobile/bind/java
gobind
aar: AndroidManifest.xml
aar: proguard.txt
aar: classes.jar
No Java runtime present, requesting install.
gomobile: javac -d /var/folders/wp/ff6sz9qs6g71jnm12nj2kbyw0000gp/T/gomobile-work-007545878/javac-output -source 1.7 -target 1.7 -bootclasspath /Users/apple/Library/Android/sdk/platforms/android-28/android.jar dvotemobile/Dvotemobile.java go/Seq.java go/Universe.java go/error.java failed: exit status 1

make[1]: *** [android] Error 1
make: *** [go-build-and] Error 2

Things i tried that dont work:
repoint the sym link of /usr/bin/javac to where android studio puts javac

  • cant do this because with latest MAC you can change these files even is you sudo. Apple did this to stop malware.

@gopherbot gopherbot added this to the Unreleased milestone Jul 22, 2019

@gopherbot gopherbot added the mobile label Jul 22, 2019

@joeblew99 joeblew99 changed the title x/mobile: gomobile bind fails for Android targets. It cant find the javac. x/mobile: gomobile bind fails for Android targets. It cant find the javac that Android Studio has already installed Jul 22, 2019

@joeblew99

This comment has been minimized.

Copy link
Author

commented Jul 22, 2019

Fixed:

brew cask install adoptopenjdk

Now i get:

make android
Cleaning ./build
Compiling Android
runtime/cgo
golang.org/x/mobile/internal/mobileinit
github.com/ethereum/go-ethereum/crypto/secp256k1
golang.org/x/mobile/bind/java
gobind
runtime/cgo
golang.org/x/mobile/internal/mobileinit
github.com/ethereum/go-ethereum/crypto/secp256k1
golang.org/x/mobile/bind/java
gobind
runtime/cgo
golang.org/x/mobile/internal/mobileinit
github.com/ethereum/go-ethereum/crypto/secp256k1
golang.org/x/mobile/bind/java
gobind
runtime/cgo
golang.org/x/mobile/internal/mobileinit
github.com/ethereum/go-ethereum/crypto/secp256k1
golang.org/x/mobile/bind/java
gobind
aar: AndroidManifest.xml
aar: proguard.txt
aar: classes.jar
warning: [options] source value 7 is obsolete and will be removed in a future release
warning: [options] target value 7 is obsolete and will be removed in a future release
warning: [options] To suppress warnings about obsolete options, use -Xlint:-options.
3 warnings
jar: META-INF/MANIFEST.MF
jar: dvotemobile/Dvotemobile.class
jar: go/Seq$GoObject.class
jar: go/Seq$GoRef.class
jar: go/Seq$GoRefQueue$1.class
jar: go/Seq$GoRefQueue.class
jar: go/Seq$Proxy.class
jar: go/Seq$Ref.class
jar: go/Seq$RefMap.class
jar: go/Seq$RefTracker.class
jar: go/Seq.class
jar: go/Universe$proxyerror.class
jar: go/Universe.class
jar: go/error.class
aar: jni/armeabi-v7a/libgojni.so
aar: jni/arm64-v8a/libgojni.so
aar: jni/x86/libgojni.so
aar: jni/x86_64/libgojni.so
aar: R.txt
aar: res/
jar: META-INF/MANIFEST.MF
jar: dvotemobile/Dvotemobile.java
jar: go/Seq.java
jar: go/Universe.java
jar: go/error.java
Generated:
./build/dvotemobile-sources.jar ./build/dvotemobile.aar

@katiehockman

This comment has been minimized.

Copy link
Contributor

commented Jul 29, 2019

@joeblew99 is there anything action that you think should be taken with this issue, or can it be closed?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.