Skip to content

Commit

Permalink
Support for API level 31. Update AGP, NDK version.
Browse files Browse the repository at this point in the history
  • Loading branch information
caikelun committed Jul 29, 2021
1 parent a8ef386 commit 5ce4d41
Show file tree
Hide file tree
Showing 8 changed files with 63 additions and 47 deletions.
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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.

Expand All @@ -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
Expand Down
12 changes: 6 additions & 6 deletions README.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 系列函数的增强实现。
Expand All @@ -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 许可证授权。

Expand All @@ -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 |


## 使用
Expand Down
11 changes: 6 additions & 5 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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'
}
}

Expand All @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 3 additions & 1 deletion xdl/build.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
apply plugin: 'com.android.library'
plugins {
id 'com.android.library'
}

android {
compileSdkVersion rootProject.ext.compileSdkVersion
Expand Down
41 changes: 24 additions & 17 deletions xdl_sample/build.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
apply plugin: 'com.android.application'
plugins {
id 'com.android.application'
}

android {
compileSdkVersion rootProject.ext.compileSdkVersion
Expand All @@ -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 {
Expand All @@ -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'
}
}

Expand Down
3 changes: 2 additions & 1 deletion xdl_sample/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".MainActivity">
<activity android:name=".MainActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

Expand Down
25 changes: 15 additions & 10 deletions xdl_sample/src/main/cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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)
Expand Down

0 comments on commit 5ce4d41

Please sign in to comment.