From 4bacb81f7f59db54758bb94040caa65272834caa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BD=AD=E9=9C=87=E4=B8=9C?= <275331498@qq.com> Date: Mon, 12 Sep 2022 19:09:44 +0800 Subject: [PATCH] [android] add build.gradle (#89) --- runtime/android/app/build.gradle | 73 ++++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 runtime/android/app/build.gradle diff --git a/runtime/android/app/build.gradle b/runtime/android/app/build.gradle new file mode 100644 index 0000000..5984fbb --- /dev/null +++ b/runtime/android/app/build.gradle @@ -0,0 +1,73 @@ +plugins { + id 'com.android.application' +} + +android { + compileSdk 32 + + configurations { + extractForNativeBuild + } + + defaultConfig { + applicationId "cn.org.wenet.wekws" + minSdk 21 + targetSdk 32 + versionCode 1 + versionName "1.0" + + testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" + externalNativeBuild { + cmake { + targets "wekws" + } + } + } + + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + } + } + externalNativeBuild { + cmake { + path "src/main/cpp/CMakeLists.txt" + } + } + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } +} + +dependencies { + implementation 'androidx.appcompat:appcompat:1.3.0' + implementation 'com.google.android.material:material:1.4.0' + implementation 'androidx.constraintlayout:constraintlayout:2.0.4' + implementation 'com.microsoft.onnxruntime:onnxruntime-mobile:latest.release' + extractForNativeBuild 'com.microsoft.onnxruntime:onnxruntime-mobile:latest.release' + testImplementation 'junit:junit:4.13.2' + androidTestImplementation 'androidx.test.ext:junit:1.1.3' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0' +} + +task extractAARForNativeBuild { + doLast { + configurations.extractForNativeBuild.files.each { + def file = it.absoluteFile + copy { + from zipTree(file) + into "$buildDir/$file.name" + include "headers/**" + include "jni/**" + } + } + } +} + +tasks.whenTaskAdded { task -> + if (task.name.contains('externalNativeBuild')) { + task.dependsOn(extractAARForNativeBuild) + } +} \ No newline at end of file