-
Notifications
You must be signed in to change notification settings - Fork 9
Description
I am trying to consume a local AAR that our SDK depends on, our SDK will be an AAR as well when release. We have some dependencies on JAR files as well however it seems this plugin is having issue with JAR files and does not respect the original AAR structure the AGP generates (without this plugin). I noticed that just by adding this plugin (not actually using it or using grease in any of the dependencies) the generated AAR is broken or has different structure and we keep getting NPE. Note that the local AAR and JAR contains native library (.so).
- Consuming JAR using
api(files("libs/SDK1.jar"))and consuming local AAR usinggreaseTree("SDK2.jar").
dependencies {
api(files("libs/SDK1.jar"))
greaseTree("org.slf4j:slf4j-android:1.7.32")
greaseTree(files("libs/SDK2.aar"))
}
Structure of AAR
- libs
- SDK1.jar
- OtherSDK.jar
- classes.jar
- com
- sdk2_package
- this_sdk_package
- org
- slf4j
- com
- Consuming JAR local AAR using
greaseTree("SDK2.jar/aar").
dependencies {
greaseTree(files("libs/SDK1.jar"))
greaseTree("org.slf4j:slf4j-android:1.7.32")
greaseTree(files("libs/SDK2.aar"))
}
Structure of AAR
- classes.jar
- com
- sdk1_package
- a- (compressed)
- b- (compressed)
- sdk2_package
- this_sdk_package
- sdk1_package
- org
- slf4j
- com
As we can see the libs folder is now gone and ** sdk1_package** is now included in classes.jar
Both of the generated AAR is not working. We compare it to the generated AAR that is working but the local AAR classes.jar was manually extracted.
- Manually extracted classes.jar from local AAR (working).
dependencies {
api(files("libs/SDK1.jar"))
implementation("org.slf4j:slf4j-android:1.7.32")
api(files("libs/SDK2_AAR_manually_extracted_classes.jar"))
}
- libs
- SDK1.jar
- SDK2_manually_extracted_classes.jar
- classes.jar
- com
- sdk1_package
- a- (uncompressed)
- b- (uncompressed)
- sdk2_package
- this_sdk_package
- sdk1_package
- com
Also noticed that SDK1 is now uncompressed and has different file name.
Does this plugin works for cases where both AAR and JAR is simultaneously consumed? I think my major problem here is the plugin does not retain the original behavior of AGP building AAR. I wanted to retain how AGP manage local JAR files while the plugin only handles local AAR.
Also got this warning during building of AAR however the .so files was still included in the final AAR.
/Users/user/Library/Android/SDK/ndk/25.1.8937393/toolchains/llvm/prebuilt/darwin-x86_64/bin/llvm-strip: error: '/Users/user/Desktop/Projects/Mobile/Native/Android/Android-App/sdk_module/build/intermediates/merged_native_libs/debug/mergeDebugNativeLibs/out/lib/armeabi-v7a/libSdk.so': The file was not recognized as a valid object file