-
Notifications
You must be signed in to change notification settings - Fork 17.8k
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 init fails with new NDK 16.0rc #21802
Comments
After reading the documentation for unified headers, I got it working with the following diff. You'll need to make sure to diff --git a/cmd/gomobile/env.go b/cmd/gomobile/env.go
index bda72ec..9445f95 100644
--- a/cmd/gomobile/env.go
+++ b/cmd/gomobile/env.go
@@ -124,11 +124,14 @@ func envInit() (err error) {
a = "armv7a"
}
target := strings.Join([]string{a, "none", os, env}, "-")
- sysroot := filepath.Join(ndkRoot, "platforms", toolchain.platform, "arch-"+toolchain.arch)
+ androidApi := strings.TrimPrefix(toolchain.platform, "android-")
+ sysroot := filepath.Join(ndkRoot, "sysroot")
+ isystem := filepath.Join(sysroot, "usr", "include", toolchain.toolPrefix)
+ ldsysroot := filepath.Join(ndkRoot, "platforms", toolchain.platform, "arch-"+toolchain.arch)
gcctoolchain := filepath.Join(ndkRoot, "toolchains", toolchain.gcc, "prebuilt", archNDK())
- flags := fmt.Sprintf("-target %s --sysroot %s -gcc-toolchain %s", target, sysroot, gcctoolchain)
- cflags := fmt.Sprintf("%s -I%s/include", flags, gomobilepath)
- ldflags := fmt.Sprintf("%s -L%s/usr/lib -L%s/lib/%s", flags, sysroot, gomobilepath, arch)
+ flags := fmt.Sprintf("-target %s -gcc-toolchain %s", target, gcctoolchain)
+ cflags := fmt.Sprintf("%s --sysroot %s -isystem %s -D__ANDROID_API__=%s -I%s/include", flags, sysroot, isystem, androidApi, gomobilepath)
+ ldflags := fmt.Sprintf("%s --sysroot %s -L%s/lib/%s", flags, ldsysroot, gomobilepath, arch)
androidEnv[arch] = []string{
"GOOS=android",
"GOARCH=" + arch,
diff --git a/internal/mobileinit/mobileinit_android.go b/internal/mobileinit/mobileinit_android.go
index 049b18e..cd73f43 100644
--- a/internal/mobileinit/mobileinit_android.go
+++ b/internal/mobileinit/mobileinit_android.go
@@ -19,6 +19,7 @@ adb logcat GoLog:I *:S
#cgo LDFLAGS: -landroid -llog
#include <android/log.h>
+#include <stdlib.h>
#include <string.h>
*/
import "C" |
I was not able to get a successful run. Same error as @zllak. Did anyone else edit these two files and then get gomobile init to work? |
@TMSConsulting I work with @zllak, you'll need to clear your |
@steeve, thank you for your note. I got it work. Long live github! |
@eliasnaur how can we go about merging this one? not sure how to contribute |
@steeve, have you signed the CLA (https://golang.org/doc/contribute.html#cla)? If so, I'll take care of merging the patch for you. |
Signed! |
Change https://golang.org/cl/69950 mentions this issue: |
Is this released? |
@txthinking it is released, yes |
Thanks. fixed. |
@steeve i have still get this error! could you tell me how to solve this?
It was always failed, This is because i live in china,The website golang.org can not be opened;
After this i install gomobile sucessfull But when i exute
I get the error:
And you said the problem was sloved in the release version, but i still get the error! my go env as bellow:
|
@steeve I have solve the problem by using android studio update ndk version(15.2.4203891) Then clear build cache and excute gomobile init again,It works
|
Due to a change in the Android NDK (starting from r16), building the docker container fails with an error during the installation of gomobile: fatal error: 'stdlib.h' file not found This issue was addressed in more recent versions of gomobile, which are compatible with the new NDK. See golang/go#21802 This CL simply updates gomobile to the most recent commit. Change-Id: I87c468c34de441bc6acd40b717d1d950014e5a99
rm -rf $GOPATH/pkg/gomobile did not work for me with NDK 16.0.4442984 Updating did the trick. |
Due to a change in the Android NDK (starting from r16), building the docker container fails with an error during the installation of gomobile: fatal error: 'stdlib.h' file not found This issue was addressed in more recent versions of gomobile, which are compatible with the new NDK. See golang/go#21802
From r16, the legacy headers no longer ship with the NDK. Update the gomobile build system to use the unified headers instead. They're available from r14. Based on a patch by Steeve Morin. Fixes golang/go#21802 Change-Id: I098330962c737edb833e968fe82558e15837f23f Reviewed-on: https://go-review.googlesource.com/69950 Reviewed-by: David Crawshaw <crawshaw@golang.org>
From r16, the legacy headers no longer ship with the NDK. Update the gomobile build system to use the unified headers instead. They're available from r14. Based on a patch by Steeve Morin. Fixes golang/go#21802 Change-Id: I098330962c737edb833e968fe82558e15837f23f Reviewed-on: https://go-review.googlesource.com/69950 Reviewed-by: David Crawshaw <crawshaw@golang.org>
What version of Go are you using (
go version
)?go version go1.9 darwin/amd64
Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env
)?What did you do?
With the latest NDK 16.0rc,
gomobile init
fails:This is very likely due to the
Unified Headers migration
(https://android.googlesource.com/platform/ndk/+/ndk-release-r16/docs/UnifiedHeadersMigration.md).This migration removes the headers from
$ANDROID_HOME/ndk-bundle/platforms/android-XX/arch-XXX/usr/include
What did you expect to see?
A successful run of
gomobile init
What did you see instead?
The text was updated successfully, but these errors were encountered: