11plugins {
2- id ' com. android.application'
2+ alias(libs . plugins . android. application)
33}
44
5- repositories {
6- jcenter()
7- maven {
8- url " https://oss.sonatype.org/content/repositories/snapshots"
9- }
5+ def nativeAbis () {
6+ return (project. findProperty(' abiFilters' ) ?: ' armeabi-v7a,arm64-v8a,x86,x86_64' )
7+ .split(' ,' ). collect { it. trim() }. findAll { it }
108}
119
1210android {
13- lintOptions {
14- abortOnError false
11+ namespace = " com.wenet.WeTextProcessing"
12+ lint {
13+ abortOnError = false
1514 }
1615 signingConfigs {
1716 release {
@@ -21,85 +20,49 @@ android {
2120 keyPassword ' 123456'
2221 }
2322 }
24- packagingOptions {
25- jniLibs {
26- pickFirsts + = [' lib/arm64-v8a/libc++_shared.so' ]
27- }
28- }
29- configurations {
30- extractForNativeBuild
31- }
32- compileSdkVersion 30
33- buildToolsVersion " 30.0.3"
23+ compileSdk = 34
3424
3525 defaultConfig {
36- applicationId " com.mobvoi .WeTextProcessing"
37- minSdkVersion 21
38- targetSdkVersion 30
39- versionCode 1
40- versionName " 1.0"
26+ applicationId = " com.wenet .WeTextProcessing"
27+ minSdk = 21
28+ targetSdk = 34
29+ versionCode = 1
30+ versionName = " 1.0"
4131
42- testInstrumentationRunner " androidx.test.runner.AndroidJUnitRunner"
43- externalNativeBuild {
44- cmake {
45- targets " wetextprocessing"
46- cppFlags " -std=c++14" , " -DC10_USE_GLOG" , " -DC10_USE_MINIMAL_GLOG" , " -DANDROID" , " -Wno-c++11-narrowing" , " -fexceptions"
47- }
48- }
32+ testInstrumentationRunner = " androidx.test.runner.AndroidJUnitRunner"
4933
50- ndkVersion ' 21.1.6352462'
5134 ndk {
52- abiFilters ' armeabi-v7a ' , ' arm64-v8a ' , ' x86 ' , ' x86_64 '
35+ abiFilters. addAll(nativeAbis())
5336 }
5437 }
5538
5639 buildTypes {
5740 release {
58- minifyEnabled false
59- signingConfig signingConfigs. release
41+ minifyEnabled = false
42+ signingConfig = signingConfigs. release
6043 proguardFiles getDefaultProguardFile(' proguard-android-optimize.txt' ), ' proguard-rules.pro'
6144 }
6245 }
63- externalNativeBuild {
64- cmake {
65- path " src/main/cpp/CMakeLists.txt"
66- }
67- }
6846 compileOptions {
69- sourceCompatibility JavaVersion . VERSION_1_8
70- targetCompatibility JavaVersion . VERSION_1_8
47+ sourceCompatibility = JavaVersion . VERSION_17
48+ targetCompatibility = JavaVersion . VERSION_17
7149 }
7250}
7351
7452dependencies {
75-
76- implementation ' androidx.appcompat:appcompat:1.2.0'
77- implementation ' com.google.android.material:material:1.2.1'
78- implementation ' androidx.constraintlayout:constraintlayout:2.0.4'
79- testImplementation ' junit:junit:4.+'
80- androidTestImplementation ' androidx.test.ext:junit:1.1.2'
81- androidTestImplementation ' androidx.test.espresso:espresso-core:3.3.0'
82-
83- implementation ' com.github.pengzhendong:wenet-openfst-android:1.0.2'
84- extractForNativeBuild ' com.github.pengzhendong:wenet-openfst-android:1.0.2'
53+ implementation libs. androidx. appcompat
54+ implementation libs. material
55+ implementation libs. androidx. constraintlayout
56+ testImplementation libs. junit
57+ androidTestImplementation libs. androidx. junit
58+ androidTestImplementation libs. androidx. espresso. core
8559}
8660
87- task extractAARForNativeBuild {
88- doLast {
89- configurations. extractForNativeBuild. files. each {
90- def file = it. absoluteFile
91- copy {
92- from zipTree(file)
93- into " $buildDir /$file . name "
94- include " headers/**"
95- include " jni/**"
96- }
97- }
98- }
99- }
100-
101- tasks. whenTaskAdded { task ->
102- if (task. name. contains(' externalNativeBuild' )) {
103- task. dependsOn(extractAARForNativeBuild)
104- }
105- }
61+ // Native libs are NOT built by Gradle. Build them beforehand with CMake presets
62+ // (from repo root) so the .so files exist in app/src/main/jniLibs/<abi>/:
63+ // export ANDROID_NDK_HOME=$ANDROID_HOME/ndk/<version>
64+ // cd runtime
65+ // cmake --preset android-arm64-v8a
66+ // cmake --build --preset android-arm64-v8a
67+ // cmake --install build/aarch64-linux-android --component jni
68+ // Gradle only packages whatever is already present under jniLibs.
0 commit comments