JNI libraries missing in AAR file on first build

Open
#43 7 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
35/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
android, rust

Research direction

Start with the reproduction in samples/library, its build.gradle configuration, and the assembleDebug task. Build once from a clean state, inspect build/outputs/aar/library-debug.aar, then build again for comparison. Done means the first assembleDebug build includes the JNI libraries in the AAR.

Written by the indexing model from the issue text.

Description

When I build my library project for the first time after cleaning the build, build/outputs/aar/library-debug.aar does not contain the JNI libraries. Only when building for a second time, the JNI libraries are included.

This can be reproduced with samples/library of this repo:

  1. Checkout the repo

    git clone git@github.com:mozilla/rust-android-gradle.git
    cd rust-android-gradle/
    
  2. Copy the gradle wrapper into samples/library

    cd samples/library
    cp ../../gradlew .
    cp -Ra ../../gradle .
    
  3. Update the gradle wrapper to the latest version

    export ANDROID_HOME=~/Library/Android/sdk/
    ./gradlew wrapper --gradle-version 6.6.1
    
  4. Make the project use the rust plugin from the repository instead of the locally build one

    rm settings.gradle
    touch settings.gradle
    

    In build.gradle, change the rust plugin classpath to gradle.plugin.org.mozilla.rust-android-gradle:plugin:0.8.3

  5. Update the Android gradle plugin to 4.0.1 in build.gradle

  6. Build the library

    ./gradlew assembleDebug
    
  7. Look at build/outputs/aar/library-debug.aar and notice the JNI libraries are not included.

  8. Build the library again by again invoking ./gradlew assembleDebug. Now build/outputs/aar/library-debug.aar will contain the JNI libraries.

Is there a workaround for this that I could apply to build.gradle?

Dominant language
Kotlin
Stars
1.3k
Forks
95
Avg merge
15m
Merged PRs (30d)
2

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from mozilla/rust-android-gradle

All issues in mozilla/rust-android-gradle

Similar issues

More Kotlin issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.