# Creates and names a library, sets it as either STATIC # or SHARED, and provides the relative paths to its source code. # You can define multiple libraries, and CMake builds them for you. # Gradle automatically packages shared libraries with your APK.
add_library( # Sets the name of the library. native-lib
# Sets the library as a shared library. SHARED
# Provides a relative path to your source file(s). src/main/cpp/native-lib.cpp src/main/cpp/bspatch.c src/main/cpp/bzip2/blocksort.c src/main/cpp/bzip2/bzip2.c src/main/cpp/bzip2/bzip2recover.c src/main/cpp/bzip2/bzlib.c src/main/cpp/bzip2/compress.c src/main/cpp/bzip2/crctable.c src/main/cpp/bzip2/decompress.c src/main/cpp/bzip2/dlltest.c src/main/cpp/bzip2/huffman.c src/main/cpp/bzip2/mk251.c src/main/cpp/bzip2/randtable.c src/main/cpp/bzip2/spewG.c src/main/cpp/bzip2/unzcrash.c)
# Searches for a specified prebuilt library and stores the path as a # variable. Because CMake includes system libraries in the search path by # default, you only need to specify the name of the public NDK library # you want to add. CMake verifies that the library exists before # completing its build.
find_library( # Sets the name of the path variable. log-lib
# Specifies the name of the NDK library that # you want CMake to locate. log )
# Specifies libraries CMake should link to your target library. You # can link multiple libraries, such as libraries you define in this # build script, prebuilt third-party libraries, or system libraries.
target_link_libraries( # Specifies the target library. native-lib
# Links the target library to the log library # included in the NDK. ${log-lib} )
val destApk = File(Environment.getExternalStorageDirectory(), "dest.apk") val patch = File(Environment.getExternalStorageDirectory(), "xxx/PATCH.patch")
/** * A native method that is implemented by the 'native-lib' native library, * which is packaged with this application. */ externalfunstringFromJNI(): String
externalfunbspatch(oldPth: String, newPath: String, path: String): Int
companionobject {
// Used to load the 'native-lib' library on application startup. init { System.loadLibrary("native-lib") } }
privatefuninstallApk(file: File) { try { val f = file // val f = File("sdcard/remeet/apk/remeet.apk") val intent = Intent(Intent.ACTION_VIEW) intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { val apkUri = FileProvider.getUriForFile(this, "${applicationInfo.packageName}.installapk.provider", f) intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION) intent.setDataAndType(apkUri, "application/vnd.android.package-archive") } else { intent.setDataAndType(Uri.fromFile(f), "application/vnd.android.package-archive") }
比较简单,界面一共就一个按钮和一个文字,文字显示版本(我自己乱填的),按钮点击会触发合并补丁的事件。当然,因为我自己的手机是8.0的,我要看效果是能简单适配一下了,各位如果代码跑不起来可以看看我的清单文件申请的权限,和对于7.0的适配。然后自己这里打两个不同的包,一个是 old 一个是 new ,之后进入 bsdiff 的目录,执行命令: