There are two ways that Android generates a static library, one is to edit the Android.mk file, and one is to edit the Cmakelist file. The first one did not do research, because the IDE is Android studio, so the direct use of Gradle call Cmakelist file to complete the static library generation, is the second way. It is summarized as follows:
File Requirements:
1.cpp header File Source file
2.cmakelists.txt file
3.gen-gmath (module for generating a static library) Build.gradle
4.hellojni (engineering) under the Settings.gradle
File Modification Requirements:
1.c++ file, not explained
2. Add code add_library (Gmath STATIC gmath/src/gmath.c)
The location where the static library is generated should also be set, but beginner, so follow-up study.
In the case where the path is not set, it is generated under the module's Externalnativebuild file.
3. Increase in defaultconfig curly braces
externalnativebuild{
cmake{
Arguments '-dandroid_platform=android-14 ',
'-dandroid_toolchain=clang '
Targets ' Gmath '
}
}
Add in the Android curly braces
externalnativebuild{
cmake{
Path ' Src/main/cpp/cmakelists.txt '
}
}
4. Add include ': Gen-gmath ' module name
Android Studio uses Gradle and cmakelist to generate C + + static libraries. A method summary