Open magiconair opened 6 years ago
@FlorianUekermann is there an additional prerequisite that needs to be installed for this to work?
I was able to work around this by creating a symlink in android-go/examples
as follows:
cd examples
mkdir -p llvm/prebuilt
ln -s ../../minimal/android/toolchain darwin-x86_64
It then failed with a different error when using the wrong target platform
$ ../build-android.sh
+ set -ex
+ : 27
+ : /Users/frank/Library/Android/sdk
+ : /Users/frank/android-sdk//ndk-bundle
+ export ANDROID_API ANDROID_HOME ANDROID_NDK_HOME
+ /Users/frank/Library/Android/sdk/tools/bin/sdkmanager --update
[=======================================] 100% Computing updates...
+ /Users/frank/Library/Android/sdk/tools/bin/sdkmanager ndk-bundle
[=======================================] 100% Computing updates...
+ rm -rf android/toolchain
+ /Users/frank/android-sdk//ndk-bundle/build/tools/make_standalone_toolchain.py --install-dir=android/toolchain --arch=arm --api=27 --stl=libc++
+ mkdir -p android/app/src/main/jniLibs/armeabi-v7a
+ GOOS=android
+ GOARCH=arm
+ GOARM=7
+ go get -d
+ CC=/Users/frank/src/github.com/xlab/android-go/examples/minimal/android/toolchain/bin/arm-linux-androideabi-gcc
+ CXX=/Users/frank/src/github.com/xlab/android-go/examples/minimal/android/toolchain/bin/arm-linux-androideabi-g++
+ CGO_ENABLED=1
+ CGO_CFLAGS=-march=armv7-a
+ GOOS=android
+ GOARCH=arm
+ GOARM=7
+ go build -i -buildmode=c-shared -o android/app/src/main/jniLibs/armeabi-v7a/libgomain.so
# github.com/xlab/android-go/android
cgo-gcc-prolog:2779:35: warning: 'ASensorManager_getInstance' is deprecated [-Wdeprecated-declarations]
/Users/frank/src/github.com/xlab/android-go/examples/minimal/android/toolchain/bin/../../../../llvm/prebuilt/darwin-x86_64/bin/../sysroot/usr/include/android/sensor.h:476:17: note: 'ASensorManager_getInstance' has been explicitly marked deprecated here
+ '[' -d assets ']'
+ cd android
+ ./gradlew build
Downloading https://services.gradle.org/distributions/gradle-3.3-all.zip
... lots of downloads ...
/Users/frank/Library/Android/sdk/licenses
License for package Android SDK Build-Tools 25 accepted.
Preparing "Install Android SDK Build-Tools 25 (revision: 25.0.0)".
"Install Android SDK Build-Tools 25 (revision: 25.0.0)" ready.
Finishing "Install Android SDK Build-Tools 25 (revision: 25.0.0)"
Installing Android SDK Build-Tools 25 in /Users/frank/Library/Android/sdk/build-tools/25.0.0
"Install Android SDK Build-Tools 25 (revision: 25.0.0)" complete.
"Install Android SDK Build-Tools 25 (revision: 25.0.0)" finished.
Checking the license for package Android SDK Platform 25 in /Users/frank/Library/Android/sdk/licenses
License for package Android SDK Platform 25 accepted.
Preparing "Install Android SDK Platform 25 (revision: 3)".
"Install Android SDK Platform 25 (revision: 3)" ready.
Finishing "Install Android SDK Platform 25 (revision: 3)"
Installing Android SDK Platform 25 in /Users/frank/Library/Android/sdk/platforms/android-25
"Install Android SDK Platform 25 (revision: 3)" complete.
"Install Android SDK Platform 25 (revision: 3)" finished.
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring project ':app'.
> No toolchains found in the NDK toolchains folder for ABI with prefix: mips64el-linux-android
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 5 mins 20.145 secs
This patch allowed me to create an apk file which I could install. It does not work but at least the build finishes...
$ git diff
diff --git a/examples/build-android.sh b/examples/build-android.sh
index 09744f9..9e06e31 100755
--- a/examples/build-android.sh
+++ b/examples/build-android.sh
@@ -45,4 +45,4 @@ fi
# Create apk
(cd android; ./gradlew build)
-cp android/app/build/outputs/apk/* android/
+cp android/app/build/outputs/apk/*/*.apk android/
diff --git a/examples/minimal/android/app/build.gradle b/examples/minimal/android/app/build.gradle
index f188903..293c22f 100644
--- a/examples/minimal/android/app/build.gradle
+++ b/examples/minimal/android/app/build.gradle
@@ -1,8 +1,8 @@
apply plugin: 'com.android.application'
android {
- compileSdkVersion = 25
- buildToolsVersion = '25.0.0'
+ compileSdkVersion = 27
+ buildToolsVersion = '28.0.2'
defaultConfig {
ndk {
diff --git a/examples/minimal/android/build.gradle b/examples/minimal/android/build.gradle
index c159eef..19639da 100644
--- a/examples/minimal/android/build.gradle
+++ b/examples/minimal/android/build.gradle
@@ -1,15 +1,17 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
+ google()
jcenter()
}
dependencies {
- classpath 'com.android.tools.build:gradle:2.3.0'
+ classpath 'com.android.tools.build:gradle:3.3.0-alpha12'
}
}
allprojects {
repositories {
+ google()
jcenter()
}
}
diff --git a/examples/minimal/android/gradle/wrapper/gradle-wrapper.properties b/examples/minimal/android/gradle/wrapper/gradle-wrapper.properties
index 3c9492c..a899529 100644
--- a/examples/minimal/android/gradle/wrapper/gradle-wrapper.properties
+++ b/examples/minimal/android/gradle/wrapper/gradle-wrapper.properties
@@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.1-all.zip
@magiconair sorry, I been busy the whole year and postponing the fixes for the build scripts for too long :) Thanks for sharing this issue, I'd gladly accept a PR containing the diff.
As for prebuilt toolchain, it should build fine using a call to make_standalone_toolchain.py
I never had any problems with that. Please check the ARCH of the toolchain, it can be different.
Thx!
No worries. I know what it is like. Is it still necessary to run make gen-android
in the root folder? Since that fails with
$ make gen-android
CPP="" c-for-go -ccdefs=true android.yml
processing android.yml ⠋[WARN] `cpp -dM` failed: fork/exec : no such file or directory
[ERR] /Users/frank/android-sdk/ndk-bundle/sysroot/usr/include/sys/cdefs.h:351:39: unexpected identifier a, expected one of [')', ',', ...]
gmake: *** [Makefile:6: gen-android] Error 1
after patching android.yml
as follows:
$ git diff android.yml
diff --git a/android.yml b/android.yml
index fa81fc9..84d86b8 100644
--- a/android.yml
+++ b/android.yml
@@ -36,10 +36,11 @@ PARSER:
- android
# NOTE: Replace these paths if you want to re-generate.
# NOTE: Can be processed only with -ccdefs cgogen option enabled.
- - /Users/xlab/Library/Android/sdk/ndk-bundle/toolchains/arm-linux-androideabi-4.9/prebuilt/darwin-x86_64/lib/gcc/arm-linux-androideabi/4.9.x/include
- - /Users/xlab/Library/Android/sdk/ndk-bundle/platforms/android-23/arch-arm/usr/include
- - /Users/xlab/Library/Android/sdk/ndk-bundle/platforms/android-23/arch-arm/usr/include/linux
- - /Users/xlab/Library/Android/sdk/ndk-bundle/platforms/android-23/arch-arm/usr/include/android
+ - /Users/frank/android-sdk/ndk-bundle/toolchains/arm-linux-androideabi-4.9/prebuilt/darwin-x86_64/lib/gcc/arm-linux-androideabi/4.9.x/include
+ - /Users/frank/android-sdk/ndk-bundle/sysroot/usr/include
+ - /Users/frank/android-sdk/ndk-bundle/sysroot/usr/include/android
+ - /Users/frank/android-sdk/ndk-bundle/sysroot/usr/include/linux
+ - /Users/frank/android-sdk/ndk-bundle/sysroot/usr/include/arm-linux-androideabi
SourcesPaths:
- api-level.h
@@ -57,7 +58,7 @@ PARSER:
- rect.h
- sensor.h
- storage_manager.h
- - tts.h
+ #- tts.h
- window.h
- jni.h
- android/jni_call.h
@magiconair It should not be necessary. Although if you do, specify path CPP=""
to the toolchain version of cpp via export
.
I'm a Go developer and new to Android and I'm trying to find out whether I can use android-go to build an Android Things app. I am trying to build the
minimal
example with go1.11 on macOS 10.14 (Mojave) for API version 27.I'm getting the following output. Any help is greatly appreciated :)