Refactor flutter to support Android (#1072)

This commit is contained in:
Fangjun Kuang
2024-07-04 10:49:09 +08:00
committed by GitHub
parent 125bb9ff99
commit b502116068
110 changed files with 4547 additions and 32 deletions

View File

@@ -0,0 +1,9 @@
*.iml
.gradle
/local.properties
/.idea/workspace.xml
/.idea/libraries
.DS_Store
/build
/captures
.cxx

View File

@@ -0,0 +1,48 @@
// The Android Gradle Plugin builds the native code with the Android NDK.
group = "com.k2fsa.sherpa.onnx.sherpa_onnx_android"
version = "1.0"
buildscript {
repositories {
google()
mavenCentral()
}
dependencies {
// The Android Gradle Plugin knows how to build native code with the NDK.
classpath("com.android.tools.build:gradle:7.3.0")
}
}
rootProject.allprojects {
repositories {
google()
mavenCentral()
}
}
apply plugin: "com.android.library"
android {
namespace 'com.k2fsa.sherpa.onnx'
// Bumping the plugin compileSdk version requires all clients of this plugin
// to bump the version in their app.
compileSdk = 34
// Use the NDK version
// declared in /android/app/build.gradle file of the Flutter project.
// Replace it with a version number if this plugin requires a specific NDK version.
// (e.g. ndkVersion "23.1.7779620")
ndkVersion = android.ndkVersion
compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
defaultConfig {
minSdk = 21
}
}

View File

@@ -0,0 +1 @@
rootProject.name = 'sherpa_onnx_android'

View File

@@ -0,0 +1,3 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.k2fsa.sherpa.onnx">
</manifest>

View File

@@ -0,0 +1,23 @@
# Introduction
Pre-built libs are not checked-in.
Please use
- https://github.com/k2-fsa/sherpa-onnx/blob/master/build-android-arm64-v8a.sh
- https://github.com/k2-fsa/sherpa-onnx/blob/master/build-android-armv7-eabi.sh
- https://github.com/k2-fsa/sherpa-onnx/blob/master/build-android-x86-64.sh
- https://github.com/k2-fsa/sherpa-onnx/blob/master/build-android-x86.sh
The following is an example for `arm64-v8a`:
```bash
git clone https://github.com/k2-fsa/sherpa-onnx
cd sherpa-onnx
export SHERPA_ONNX_ENABLE_JNI=OFF
export SHERPA_ONNX_ENABLE_C_API=ON
./build-android-arm64-v8a.sh
cp -v build-android-arm64-v8a/install/lib/*.so flutter/sherpa_onnx_android/android/src/main/jniLibs/arm64-v8a/
```