Hey @ncalexan
I am getting the following error when I run .gradlew cargoBuild
> Task :app:cargoBuildArm FAILED
Compiling adder v0.1.0 (/Users/surisa/Documents/flutter/flutter_rust_demo/native/adder)
error[E0463]: can't find crate for `std`
|
= note: the `armv7-linux-androideabi` target may not be installed
= help: consider downloading the target with `rustup target add armv7-linux-androideabi`
error: requires `sized` lang_item
For more information about this error, try `rustc --explain E0463`.
error: could not compile `adder` due to 2 previous errors
My active toolchain:
❯ rustup show
Default host: aarch64-apple-darwin
rustup home: /Users/surisa/.rustup
installed targets for active toolchain
--------------------------------------
aarch64-apple-darwin
aarch64-linux-android
armv7-linux-androideabi
i686-linux-android
x86_64-linux-android
active toolchain
----------------
stable-aarch64-apple-darwin (default)
rustc 1.64.0 (a55dd71d5 2022-09-19)
This is my build.gradle:
def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
localPropertiesFile.withReader('UTF-8') { reader ->
localProperties.load(reader)
}
}
def flutterRoot = localProperties.getProperty('flutter.sdk')
if (flutterRoot == null) {
throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
}
def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
flutterVersionCode = '1'
}
def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {
flutterVersionName = '1.0'
}
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
android {
compileSdkVersion flutter.compileSdkVersion
ndkVersion "25.1.8937393"
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
}
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.example.flutter_rust_demo"
// You can update the following values to match your application needs.
// For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-build-configuration.
minSdkVersion flutter.minSdkVersion
targetSdkVersion flutter.targetSdkVersion
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
}
buildTypes {
release {
// TODO: Add your own signing config for the release build.
// Signing with the debug keys for now, so `flutter run --release` works.
signingConfig signingConfigs.debug
}
}
}
apply plugin: 'org.mozilla.rust-android-gradle.rust-android'
cargo {
module = "../../native/adder-ffi" // Or whatever directory contains your Cargo.toml
libname = "adder-ffi" // Or whatever matches Cargo.toml's [package] name.
targets = ["arm", "arm64", "x86", "x86_64"] // See bellow for a longer list of options
profile = "release"
apiLevel = 21
}
flutter {
source '../..'
}
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
}
[
Debug: null,
Profile: '--release',
Release: '--release'
].each {
def taskPostfix = it.key
def profileMode = it.value
tasks.whenTaskAdded { task ->
if (task.name == "javaPreCompile$taskPostfix") {
task.dependsOn 'cargoBuild'
}
}
}
Hey @ncalexan I am getting the following error when I run
.gradlew cargoBuild
My active toolchain:
This is my build.gradle: