Browse Source

Android vscode workflow (#912)

* fix: fix linux build

* Merge pull request #599 from AppFlowy-IO/refactor/grid_decode_cell_data

Refactor/grid decode cell data

* feat: ⭐ configured android vscode workflow

* chore: clean up android vscode

* fix: fixed typo

* chore: remove unused code

Co-authored-by: Nathan.fooo <[email protected]>
Co-authored-by: Lucas.Xu <[email protected]>
Sean Riley Hawkins 2 năm trước cách đây
mục cha
commit
69e3aed6b5
27 tập tin đã thay đổi với 287 bổ sung36 xóa
  1. 38 0
      frontend/.vscode/launch.json
  2. 27 0
      frontend/.vscode/tasks.json
  3. 5 0
      frontend/Makefile.toml
  4. 64 0
      frontend/app_flowy/android/README.md
  5. 10 3
      frontend/app_flowy/android/app/build.gradle
  6. 2 1
      frontend/app_flowy/android/app/src/main/AndroidManifest.xml
  7. 1 1
      frontend/app_flowy/android/build.gradle
  8. 1 0
      frontend/app_flowy/android/gradle.properties
  9. 1 2
      frontend/app_flowy/android/gradle/wrapper/gradle-wrapper.properties
  10. 16 0
      frontend/app_flowy/android/settings.gradle
  11. 1 0
      frontend/app_flowy/packages/appflowy_board/example/lib/multi_board_list_example.dart
  12. 1 0
      frontend/app_flowy/packages/flowy_infra_ui/android/build.gradle
  13. 0 0
      frontend/app_flowy/packages/flowy_infra_ui/android/src/main/java/com/example/flowy_infra_ui/FlowyInfraUIPlugin.java
  14. 15 3
      frontend/app_flowy/packages/flowy_infra_ui/example/android/app/build.gradle
  15. 0 7
      frontend/app_flowy/packages/flowy_infra_ui/example/android/app/src/main/java/com/example/flowy_infra_ui_example/MainActivity.java
  16. 1 1
      frontend/app_flowy/packages/flowy_infra_ui/example/android/build.gradle
  17. 16 0
      frontend/app_flowy/packages/flowy_infra_ui/example/android/settings.gradle
  18. 4 0
      frontend/app_flowy/packages/flowy_infra_ui/example/example/android/app/src/main/java/com/example/flowy_infra_ui_example/FlutterActivity.java
  19. 2 2
      frontend/app_flowy/packages/flowy_sdk/android/build.gradle
  20. 1 1
      frontend/app_flowy/packages/flowy_sdk/example/android/app/build.gradle
  21. 1 1
      frontend/app_flowy/packages/flowy_sdk/example/android/build.gradle
  22. 19 11
      frontend/app_flowy/packages/flowy_sdk/lib/ffi.dart
  23. 17 1
      frontend/rust-lib/.cargo/config.toml
  24. 11 0
      frontend/rust-lib/Cargo.lock
  25. 1 1
      frontend/rust-lib/dart-ffi/Cargo.toml
  26. 1 1
      frontend/rust-lib/lib-sqlite/Cargo.toml
  27. 31 0
      frontend/scripts/makefile/desktop.toml

+ 38 - 0
frontend/.vscode/launch.json

@@ -16,6 +16,18 @@
             },
             "cwd": "${workspaceRoot}/app_flowy"
         },
+        {
+            // This task builds the Rust and Dart code of AppFlowy for android.
+            "name": "AF: Run Android",
+            "request": "launch",
+            "program": "./lib/main.dart",
+            "type": "dart",
+            "preLaunchTask": "AF: build_mobile_sdk",
+            "env": {
+                "RUST_LOG": "info"
+            },
+            "cwd": "${workspaceRoot}/app_flowy"
+        },
         {
             "name": "AF: Debug Rust",
             "request": "attach",
@@ -48,6 +60,21 @@
             },
             "cwd": "${workspaceRoot}/app_flowy"
         },
