Hello - I'm running Android Studio 2020.3.1 Arctic Fox July 26, 2021 build.

I've created a simple project that includes a Java application and a C++ 
JNI piece of code. This all builds and runs successfully.

I can also add prebuilt shared (.so) libraries by adding the following 
lines to my CMakeLists.txt file:

add_library( my-lib SHARED IMPORTED )
set_target_properties( my-lib PROPERTIES IMPORTED_LOCATION 
jniLibs/armabi-v7a/mylib.so )

Then I add the library name to the target_link_libraries() line and not 
only does that library get included in the APK, all of the .s0 libraries in 
that directory get included and they aren't even referenced in the 
CMakeLists.txt file.

I also have some static libraries I need to include in the APK. 

I've tried a couple different ways:
ATTEMPT #1:
add_library( my-static-lib STATIC IMPORTED )
set_target_properties( my-static-lib PROPERTIES IMPORTED_LOCATION 
jniLibs/armabi-v7a/myStaticLib.a )

This builds successfully, but when I look at the APK with the analyzer, 
mystaticLib.a isn't there.

ATTEMPT #2:
Adding the library directly in the target_link_libraries file:

target_link_libraries(myNdkApp 
{CMAKE_CURRENT_SOURCE_DIR}/libs/myStaticLib.a )

This also builds successfully, but when I look at the APK with the 
analyzer, mystaticLib.a isn't there.

Can anyone provide a simple example of adding prebuilt .a static libraries 
to an APK?

Thanks!

-- 
You received this message because you are subscribed to the Google Groups 
"Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/android-developers/424580e6-8b5e-426f-8f3e-c462fd7f1a4dn%40googlegroups.com.

Reply via email to