Android improvements (#105)

* Improve the android demo project

* Install missing toolchain for the Android action

* Improve Android NDK installation docs

Co-authored-by: Maximilian Ammann <max@maxammann.org>
This commit is contained in:
Antoine Drabble 2022-06-11 23:08:10 +02:00 committed by GitHub
parent 70cf25e0c1
commit 172d64f1b3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 11 additions and 27 deletions

View File

@ -8,7 +8,7 @@ android {
defaultConfig {
applicationId "com.example.demo"
minSdk 30
minSdk 21
targetSdk 31
versionCode 1
versionName "1.0"
@ -17,7 +17,7 @@ android {
ndk {
// Specifies the ABI configurations of your native
// libraries Gradle should build and package with your app.
abiFilters 'x86_64', 'arm64-v8a'
abiFilters 'x86_64', 'x86', 'arm64-v8a'
}
}

View File

@ -1,5 +1,5 @@
plugins {
id 'org.mozilla.rust-android-gradle.rust-android' version '0.9.2' apply true
id 'org.mozilla.rust-android-gradle.rust-android' version '0.9.3' apply true
id 'com.android.library' version '7.0.4' apply true
id 'org.jetbrains.kotlin.android' version '1.6.21' apply true
}
@ -9,11 +9,11 @@ apply plugin: 'kotlin-android'
android {
ndkVersion "23.2.8568313"
compileSdkVersion 29
compileSdkVersion 31
defaultConfig {
minSdkVersion 21
targetSdkVersion 29
targetSdkVersion 31
versionCode 1
versionName "1.0"
@ -31,7 +31,7 @@ android {
cargo {
module = "../../"
targets = ["arm64", "x86_64"]
targets = ["arm64", "x86_64", "x86"]
libname = "maplibre_android"
targetDirectory = "${module}/../target"
profile = "debug"
@ -41,24 +41,6 @@ cargo {
noDefaultBut("foo", "bar")
all()
}
def ndkDir = android.ndkDirectory
exec = { spec, toolchain ->
spec.environment("TEST", "test")
// https://github.com/mozilla/rust-android-gradle/issues/91
if (toolchain.target == "x86_64-linux-android") {
spec.environment("AR_x86_64-linux-android", "$ndkDir/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-ar")
}
if (toolchain.target == "armv7-linux-androideabi") {
spec.environment("AR_armv7-linux-androideabi", "$ndkDir/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-ar")
}
if (toolchain.target == "aarch64-linux-android") {
spec.environment("AR_aarch64-linux-android", "$ndkDir/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-ar")
}
}
}
dependencies {

View File

@ -54,11 +54,12 @@ cargo run -p maplibre-demo
Start by installing the
[Android Studio IDE](https://developer.android.com/studio?gclid=CjwKCAjwj42UBhAAEiwACIhADmF7uHXnEHGnmOgFnjp0Z6n-TnBvutC5faGA89lwouMIXiR6OXK4hBoCq78QAvD_BwE&gclsrc=aw.ds).
Make sure the NDK version 23.1.7779620 is installed. The Native Development Kit (NDK) is a set of tools that allows
you to use C and C++ code with Android.
Make sure the NDK is installed. The Native Development Kit (NDK) is a set of tools that allows
you to use C and C++ code with Android. You have to install manually the version that is used in
`./android/gradle/lib/build.gradle`.
```
ANDROID STUDIO -> tools -> SDK manager -> SDK tools -> tick show package details -> ndk (side by side) version 23.1.7779620
ANDROID STUDIO -> tools -> SDK manager -> SDK tools -> tick show package details -> ndk (side by side)
```
Open the project within `./android/gradle` and create a new virtual device with the device manager. Minimum SDK version

View File

@ -56,6 +56,7 @@ nightly-toolchain:
nightly-toolchain-android: nightly-toolchain
rustup target add --toolchain $NIGHTLY_TOOLCHAIN x86_64-linux-android
rustup target add --toolchain $NIGHTLY_TOOLCHAIN aarch64-linux-android
rustup target add --toolchain $NIGHTLY_TOOLCHAIN i686-linux-android
web-install PROJECT:
cd web/{{PROJECT}} && npm install