mozilla / rust-android-gradle

Apache License 2.0
1.03k stars 67 forks source link

Generated apk does not contain jniLibs #147

Open Neerajsh8851 opened 1 month ago

Neerajsh8851 commented 1 month ago

image

Cargo.toml : https://github.com/Neerajsh8851/androidrust/blob/main/rust/Cargo.toml app/build.gradle.kts : https://github.com/Neerajsh8851/androidrust/blob/main/app/build.gradle.kts

paulirotta commented 1 month ago

You might need

tasks.configureEach { task -> if ((task.name == 'mergeDebugJniLibFolders' || task.name == 'mergeReleaseJniLibFolders')) { task.dependsOn 'cargoBuild' } }

peacefulprogram commented 1 month ago

When I ran the code provided in the link above, the following error occurred Execution failed for task ':app:mergeDebugJniLibFolders'. image

paulirotta commented 1 month ago

@peacefulprogram I faced similar issues after updating the Android gradle plugin to 8.4.1

After days of fun, the solution seemed to be placing the cargo gradle plugin before others. Don't ask why- it is Android

in the "app" module gradle

plugins {
    id 'org.mozilla.rust-android-gradle.rust-android'
    id 'io.sentry.android.gradle' version '4.6.0' // This must be AFTER the rust-android plugin, otherwise "duplicate" errors
}

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'androidx.navigation.safeargs.kotlin'

and in the "project" gradle

plugins {
    id 'com.android.application' version '8.4.1' apply false
    id 'org.jetbrains.kotlin.android' version '1.9.10' apply false
    id 'androidx.navigation.safeargs.kotlin' version '2.7.7' apply false
    id 'org.mozilla.rust-android-gradle.rust-android' version '0.9.4' apply false
}
peacefulprogram commented 1 month ago

@peacefulprogram I faced similar issues after updating the Android gradle plugin to 8.4.1

After days of fun, the solution seemed to be placing the cargo gradle plugin before others. Don't ask why- it is Android

in the "app" module gradle

plugins {
    id 'org.mozilla.rust-android-gradle.rust-android'
    id 'io.sentry.android.gradle' version '4.6.0' // This must be AFTER the rust-android plugin, otherwise "duplicate" errors
}

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'androidx.navigation.safeargs.kotlin'

and in the "project" gradle

plugins {
    id 'com.android.application' version '8.4.1' apply false
    id 'org.jetbrains.kotlin.android' version '1.9.10' apply false
    id 'androidx.navigation.safeargs.kotlin' version '2.7.7' apply false
    id 'org.mozilla.rust-android-gradle.rust-android' version '0.9.4' apply false
}

@paulirotta Thank you so much, it worked perfectly. You really saved me a lot of time.