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: Android gobindPlugin doesn't package *.so into the apk for the very first build #23766
Comments
cc @hyangah |
Sorry that I don't have time to look into this issue for now. I am guessing the plugin needs additional checks or dependency specification. Contribution is really welcome. Once it's fixed, I will happily build and upload a new version. |
Hey hana, please look into it when you get time https://go-review.googlesource.com/c/mobile/+/94835 :) |
Change https://golang.org/cl/94835 mentions this issue: |
0.2.11 is out. |
Thanks a lot @hyangah 👍:) |
Thank you for actually fixing it @vickyramachandra |
…ation When there is no prior gradle cache (i.e .gradle/ directory isn't created yet) in your Android project and a gradle build command is executed (e.g ./gradlew build), the *.so files generated by the gobind android plugin is not packaged into the apk. Successive builds work fine though. This issue doesn't happen when using Android plugin version 2.x, but does using version 3.x. The gomobile bind task, libTask, is only finalizing the java compile task which allows it to run in parallel with javaCompile. That is probably too late, so instead, make libTask a dependency of the compile task to make sure the output of gomobile bind (in particular, the *so libraries) are included in the final build product. Fixes golang/go#23766 Change-Id: I62727bfa0ffd54d8158c3a2aa3d7303867fcbabc Reviewed-on: https://go-review.googlesource.com/94835 Reviewed-by: Elias Naur <elias.naur@gmail.com>
…ation When there is no prior gradle cache (i.e .gradle/ directory isn't created yet) in your Android project and a gradle build command is executed (e.g ./gradlew build), the *.so files generated by the gobind android plugin is not packaged into the apk. Successive builds work fine though. This issue doesn't happen when using Android plugin version 2.x, but does using version 3.x. The gomobile bind task, libTask, is only finalizing the java compile task which allows it to run in parallel with javaCompile. That is probably too late, so instead, make libTask a dependency of the compile task to make sure the output of gomobile bind (in particular, the *so libraries) are included in the final build product. Fixes golang/go#23766 Change-Id: I62727bfa0ffd54d8158c3a2aa3d7303867fcbabc Reviewed-on: https://go-review.googlesource.com/94835 Reviewed-by: Elias Naur <elias.naur@gmail.com>
What version of Go are you using (
go version
)?go1.8.1 darwin/amd64
Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env
)?GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/user/goprojects"
GORACE=""
GOROOT="/usr/local/go"
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64"
GCCGO="gccgo"
CC="clang"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/y8/ylh63k1106ldg8t7q3jrl701s3tf0r/T/go-build239147691=/tmp/go-build -gno-record-gcc-switches -fno-common"
CXX="clang++"
CGO_ENABLED="1"
PKG_CONFIG="pkg-config"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
What did you do?
Gradle version - 4.5.1
Android plugin version - 3.0.1
I am using the android plugin gobindPlugin 0.2.10 to build my go source files and include them into the android app. I use the gradle wrapper to execute the gradle commands. When i execute one of the gradle build commands (eg ./gradlew build) for the very first time (i.e there is no prior gradle cache present -> .gradle/ folder isn't generated yet), i could see that the native files *.so isn't packaged into my final apk. Hence when i run the app, finding the go methods fails, resulting in UnsatisfiedLinkError. However it is included in the successive builds (i.e when the gradle cache is once created). Also if i don't use the gobindPlugin and prebuild my go source files as .aar using the gomobile bind command and place them into the libs folder under the android app and include them as compile dependencies in my gradle script, the *.so files are correctly packaged.
P.S - Make sure that app/build and app/src/main/jniLibs and .gradle/ directories aren't present inside the android project before any of the gradle commands are executed
What did you expect to see?
The native *.so packaged in my apk
What did you see instead?
Native files are missing in the apk
The text was updated successfully, but these errors were encountered: