From 5ce4d418f3ebf0f70a004945dd0150eae390fe66 Mon Sep 17 00:00:00 2001 From: CAI Kelun Date: Thu, 29 Jul 2021 23:44:51 +0800 Subject: [PATCH] Support for API level 31. Update AGP, NDK version. --- README.md | 12 +++---- README.zh-CN.md | 12 +++---- build.gradle | 11 ++++--- gradle/wrapper/gradle-wrapper.properties | 2 +- xdl/build.gradle | 4 ++- xdl_sample/build.gradle | 41 ++++++++++++++---------- xdl_sample/src/main/AndroidManifest.xml | 3 +- xdl_sample/src/main/cpp/CMakeLists.txt | 25 +++++++++------ 8 files changed, 63 insertions(+), 47 deletions(-) diff --git a/README.md b/README.md index bfd4799..bbcf275 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ ![](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat) ![](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat) ![](https://img.shields.io/badge/release-1.1.1-red.svg?style=flat) -![](https://img.shields.io/badge/Android-4.1%20--%2011-blue.svg?style=flat) +![](https://img.shields.io/badge/Android-4.1%20--%2012-blue.svg?style=flat) ![](https://img.shields.io/badge/arch-armeabi--v7a%20%7C%20arm64--v8a%20%7C%20x86%20%7C%20x86__64-blue.svg?style=flat) xDL is an enhanced implementation of the Android DL series functions. @@ -22,7 +22,7 @@ xDL is an enhanced implementation of the Android DL series functions. * Including linker / linker64 (for Android <= 8.x). * Return full pathname instead of basename (for Android 5.x). * Return app\_process32 / app\_process64 instead of package name. -* Support Android 4.1 - 11 (API level 16 - 30). +* Support Android 4.1 - 12 (API level 16 - 31). * Support armeabi-v7a, arm64-v8a, x86 and x86_64. * MIT licensed. @@ -33,10 +33,10 @@ If xDL is compiled into an independent dynamic library: | ABI | Compressed (KB) | Uncompressed (KB) | | :---------- | --------------: | ----------------: | -| armeabi-v7a | 6.8 | 13.9 | -| arm64-v8a | 7.5 | 18.3 | -| x86 | 7.7 | 17.9 | -| x86_64 | 7.9 | 18.6 | +| armeabi-v7a | 6.8 | 12.0 | +| arm64-v8a | 7.6 | 16.2 | +| x86 | 7.8 | 15.1 | +| x86_64 | 7.8 | 16.6 | ## Usage diff --git a/README.zh-CN.md b/README.zh-CN.md index f6aacfd..2eec56c 100644 --- a/README.zh-CN.md +++ b/README.zh-CN.md @@ -3,7 +3,7 @@ ![](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat) ![](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat) ![](https://img.shields.io/badge/release-1.1.1-red.svg?style=flat) -![](https://img.shields.io/badge/Android-4.1%20--%2011-blue.svg?style=flat) +![](https://img.shields.io/badge/Android-4.1%20--%2012-blue.svg?style=flat) ![](https://img.shields.io/badge/arch-armeabi--v7a%20%7C%20arm64--v8a%20%7C%20x86%20%7C%20x86__64-blue.svg?style=flat) xDL 是 Android DL 系列函数的增强实现。 @@ -22,7 +22,7 @@ xDL 是 Android DL 系列函数的增强实现。 * 在 Android <= 8.x 时,包含 linker / linker64。 * 在 Android 5.x 中,返回完整的路径名(full pathname),而不是文件名(basename)。 * 返回 app\_process32 / app\_process64,而不是包名。 -* 支持 Android 4.1 - 11 (API level 16 - 30)。 +* 支持 Android 4.1 - 12 (API level 16 - 31)。 * 支持 armeabi-v7a, arm64-v8a, x86 和 x86_64。 * 使用 MIT 许可证授权。 @@ -33,10 +33,10 @@ xDL 是 Android DL 系列函数的增强实现。 | ABI | 压缩后 (KB) | 未压缩 (KB) | | :---------- | ---------: | ---------: | -| armeabi-v7a | 6.8 | 13.9 | -| arm64-v8a | 7.5 | 18.3 | -| x86 | 7.7 | 17.9 | -| x86_64 | 7.9 | 18.6 | +| armeabi-v7a | 6.8 | 12.0 | +| arm64-v8a | 7.6 | 16.2 | +| x86 | 7.8 | 15.1 | +| x86_64 | 7.8 | 16.6 | ## 使用 diff --git a/build.gradle b/build.gradle index 38b51de..74ef598 100644 --- a/build.gradle +++ b/build.gradle @@ -4,7 +4,7 @@ buildscript { mavenCentral() } dependencies { - classpath 'com.android.tools.build:gradle:4.2.1' + classpath 'com.android.tools.build:gradle:7.0.0' } } @@ -22,14 +22,15 @@ task clean(type: Delete) { ext { minSdkVersion = 16 - compileSdkVersion = 30 - targetSdkVersion = 30 - buildToolsVersion = "30.0.3" + compileSdkVersion = 31 + targetSdkVersion = 31 + buildToolsVersion = "31.0.0" javaVersion = JavaVersion.VERSION_1_7 - ndkVersion = "21.4.7075529" + ndkVersion = "22.1.7171670" cmakeVersion = "3.18.1" abiFilters = "armeabi-v7a,arm64-v8a,x86,x86_64" useASAN = false + dependencyOnLocalLibrary = true POM_GROUP_ID = "io.hexhacking" POM_ARTIFACT_ID = "xdl" diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 7cc6d60..45c8a23 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-all.zip diff --git a/xdl/build.gradle b/xdl/build.gradle index 32ce261..b1bed09 100644 --- a/xdl/build.gradle +++ b/xdl/build.gradle @@ -1,4 +1,6 @@ -apply plugin: 'com.android.library' +plugins { + id 'com.android.library' +} android { compileSdkVersion rootProject.ext.compileSdkVersion diff --git a/xdl_sample/build.gradle b/xdl_sample/build.gradle index c9917e4..9d8f965 100644 --- a/xdl_sample/build.gradle +++ b/xdl_sample/build.gradle @@ -1,4 +1,6 @@ -apply plugin: 'com.android.application' +plugins { + id 'com.android.application' +} android { compileSdkVersion rootProject.ext.compileSdkVersion @@ -13,6 +15,14 @@ android { ndk { abiFilters rootProject.ext.abiFilters.split(",") } + externalNativeBuild { + cmake { + abiFilters rootProject.ext.abiFilters.split(",") + if (rootProject.ext.dependencyOnLocalLibrary) { + arguments "-DDEPENDENCY_ON_LOCAL_LIBRARY=ON" + } + } + } } externalNativeBuild { cmake { @@ -35,31 +45,28 @@ android { minifyEnabled false } } - buildFeatures { - prefab true + if (!rootProject.ext.dependencyOnLocalLibrary) { + buildFeatures { + prefab true + } } packagingOptions { pickFirst '**/libxdl.so' } + lintOptions { + abortOnError false + } } dependencies { - implementation 'androidx.appcompat:appcompat:1.3.0' - implementation 'com.google.android.material:material:1.3.0' + implementation 'androidx.appcompat:appcompat:1.3.1' + implementation 'com.google.android.material:material:1.4.0' implementation 'androidx.constraintlayout:constraintlayout:2.0.4' - implementation project(':xdl') -// implementation 'io.hexhacking:xdl:1.1.1' -} - -// Bypass the compatibility issue between prefab and gradle-project-dependencies. -// Note: This is not required for gradle-maven-dependencies. -tasks.whenTaskAdded { task -> - if (task.name == 'generateJsonModelDebug') { - task.dependsOn(':xdl:prefabDebugPackage') - } - else if (task.name == 'generateJsonModelRelease') { - task.dependsOn(':xdl:prefabReleasePackage') + if (rootProject.ext.dependencyOnLocalLibrary) { + implementation project(':xdl') + } else { + implementation 'io.hexhacking:xdl:1.1.1' } } diff --git a/xdl_sample/src/main/AndroidManifest.xml b/xdl_sample/src/main/AndroidManifest.xml index 33af04c..9dd68ab 100644 --- a/xdl_sample/src/main/AndroidManifest.xml +++ b/xdl_sample/src/main/AndroidManifest.xml @@ -10,7 +10,8 @@ android:roundIcon="@mipmap/ic_launcher_round" android:supportsRtl="true" android:theme="@style/AppTheme"> - + diff --git a/xdl_sample/src/main/cpp/CMakeLists.txt b/xdl_sample/src/main/cpp/CMakeLists.txt index e5235a9..4e0474a 100644 --- a/xdl_sample/src/main/cpp/CMakeLists.txt +++ b/xdl_sample/src/main/cpp/CMakeLists.txt @@ -1,16 +1,21 @@ cmake_minimum_required(VERSION 3.18.1) project(sample) -# import xdl from local-project -string(TOLOWER ${CMAKE_BUILD_TYPE} BUILD_TYPE_DIRNAME) -set(XDL_BASE ${CMAKE_CURRENT_SOURCE_DIR}/../../../../xdl) -add_library(xdl::xdl SHARED IMPORTED) -set_target_properties(xdl::xdl PROPERTIES - IMPORTED_LOCATION ${XDL_BASE}/build/intermediates/stripped_native_libs/${BUILD_TYPE_DIRNAME}/out/lib/${ANDROID_ABI}/libxdl.so - INTERFACE_INCLUDE_DIRECTORIES ${XDL_BASE}/src/main/cpp/include) - -# import xdl from maven -#find_package(xdl REQUIRED CONFIG) +if(DEPENDENCY_ON_LOCAL_LIBRARY) + # import xdl from local-project + string(TOLOWER ${CMAKE_BUILD_TYPE} BUILD_TYPE_DIRNAME) + if(${BUILD_TYPE_DIRNAME} STREQUAL "relwithdebinfo") + set(BUILD_TYPE_DIRNAME "release") + endif() + set(XDL_BASE ${CMAKE_CURRENT_SOURCE_DIR}/../../../../xdl) + add_library(xdl::xdl SHARED IMPORTED) + set_target_properties(xdl::xdl PROPERTIES + IMPORTED_LOCATION ${XDL_BASE}/build/intermediates/stripped_native_libs/${BUILD_TYPE_DIRNAME}/out/lib/${ANDROID_ABI}/libxdl.so + INTERFACE_INCLUDE_DIRECTORIES ${XDL_BASE}/src/main/cpp/include) +else() + # import xdl from maven + find_package(xdl REQUIRED CONFIG) +endif() add_library(sample SHARED sample.c) target_compile_features(sample PUBLIC c_std_11)