+        {
+            // This task builds will:
+            // - call the clean task,
+            // - rebuild all the generated Files (including freeze and language files)
+            // - rebuild the the Rust and Dart code of AppFlowy.
+            "name": "AF: Clean + Rebuild All (Android)",
+            "request": "launch",
+            "program": "./lib/main.dart",
+            "type": "dart",
+            "preLaunchTask": "AF: Clean + Rebuild All (Android)",
+            "env": {
+                "RUST_LOG": "info"
+            },
+            "cwd": "${workspaceRoot}/app_flowy"
+        },
         {
             "name": "AF: Build All (rustlog: trace)",
             "request": "launch",
@@ -59,6 +86,17 @@
             },
             "cwd": "${workspaceRoot}/app_flowy"
         },
+        {
+            "name": "AF: Build All Android (rustlog: trace)",
+            "request": "launch",
+            "program": "./lib/main.dart",
+            "type": "dart",
+            "preLaunchTask": "AF: build_mobile_sdk",
+            "env": {
+                "RUST_LOG": "trace"
+            },
+            "cwd": "${workspaceRoot}/app_flowy"
+        },
         {
             "name": "AF: app_flowy (profile mode)",
             "request": "launch",

+ 27 - 0
frontend/.vscode/tasks.json

@@ -27,6 +27,33 @@
 				"panel": "new"
 			}
 		},
