Skip to content

Bring projects, wikis, and teams together with AI. AppFlowy is the AI collaborative workspace where you achieve more without losing control of your data. The leading open source Notion alternative.

Android vscode workflow (#912)

Sean Riley Hawkins69e3aed6b55d
diff --git a/frontend/.vscode/launch.json b/frontend/.vscode/launch.json
index 0efc79b00e..f40b4c713e 100644
--- a/frontend/.vscode/launch.json
+++ b/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",
diff --git a/frontend/.vscode/tasks.json b/frontend/.vscode/tasks.json
index 769ecd9b28..30fc1e134d 100644
--- a/frontend/.vscode/tasks.json
+++ b/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",
diff --git a/frontend/Makefile.toml b/frontend/Makefile.toml
index f6e8194efa..185dac15ad 100644
--- a/frontend/Makefile.toml
+++ b/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
diff --git a/frontend/app_flowy/android/README.md b/frontend/app_flowy/android/README.md
new file mode 100644
index 0000000000..a073fde807
--- /dev/null
+++ b/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
+ ```
\ No newline at end of file
diff --git a/frontend/app_flowy/android/app/build.gradle b/frontend/app_flowy/android/app/build.gradle
index e2f9734817..2fc26c2fb5 100644
--- a/frontend/app_flowy/android/app/build.gradle
+++ b/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"
}
diff --git a/frontend/app_flowy/android/app/src/main/AndroidManifest.xml b/frontend/app_flowy/android/app/src/main/AndroidManifest.xml
index a9fd47bd31..a34dc98587 100644
--- a/frontend/app_flowy/android/app/src/main/AndroidManifest.xml
+++ b/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"
diff --git a/frontend/app_flowy/android/build.gradle b/frontend/app_flowy/android/build.gradle
index ed45c65885..09fbd6404c 100644
--- a/frontend/app_flowy/android/build.gradle
+++ b/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()
diff --git a/frontend/app_flowy/android/gradle.properties b/frontend/app_flowy/android/gradle.properties
index 94adc3a3f9..792b531d57 100644
--- a/frontend/app_flowy/android/gradle.properties
+++ b/frontend/app_flowy/android/gradle.properties
@@ -1,3 +1,4 @@
org.gradle.jvmargs=-Xmx1536M
android.useAndroidX=true
android.enableJetifier=true
+org.gradle.caching=true
diff --git a/frontend/app_flowy/android/gradle/wrapper/gradle-wrapper.properties b/frontend/app_flowy/android/gradle/wrapper/gradle-wrapper.properties
index bc6a58afdd..1acc777d74 100644
--- a/frontend/app_flowy/android/gradle/wrapper/gradle-wrapper.properties
+++ b/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
diff --git a/frontend/app_flowy/android/settings.gradle b/frontend/app_flowy/android/settings.gradle
index 44e62bcf06..b6e43fa619 100644
--- a/frontend/app_flowy/android/settings.gradle
+++ b/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
+}
\ No newline at end of file
diff --git a/frontend/app_flowy/packages/appflowy_board/example/lib/multi_board_list_example.dart b/frontend/app_flowy/packages/appflowy_board/example/lib/multi_board_list_example.dart
index b69fb1dbf3..1decf21063 100644
--- a/frontend/app_flowy/packages/appflowy_board/example/lib/multi_board_list_example.dart
+++ b/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",
diff --git a/frontend/app_flowy/packages/flowy_infra_ui/android/build.gradle b/frontend/app_flowy/packages/flowy_infra_ui/android/build.gradle
index 76e9272bbf..d129628362 100644
--- a/frontend/app_flowy/packages/flowy_infra_ui/android/build.gradle
+++ b/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()
diff --git a/frontend/app_flowy/packages/flowy_infra_ui/android/src/main/java/com/example/flowy_infra_ui/FlowyInfraUiPlugin.java b/frontend/app_flowy/packages/flowy_infra_ui/android/src/main/java/com/example/flowy_infra_ui/FlowyInfraUIPlugin.java
similarity index 100%
rename from frontend/app_flowy/packages/flowy_infra_ui/android/src/main/java/com/example/flowy_infra_ui/FlowyInfraUiPlugin.java
rename to frontend/app_flowy/packages/flowy_infra_ui/android/src/main/java/com/example/flowy_infra_ui/FlowyInfraUIPlugin.java
diff --git a/frontend/app_flowy/packages/flowy_infra_ui/example/android/app/build.gradle b/frontend/app_flowy/packages/flowy_infra_ui/example/android/app/build.gradle
index 7356196bc3..1aa1cc480b 100644
--- a/frontend/app_flowy/packages/flowy_infra_ui/example/android/app/build.gradle
+++ b/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'
}
diff --git a/frontend/app_flowy/packages/flowy_infra_ui/example/android/app/src/main/java/com/example/flowy_infra_ui_example/MainActivity.java b/frontend/app_flowy/packages/flowy_infra_ui/example/android/app/src/main/java/com/example/flowy_infra_ui_example/MainActivity.java
deleted file mode 100644
index 8adb012232..0000000000
--- a/frontend/app_flowy/packages/flowy_infra_ui/example/android/app/src/main/java/com/example/flowy_infra_ui_example/MainActivity.java
+++ /dev/null
@@ -1,7 +0,0 @@
-package com.example.flowy_infra_ui_example;
-
-import io.flutter.embedding.android.FlutterActivity;
-
-public class MainActivity extends FlutterActivity {
-
-}
diff --git a/frontend/app_flowy/packages/flowy_infra_ui/example/android/build.gradle b/frontend/app_flowy/packages/flowy_infra_ui/example/android/build.gradle
index 3dd86e4db3..cb243569ed 100644
--- a/frontend/app_flowy/packages/flowy_infra_ui/example/android/build.gradle
+++ b/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()
diff --git a/frontend/app_flowy/packages/flowy_infra_ui/example/android/settings.gradle b/frontend/app_flowy/packages/flowy_infra_ui/example/android/settings.gradle
index 44e62bcf06..e15f18b2ec 100644
--- a/frontend/app_flowy/packages/flowy_infra_ui/example/android/settings.gradle
+++ b/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
+}
\ No newline at end of file
diff --git a/frontend/app_flowy/packages/flowy_infra_ui/example/example/android/app/src/main/java/com/example/flowy_infra_ui_example/FlutterActivity.java b/frontend/app_flowy/packages/flowy_infra_ui/example/example/android/app/src/main/java/com/example/flowy_infra_ui_example/FlutterActivity.java
new file mode 100644
index 0000000000..33c3ea5970
--- /dev/null
+++ b/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 {
+}
diff --git a/frontend/app_flowy/packages/flowy_sdk/android/build.gradle b/frontend/app_flowy/packages/flowy_sdk/android/build.gradle
index 52a1508a46..f28d45b3a1 100644
--- a/frontend/app_flowy/packages/flowy_sdk/android/build.gradle
+++ b/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'
diff --git a/frontend/app_flowy/packages/flowy_sdk/example/android/app/build.gradle b/frontend/app_flowy/packages/flowy_sdk/example/android/app/build.gradle
index cccedb641b..aa5daf1e9d 100644
--- a/frontend/app_flowy/packages/flowy_sdk/example/android/app/build.gradle
+++ b/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
}
diff --git a/frontend/app_flowy/packages/flowy_sdk/example/android/build.gradle b/frontend/app_flowy/packages/flowy_sdk/example/android/build.gradle
index c505a86352..714549c265 100644
--- a/frontend/app_flowy/packages/flowy_sdk/example/android/build.gradle
+++ b/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()
diff --git a/frontend/app_flowy/packages/flowy_sdk/lib/ffi.dart b/frontend/app_flowy/packages/flowy_sdk/lib/ffi.dart
index 0ade770a23..5ced5b2e83 100644
--- a/frontend/app_flowy/packages/flowy_sdk/lib/ffi.dart
+++ b/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,
);
diff --git a/frontend/rust-lib/.cargo/config.toml b/frontend/rust-lib/.cargo/config.toml
index 06a85fae37..5be8246f16 100644
--- a/frontend/rust-lib/.cargo/config.toml
+++ b/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"]
\ No newline at end of file
+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"
\ No newline at end of file
diff --git a/frontend/rust-lib/Cargo.lock b/frontend/rust-lib/Cargo.lock
index 4119cc1edf..c2d3fa7339 100644
--- a/frontend/rust-lib/Cargo.lock
+++ b/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",
]
diff --git a/frontend/rust-lib/dart-ffi/Cargo.toml b/frontend/rust-lib/dart-ffi/Cargo.toml
index 44fd254cbb..117d78c064 100644
--- a/frontend/rust-lib/dart-ffi/Cargo.toml
+++ b/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"] }
\ No newline at end of file
+lib-infra = { path = "../../../shared-lib/lib-infra", features = ["protobuf_file_gen", "dart"] }
diff --git a/frontend/rust-lib/lib-sqlite/Cargo.toml b/frontend/rust-lib/lib-sqlite/Cargo.toml
index 6536a19a56..ea45b7d6ae 100644
--- a/frontend/rust-lib/lib-sqlite/Cargo.toml
+++ b/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"]
\ No newline at end of file
diff --git a/frontend/scripts/makefile/desktop.toml b/frontend/scripts/makefile/desktop.toml
index 458801ee26..09b1680f3f 100644
--- a/frontend/scripts/makefile/desktop.toml
+++ b/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 = [