|
| 1 | +plugins { |
| 2 | + id 'com.android.application' |
| 3 | +} |
| 4 | + |
| 5 | +repositories { |
| 6 | + jcenter() |
| 7 | + maven { |
| 8 | + url "https://oss.sonatype.org/content/repositories/snapshots" |
| 9 | + } |
| 10 | +} |
| 11 | + |
| 12 | +android { |
| 13 | + signingConfigs { |
| 14 | + release { |
| 15 | + storeFile file('wenet.keystore') |
| 16 | + storePassword '123456' |
| 17 | + keyAlias 'wenet' |
| 18 | + keyPassword '123456' |
| 19 | + } |
| 20 | + } |
| 21 | + packagingOptions { |
| 22 | + pickFirst 'lib/arm64-v8a/libc++_shared.so' |
| 23 | + } |
| 24 | + configurations { |
| 25 | + extractForNativeBuild |
| 26 | + } |
| 27 | + compileSdkVersion 30 |
| 28 | + buildToolsVersion "30.0.3" |
| 29 | + |
| 30 | + defaultConfig { |
| 31 | + applicationId "com.mobvoi.WeTextProcessing" |
| 32 | + minSdkVersion 21 |
| 33 | + targetSdkVersion 30 |
| 34 | + versionCode 1 |
| 35 | + versionName "1.0" |
| 36 | + |
| 37 | + testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" |
| 38 | + externalNativeBuild { |
| 39 | + cmake { |
| 40 | + targets "wetextprocessing" |
| 41 | + cppFlags "-std=c++14", "-DC10_USE_GLOG", "-DC10_USE_MINIMAL_GLOG", "-DANDROID", "-Wno-c++11-narrowing", "-fexceptions" |
| 42 | + } |
| 43 | + } |
| 44 | + |
| 45 | + ndkVersion '21.1.6352462' |
| 46 | + ndk { |
| 47 | + abiFilters 'armeabi-v7a', 'arm64-v8a', 'x86', 'x86_64' |
| 48 | + } |
| 49 | + } |
| 50 | + |
| 51 | + buildTypes { |
| 52 | + release { |
| 53 | + minifyEnabled false |
| 54 | + signingConfig signingConfigs.release |
| 55 | + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' |
| 56 | + } |
| 57 | + } |
| 58 | + externalNativeBuild { |
| 59 | + cmake { |
| 60 | + path "src/main/cpp/CMakeLists.txt" |
| 61 | + } |
| 62 | + } |
| 63 | + compileOptions { |
| 64 | + sourceCompatibility JavaVersion.VERSION_1_8 |
| 65 | + targetCompatibility JavaVersion.VERSION_1_8 |
| 66 | + } |
| 67 | +} |
| 68 | + |
| 69 | +dependencies { |
| 70 | + |
| 71 | + implementation 'androidx.appcompat:appcompat:1.2.0' |
| 72 | + implementation 'com.google.android.material:material:1.2.1' |
| 73 | + implementation 'androidx.constraintlayout:constraintlayout:2.0.4' |
| 74 | + testImplementation 'junit:junit:4.+' |
| 75 | + androidTestImplementation 'androidx.test.ext:junit:1.1.2' |
| 76 | + androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0' |
| 77 | + |
| 78 | + implementation 'com.github.pengzhendong:wenet-openfst-android:1.0.2' |
| 79 | + extractForNativeBuild 'com.github.pengzhendong:wenet-openfst-android:1.0.2' |
| 80 | +} |
| 81 | + |
| 82 | +task extractAARForNativeBuild { |
| 83 | + doLast { |
| 84 | + configurations.extractForNativeBuild.files.each { |
| 85 | + def file = it.absoluteFile |
| 86 | + copy { |
| 87 | + from zipTree(file) |
| 88 | + into "$buildDir/$file.name" |
| 89 | + include "headers/**" |
| 90 | + include "jni/**" |
| 91 | + } |
| 92 | + } |
| 93 | + } |
| 94 | +} |
| 95 | + |
| 96 | +tasks.whenTaskAdded { task -> |
| 97 | + if (task.name.contains('externalNativeBuild')) { |
| 98 | + task.dependsOn(extractAARForNativeBuild) |
| 99 | + } |
| 100 | +} |
0 commit comments