+		{
+			"label": "AF: Clean + Rebuild All (Android)",
+			"type": "shell",
+			"dependsOrder": "sequence",
+			"dependsOn": [
+				"AF: Rust Clean",
+				"AF: Flutter Clean",
+				"AF: build_flowy_sdk_for_android",
+				"AF: Flutter Pub Get",
+				"AF: Flutter Package Get",
+				"AF: Generate Language Files",
+				"AF: Generate Freezed Files",
+			],
+			"presentation": {
+				"reveal": "always",
+				"panel": "new",
+			},
+		},
+		{
+			"label": "AF: build_flowy_sdk_for_android",
+			"type": "shell",
+			"command": "cargo make --profile development-android flowy-sdk-dev-android",
+			"group": "build",
+			"options": {
+				"cwd": "${workspaceFolder}"
+			}
+		},
 		{
 			"label": "AF: build_flowy_sdk",
 			"type": "shell",

+ 5 - 0
frontend/Makefile.toml

@@ -161,6 +161,11 @@ TARGET_OS = "ios"
 FLUTTER_OUTPUT_DIR = "Release"
 PRODUCT_EXT = "ipa"
 
+[env.development-android]
+BUILD_FLAG = "debug"
+TARGET_OS = "android"
+CRATE_TYPE = "cdylib"
+FLUTTER_OUTPUT_DIR = "Debug"
 
 [tasks.setup-crate-type]
 private = true

+ 64 - 0
frontend/app_flowy/android/README.md

@@ -0,0 +1,64 @@
+# Description
+
+This is a guide on how to build the rust SDK for AppFlowy on android.
+Compiling the sdk is easy it just needs a few tweaks.
+When compiling for android we need the following pre-requisites:
+
+- Android NDK Tools. (v24 has been tested).
+- Cargo NDK. (@latest version).
+
+**Getting the tools**
+- Install cargo-ndk ```bash cargo install cargo-ndk```.
+- [Download](https://developer.android.com/ndk/downloads/) Android NDK version 24.
+- When downloading Android NDK you can get the compressed version as a standalone from the site.
+    Or you can download it through [Android Studio](https://developer.android.com/studio).
+- After downloading the two you need to set the environment variables. For Windows that's a seperate process.
+    On MacOs and Linux the process is similar.
+- The variables needed are '$ANDROID_NDK_HOME', this will point to where the NDK is located.
+---
+
+**Cargo Config File**
+This code needs to be written in ~/.cargo/config, this helps cargo know where to locate the android tools(linker and archiver).
+**NB** Keep in mind just replace 'user' with your own user name. Or just point it to the location of where you put the NDK.
+
+```toml
+[target.aarch64-linux-android]
+ar = "/home/user/Android/Sdk/ndk/24.0.8215888/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-ar"
+linker = "/home/user/Android/Sdk/ndk/24.0.8215888/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android29-clang"
+
+[target.armv7-linux-androideabi]
+ar = "/home/user/Android/Sdk/ndk/24.0.8215888/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-ar"
+linker = "/home/user/Android/Sdk/ndk/24.0.8215888/toolchains/llvm/prebuilt/linux-x86_64/bin/armv7a-linux-androideabi29-clang"
+
+[target.i686-linux-android]
+ar = "/home/user/Android/Sdk/ndk/24.0.8215888/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-ar"
+linker = "/home/user/Android/Sdk/ndk/24.0.8215888/toolchains/llvm/prebuilt/linux-x86_64/bin/i686-linux-android29-clang"
+
+[target.x86_64-linux-android]
+ar = "/home/user/Android/Sdk/ndk/24.0.8215888/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-ar"
+linker = "/home/user/Android/Sdk/ndk/24.0.8215888/toolchains/llvm/prebuilt/linux-x86_64/bin/x86_64-linux-android29-clang"
+```
+
+**Clang Fix**
+ In order to get clang to work properly with version 24 you need to create this file.
+ libgcc.a, then add this one line.
+ ```
+ INPUT(-lunwind)
+ ```
+
+**Folder path: 'Android/Sdk/ndk/24.0.8215888/toolchains/llvm/prebuilt/linux-x86_64/lib64/clang/14.0.1/lib/linux'.**
+After that you have to copy this file into three different folders namely aarch64, arm, i386 and x86_64.
+We have to do this so we Android NDK can find clang on our system, if we used NDK 22 we wouldnt have to do this process.
+Though using NDK v22 will not give us alot of features to work with.
+This github [issue](https://github.com/fzyzcjy/flutter_rust_bridge/issues/419) explains the reason why we are doing this.
+
+ ---
+
+ **Android NDK**
+
+ After installing the NDK tools for android you should export the PATH to your config file
+ (.vimrc, .zshrc, .profile, .bashrc file), That way it can be found.
+
+ ```vim
+ export PATH=/home/sean/Android/Sdk/ndk/24.0.8215888
+ ```

+ 10 - 3
frontend/app_flowy/android/app/build.gradle

@@ -26,7 +26,8 @@ apply plugin: 'kotlin-android'
 apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
 
 android {
-    compileSdkVersion 30
+    compileSdkVersion 31
+    ndkVersion "24.0.8215888"
 
     compileOptions {
         sourceCompatibility JavaVersion.VERSION_1_8
@@ -39,21 +40,26 @@ android {
 
     sourceSets {
         main.java.srcDirs += 'src/main/kotlin'
+        main.jniLibs.srcDirs += 'jniLibs/'
     }
 
     defaultConfig {
         // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
         applicationId "com.example.app_flowy"
-        minSdkVersion 16
-        targetSdkVersion 30
+        minSdkVersion 19
+        targetSdkVersion 31
         versionCode flutterVersionCode.toInteger()
         versionName flutterVersionName
+        multiDexEnabled true
     }
 
     buildTypes {
         release {
             // TODO: Add your own signing config for the release build.
             // Signing with the debug keys for now, so `flutter run --release` works.
+            minifyEnabled true
+            shrinkResources true
+
             signingConfig signingConfigs.debug
         }
     }
@@ -65,4 +71,5 @@ flutter {
 
 dependencies {
     implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
+    implementation "com.android.support:multidex:2.0.1"
 }

+ 2 - 1
frontend/app_flowy/android/app/src/main/AndroidManifest.xml

@@ -2,7 +2,8 @@
     package="com.example.app_flowy">
    <application
         android:label="app_flowy"
-        android:icon="@mipmap/ic_launcher">
+        android:icon="@mipmap/ic_launcher"
+        android:name="${applicationName}">
         <activity
             android:name=".MainActivity"
             android:launchMode="singleTop"

+ 1 - 1
frontend/app_flowy/android/build.gradle

@@ -1,5 +1,5 @@
 buildscript {
-    ext.kotlin_version = '1.3.50'
+    ext.kotlin_version = '1.6.10'
     repositories {
         google()
         mavenCentral()

+ 1 - 0
frontend/app_flowy/android/gradle.properties

@@ -1,3 +1,4 @@
 org.gradle.jvmargs=-Xmx1536M
 android.useAndroidX=true
 android.enableJetifier=true
+org.gradle.caching=true

+ 1 - 2
frontend/app_flowy/android/gradle/wrapper/gradle-wrapper.properties

@@ -1,6 +1,5 @@
-#Fri Jun 23 08:50:38 CEST 2017
 distributionBase=GRADLE_USER_HOME
 distributionPath=wrapper/dists
+distributionUrl=https\://services.gradle.org/distributions/gradle-7.1-all.zip
 zipStoreBase=GRADLE_USER_HOME
 zipStorePath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-6.7-all.zip

+ 16 - 0
frontend/app_flowy/android/settings.gradle

@@ -9,3 +9,19 @@ localPropertiesFile.withReader("UTF-8") { reader -> properties.load(reader) }
 def flutterSdkPath = properties.getProperty("flutter.sdk")
 assert flutterSdkPath != null, "flutter.sdk not set in local.properties"
 apply from: "$flutterSdkPath/packages/flutter_tools/gradle/app_plugin_loader.gradle"
+
+
+def flutterProjectRoot = rootProject.projectDir.parentFile.toPath()
+
+def plugins = new Properties()
+def pluginsFile = new File(flutterProjectRoot.toFile(), '.flutter-plugins')
+
+if(pluginsFile.exists()){
+    pluginsFile.withReader('UTF-8'){reader -> plugins.load(reader)}
+}
+
+plugins.each{name, path ->
+        def pluginDirectory = flutterProjectRoot.resolve(path).resolve('android').toFile()
+        include ":$name"
+        project(":$name").projectDir  = pluginDirectory
+}

+ 1 - 0
frontend/app_flowy/packages/appflowy_board/example/lib/multi_board_list_example.dart

@@ -34,6 +34,7 @@ class _MultiBoardListExampleState extends State<MultiBoardListExample> {
       RichTextItem(title: "Card 8", subtitle: 'Aug 1, 2020 4:05 PM'),
       TextItem("Card 9"),
     ];
+
     final column1 = AFBoardColumnData(id: "To Do", name: "To Do", items: a);
     final column2 = AFBoardColumnData(
       id: "In Progress",

+ 1 - 0
frontend/app_flowy/packages/flowy_infra_ui/android/build.gradle

@@ -2,6 +2,7 @@ group 'com.example.flowy_infra_ui'
 version '1.0'
 
 buildscript {
+    ext.kotlin_version  = '1.6.10'
     repositories {
         google()
         mavenCentral()

+ 0 - 0
frontend/app_flowy/packages/flowy_infra_ui/android/src/main/java/com/example/flowy_infra_ui/FlowyInfraUiPlugin.java → frontend/app_flowy/packages/flowy_infra_ui/android/src/main/java/com/example/flowy_infra_ui/FlowyInfraUIPlugin.java


+ 15 - 3
frontend/app_flowy/packages/flowy_infra_ui/example/android/app/build.gradle

@@ -24,8 +24,16 @@ if (flutterVersionName == null) {
 apply plugin: 'com.android.application'
 apply plugin: 'kotlin-android'
 apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
+//apply plugin: 'kotlin-android-extensions'
+
+
+//androidExtensions {
+//    experimental = true
+//}
 
 android {
+    compileSdkVersion flutter.compileSdkVersion
+    ndkVersion flutter.ndkVersion
 
     compileOptions {
         sourceCompatibility JavaVersion.VERSION_1_8
@@ -43,20 +51,23 @@ android {
     defaultConfig {
         // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
         applicationId "com.example.flowy_infra_ui_example"
-        minSdkVersion 16
-        targetSdkVersion 30
+        minSdkVersion flutter.minSdkVersion
+        targetSdkVersion flutter.targetSdkVersion
         versionCode flutterVersionCode.toInteger()
         versionName flutterVersionName
+        multiDexEnabled true
     }
 
     buildTypes {
         release {
+            minifyEnabled true
+            shrinkResources true
             // TODO: Add your own signing config for the release build.
             // Signing with the debug keys for now, so `flutter run --release` works.
             signingConfig signingConfigs.debug
         }
     }
-    compileSdkVersion 30
+
 }
 
 flutter {
@@ -65,4 +76,5 @@ flutter {
 
 dependencies {
     implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
+    implementation 'com.android.support:multidex:2.0.1'
 }

+ 0 - 7
frontend/app_flowy/packages/flowy_infra_ui/example/android/app/src/main/java/com/example/flowy_infra_ui_example/MainActivity.java

@@ -1,7 +0,0 @@
-package com.example.flowy_infra_ui_example;
-
-import io.flutter.embedding.android.FlutterActivity;
-
-public class MainActivity extends FlutterActivity {
-
-}

+ 1 - 1
frontend/app_flowy/packages/flowy_infra_ui/example/android/build.gradle

@@ -1,5 +1,5 @@
 buildscript {
-    ext.kotlin_version = '1.3.50'
+    ext.kotlin_version = '1.6.10'
     repositories {
         google()
         mavenCentral()

+ 16 - 0
frontend/app_flowy/packages/flowy_infra_ui/example/android/settings.gradle

@@ -9,3 +9,19 @@ localPropertiesFile.withReader("UTF-8") { reader -> properties.load(reader) }
 def flutterSdkPath = properties.getProperty("flutter.sdk")
 assert flutterSdkPath != null, "flutter.sdk not set in local.properties"
 apply from: "$flutterSdkPath/packages/flutter_tools/gradle/app_plugin_loader.gradle"
+
+
+
+def flutterProjectRoot = rootProject.projectDir.parentFile.toPath()
+
+def plugins = new Properties()
+def pluginsFile = new File(flutterProjectRoot.toFile(), '.flutter-plugins')
+if (pluginsFile.exists()) {
+    pluginsFile.withReader('UTF-8') { reader -> plugins.load(reader) }
+}
+
+plugins.each { name, path ->
+    def pluginDirectory = flutterProjectRoot.resolve(path).resolve('android').toFile()
+    include ":$name"
+    project(":$name").projectDir = pluginDirectory
+}

+ 4 - 0
frontend/app_flowy/packages/flowy_infra_ui/example/example/android/app/src/main/java/com/example/flowy_infra_ui_example/FlutterActivity.java

@@ -0,0 +1,4 @@
+package example.android.app.src.main.java.com.example.flowy_infra_ui_example;
+
+public class FlutterActivity {
+}

+ 2 - 2
frontend/app_flowy/packages/flowy_sdk/android/build.gradle

@@ -2,7 +2,7 @@ group 'com.plugin.flowy_sdk'
 version '1.0-SNAPSHOT'
 
 buildscript {
-    ext.kotlin_version = '1.3.50'
+    ext.kotlin_version = '1.6.10'
     repositories {
         google()
         jcenter()
@@ -25,7 +25,7 @@ apply plugin: 'com.android.library'
 apply plugin: 'kotlin-android'
 
 android {
-    compileSdkVersion 30
+    compileSdkVersion 31
 
     sourceSets {
         main.java.srcDirs += 'src/main/kotlin'

+ 1 - 1
frontend/app_flowy/packages/flowy_sdk/example/android/app/build.gradle

@@ -36,7 +36,7 @@ android {
         // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
         applicationId "com.plugin.flowy_sdk_example"
         minSdkVersion 16
-        targetSdkVersion 30
+        targetSdkVersion 31
         versionCode flutterVersionCode.toInteger()
         versionName flutterVersionName
     }

+ 1 - 1
frontend/app_flowy/packages/flowy_sdk/example/android/build.gradle

@@ -1,5 +1,5 @@
 buildscript {
-    ext.kotlin_version = '1.3.50'
+    ext.kotlin_version = '1.6.10'
     repositories {
         google()
         jcenter()

+ 19 - 11
frontend/app_flowy/packages/flowy_sdk/lib/ffi.dart

@@ -14,11 +14,14 @@ final DynamicLibrary dl = _dl;
 DynamicLibrary _open() {
   if (Platform.environment.containsKey('FLUTTER_TEST')) {
     final prefix = "${Directory.current.path}/.sandbox";
-    if (Platform.isLinux) return DynamicLibrary.open('${prefix}/libdart_ffi.so');
-    if (Platform.isAndroid) return DynamicLibrary.open('${prefix}/libdart_ffi.so');
+    if (Platform.isLinux)
+      return DynamicLibrary.open('${prefix}/libdart_ffi.so');
+    if (Platform.isAndroid)
+      return DynamicLibrary.open('${prefix}/libdart_ffi.so');
     if (Platform.isMacOS) return DynamicLibrary.open('${prefix}/libdart_ffi.a');
     if (Platform.isIOS) return DynamicLibrary.open('${prefix}/libdart_ffi.a');
-    if (Platform.isWindows) return DynamicLibrary.open('${prefix}/dart_ffi.dll');
+    if (Platform.isWindows)
+      return DynamicLibrary.open('${prefix}/dart_ffi.dll');
   } else {
     if (Platform.isLinux) return DynamicLibrary.open('libdart_ffi.so');
     if (Platform.isAndroid) return DynamicLibrary.open('libdart_ffi.so');
@@ -39,7 +42,8 @@ void async_event(
   _invoke_async(port, input, len);
 }
 
-final _invoke_async_Dart _invoke_async = _dl.lookupFunction<_invoke_async_C, _invoke_async_Dart>('async_event');
+final _invoke_async_Dart _invoke_async =
+    _dl.lookupFunction<_invoke_async_C, _invoke_async_Dart>('async_event');
 typedef _invoke_async_C = Void Function(
   Int64 port,
   Pointer<Uint8> input,
@@ -59,7 +63,8 @@ Pointer<Uint8> sync_event(
   return _invoke_sync(input, len);
 }
 
-final _invoke_sync_Dart _invoke_sync = _dl.lookupFunction<_invoke_sync_C, _invoke_sync_Dart>('sync_event');
+final _invoke_sync_Dart _invoke_sync =
+    _dl.lookupFunction<_invoke_sync_C, _invoke_sync_Dart>('sync_event');
 typedef _invoke_sync_C = Pointer<Uint8> Function(
   Pointer<Uint8> input,
   Uint64 len,
@@ -76,7 +81,8 @@ int init_sdk(
   return _init_sdk(path);
 }
 
-final _init_sdk_Dart _init_sdk = _dl.lookupFunction<_init_sdk_C, _init_sdk_Dart>('init_sdk');
+final _init_sdk_Dart _init_sdk =
+    _dl.lookupFunction<_init_sdk_C, _init_sdk_Dart>('init_sdk');
 typedef _init_sdk_C = Int64 Function(
   Pointer<ffi.Utf8> path,
 );
@@ -90,7 +96,8 @@ int set_stream_port(int port) {
 }
 
 final _set_stream_port_Dart _set_stream_port =
-    _dl.lookupFunction<_set_stream_port_C, _set_stream_port_Dart>('set_stream_port');
+    _dl.lookupFunction<_set_stream_port_C, _set_stream_port_Dart>(
+        'set_stream_port');
 
 typedef _set_stream_port_C = Int32 Function(
   Int64 port,
@@ -104,8 +111,8 @@ void link_me_please() {
   _link_me_please();
 }
 
-final _link_me_please_Dart _link_me_please =
-    _dl.lookupFunction<_link_me_please_C, _link_me_please_Dart>('link_me_please');
+final _link_me_please_Dart _link_me_please = _dl
+    .lookupFunction<_link_me_please_C, _link_me_please_Dart>('link_me_please');
 typedef _link_me_please_C = Void Function();
 typedef _link_me_please_Dart = void Function();
 
@@ -116,8 +123,9 @@ void store_dart_post_cobject(
   _store_dart_post_cobject(ptr);
 }
 
-final _store_dart_post_cobject_Dart _store_dart_post_cobject =
-    _dl.lookupFunction<_store_dart_post_cobject_C, _store_dart_post_cobject_Dart>('store_dart_post_cobject');
+final _store_dart_post_cobject_Dart _store_dart_post_cobject = _dl
+    .lookupFunction<_store_dart_post_cobject_C, _store_dart_post_cobject_Dart>(
+        'store_dart_post_cobject');
 typedef _store_dart_post_cobject_C = Void Function(
   Pointer<NativeFunction<Int8 Function(Int64, Pointer<Dart_CObject>)>> ptr,
 );

+ 17 - 1
frontend/rust-lib/.cargo/config.toml

@@ -5,4 +5,20 @@
 rustflags=["-C", "link-arg=-mmacosx-version-min=10.11"]
 
 [target.aarch64-apple-darwin]
-rustflags=["-C", "link-arg=-mmacosx-version-min=10.11"]
+rustflags=["-C", "link-arg=-mmacosx-version-min=10.11"]
+
+[target.aarch64-linux-android]
+ar = "path-to-ndk/llvm-ar"
+linker = "path-to-ndk/aarch64-linux-android29-clang"
+
+[target.armv7-linux-androideabi]
+ar = "path-to-ndk/llvm-ar"
+linker = "path-to-ndk/armv7a-linux-androideabi29-clang"
+
+[target.i686-linux-android]
+ar = "path-to-ndk/llvm-ar"
+linker = "path-to-ndk/i686-linux-android29-clang"
+
+[target.x86_64-linux-android]
+ar = "path-to-ndk/llvm-ar"
+linker = "path-to-ndk/x86_64-linux-android29-clang"

+ 11 - 0
frontend/rust-lib/Cargo.lock

@@ -1796,6 +1796,7 @@ dependencies = [
  "lazy_static",
  "libsqlite3-sys",
  "log",
+ "openssl",
  "r2d2",
  "scheduled-thread-pool",
 ]
@@ -2096,6 +2097,15 @@ version = "0.1.5"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf"
 
+[[package]]
+name = "openssl-src"
+version = "111.22.0+1.1.1q"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8f31f0d509d1c1ae9cada2f9539ff8f37933831fd5098879e482aa687d659853"
+dependencies = [
+ "cc",
+]
+
 [[package]]
 name = "openssl-sys"
 version = "0.9.72"
@@ -2105,6 +2115,7 @@ dependencies = [
  "autocfg",
  "cc",
  "libc",
+ "openssl-src",
  "pkg-config",
  "vcpkg",
 ]

+ 1 - 1
frontend/rust-lib/dart-ffi/Cargo.toml

@@ -38,4 +38,4 @@ http_sync = ["flowy-sdk/http_sync", "flowy-sdk/use_bunyan"]
 #use_protobuf= ["protobuf"]
 
 [build-dependencies]
-lib-infra = { path = "../../../shared-lib/lib-infra", features = ["protobuf_file_gen", "dart"] }
+lib-infra = { path = "../../../shared-lib/lib-infra", features = ["protobuf_file_gen", "dart"] }

+ 1 - 1
frontend/rust-lib/lib-sqlite/Cargo.toml

@@ -15,6 +15,6 @@ lazy_static = "1.4.0"
 scheduled-thread-pool = "0.2.5"
 error-chain = "=0.12.0"
 log = "0.4.11"
-
+openssl = { version = "0.10.38", features = ["vendored"] }
 #[features]
 #windows = ["libsqlite3-sys/bundled-windows"]

+ 31 - 0
frontend/scripts/makefile/desktop.toml

@@ -13,6 +13,11 @@ mac_alias = "flowy-sdk-dev-macos"
 windows_alias = "flowy-sdk-dev-windows"
 linux_alias = "flowy-sdk-dev-linux"
 
+[tasks.flowy-sdk-dev-android]
+category = "Build"
+dependencies = ["env_check"]
+run_task = { name = ["setup-crate-type","sdk-build-android", "restore-crate-type"] }
+
 [tasks.flowy-sdk-dev-macos]
 category = "Build"
 dependencies = ["env_check"]
@@ -42,6 +47,32 @@ script = [
 ]
 script_runner = "@shell"
 
+[tasks.sdk-build-android]
+private = true
+script = [
+  """
+    cd rust-lib/
+    rustup show
+    rustup target add aarch64-linux-android \
+      armv7-linux-androideabi \
+      i686-linux-android \
+      x86_64-linux-android
+    DEST=${CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY}/app_flowy/android/app/src/main/jniLibs
+    rm -rf $DEST/arm64-v8a \
+      $DEST/armeabi-v7a \
+      $DEST/x86 \
+      $DEST/x86_64
+    cargo ndk \
+      -t arm64-v8a \
+      -t armeabi-v7a \
+      -t x86 \
+      -t x86_64 \
+      -o $DEST build
+    cd ../
+  """,
+]
+script_runner = "@shell"
+
 [tasks.sdk-build.windows]
 private = true
 script = [