Closed VictorSnow closed 1 year ago
A workround: skip step 1 and 2
Add Script docker-exec.sh
in root project dir
#!/bin/sh
cd core/src/main/rust/shadowsocks-rust
rustup target add armv7-linux-androideabi aarch64-linux-android i686-linux-android x86_64-linux-android
cd /build/
./gradlew assembleDebug
Then
docker run --rm -v ${PWD}:/build -w /build shadowsocks/android-ndk-go /build/docker-exec.sh
Builded success on mobile
Apk
Addition
If failed in resolve rust dependence, you may want to add to core/src/main/rust/shadowsocks-rust/.cargo/config.toml
[source.crates-io]
replace-with = 'tuna'
[source.tuna]
registry = "https://mirrors.tuna.tsinghua.edu.cn/git/crates.io-index.git"
Trouble in build TV version
> Task :tv:getDependencies
Failed to process com.github.shadowsocks:plugin:2.0.1
org.gradle.internal.component.AmbiguousVariantSelectionException: The consumer was configured to find an API of a component, preferably optimized for Android, as well as attribute 'com.android.build.api.attributes.BuildTypeAttr' with value 'debug', attribute 'market' with value 'freedom', attribute 'org.jetbrains.kotlin.platform.type' with value 'androidJvm'. However we cannot choose between the following variants of project :plugin:
- Configuration ':plugin:debugApiElements' variant android-aidl declares an API of a component, as well as attribute 'com.android.build.api.attributes.BuildTypeAttr' with value 'debug', attribute 'org.jetbrains.kotlin.platform.type' with value 'androidJvm':
- Unmatched attributes:
- Provides attribute 'artifactType' with value 'android-aidl' but the consumer didn't ask for it
- Provides attribute 'com.android.build.gradle.internal.attributes.VariantAttr' with value 'debug' but the consumer didn't ask for it
- Doesn't say anything about market (required 'freedom')
- Doesn't say anything about its target Java environment (preferred optimized for Android)
- Configuration ':plugin:debugApiElements' variant android-lint-local-aar declares an API of a component, as well as attribute 'com.android.build.api.attributes.BuildTypeAttr' with value 'debug', attribute 'org.jetbrains.kotlin.platform.type' with value 'androidJvm':
Describe the bug Failed to build from source using docker
To Reproduce Steps to reproduce the behavior:
cd core/src/main/rust/shadowsocks-rust
rustup target add armv7-linux-androideabi aarch64-linux-android i686-linux-android x86_64-linux-android
docker run --rm -v ${PWD}:/build -w /build shadowsocks/android-ndk-go ./gradlew assembleDebug
error: aborting due to previous error
For more information about this error, try
rustc --explain E0463
. error: could not compilecfg-if
Macx@A1398 shadowsocks-rust % rustup show Default host: x86_64-apple-darwin rustup home: /Users/xxxx/.rustup
installed toolchains
stable-x86_64-apple-darwin (default) nightly-2021-06-03-x86_64-apple-darwin
installed targets for active toolchain
aarch64-linux-android armv7-linux-androideabi i686-linux-android x86_64-apple-darwin x86_64-linux-android
active toolchain
nightly-2021-06-03-x86_64-apple-darwin (overridden by '/Users/xxxxx/Desktop/shadowsocks-android/core/src/main/rust/shadowsocks-rust/rust-toolchain') rustc 1.54.0-nightly (dbe459ded 2021-06-02)