android flutter plugin
This commit is contained in:
1
veilid-flutter/android/.gitignore
vendored
1
veilid-flutter/android/.gitignore
vendored
@@ -6,3 +6,4 @@
|
||||
.DS_Store
|
||||
/build
|
||||
/captures
|
||||
.cxx
|
||||
|
3
veilid-flutter/android/CMakeLists.txt
Normal file
3
veilid-flutter/android/CMakeLists.txt
Normal file
@@ -0,0 +1,3 @@
|
||||
cmake_minimum_required(VERSION 3.1)
|
||||
project(cpplink CXX)
|
||||
add_library(cpplink cpplink.cpp)
|
@@ -1,6 +1,3 @@
|
||||
group 'com.veilid.veilid'
|
||||
version '1.0-SNAPSHOT'
|
||||
|
||||
buildscript {
|
||||
ext.kotlin_version = '1.3.50'
|
||||
repositories {
|
||||
@@ -14,6 +11,13 @@ buildscript {
|
||||
}
|
||||
}
|
||||
|
||||
plugins {
|
||||
id "org.mozilla.rust-android-gradle.rust-android" version "0.9.0"
|
||||
}
|
||||
|
||||
group 'com.veilid.veilid'
|
||||
version '1.0-SNAPSHOT'
|
||||
|
||||
rootProject.allprojects {
|
||||
repositories {
|
||||
google()
|
||||
@@ -41,10 +45,60 @@ android {
|
||||
}
|
||||
|
||||
defaultConfig {
|
||||
minSdkVersion 16
|
||||
minSdkVersion 24
|
||||
targetSdkVersion 30
|
||||
versionCode 1
|
||||
versionName "1.0"
|
||||
|
||||
ndk {
|
||||
abiFilters 'armeabi-v7a', 'arm64-v8a', 'x86', 'x86_64'
|
||||
}
|
||||
|
||||
// Required to copy libc++_shared.so
|
||||
externalNativeBuild {
|
||||
cmake {
|
||||
arguments "-DANDROID_STL=c++_shared"
|
||||
targets "cpplink"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ndkVersion '22.0.7026061'
|
||||
|
||||
// Required to copy libc++_shared.so
|
||||
externalNativeBuild {
|
||||
cmake {
|
||||
path file('CMakeLists.txt')
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
|
||||
}
|
||||
|
||||
apply plugin: 'org.mozilla.rust-android-gradle.rust-android'
|
||||
|
||||
cargo {
|
||||
module = "../rust"
|
||||
libname = "veilid_flutter"
|
||||
targets = ["arm", "arm64", "x86", "x86_64"]
|
||||
targetDirectory = "../../target"
|
||||
prebuiltToolchains = true
|
||||
profile = gradle.startParameter.taskNames.any{it.toLowerCase().contains("debug")} ? "debug" : "release"
|
||||
// features {
|
||||
// defaultAnd("android_tests")
|
||||
// }
|
||||
}
|
||||
|
||||
afterEvaluate {
|
||||
// The `cargoBuild` task isn't available until after evaluation.
|
||||
android.libraryVariants.all { variant ->
|
||||
def productFlavor = ""
|
||||
variant.productFlavors.each {
|
||||
productFlavor += "${it.name.capitalize()}"
|
||||
}
|
||||
def buildType = "${variant.buildType.name.capitalize()}"
|
||||
tasks["generate${productFlavor}${buildType}Assets"].dependsOn(tasks["cargoBuild"])
|
||||
}
|
||||
}
|
||||
|
0
veilid-flutter/android/cpplink.cpp
Normal file
0
veilid-flutter/android/cpplink.cpp
Normal file
@@ -14,22 +14,22 @@ class VeilidPlugin: FlutterPlugin, MethodCallHandler {
|
||||
///
|
||||
/// This local reference serves to register the plugin with the Flutter Engine and unregister it
|
||||
/// when the Flutter Engine is detached from the Activity
|
||||
private lateinit var channel : MethodChannel
|
||||
// private lateinit var channel : MethodChannel
|
||||
|
||||
override fun onAttachedToEngine(@NonNull flutterPluginBinding: FlutterPlugin.FlutterPluginBinding) {
|
||||
channel = MethodChannel(flutterPluginBinding.binaryMessenger, "veilid")
|
||||
channel.setMethodCallHandler(this)
|
||||
// channel = MethodChannel(flutterPluginBinding.binaryMessenger, "veilid")
|
||||
// channel.setMethodCallHandler(this)
|
||||
}
|
||||
|
||||
override fun onMethodCall(@NonNull call: MethodCall, @NonNull result: Result) {
|
||||
if (call.method == "getPlatformVersion") {
|
||||
result.success("Android ${android.os.Build.VERSION.RELEASE}")
|
||||
} else {
|
||||
result.notImplemented()
|
||||
}
|
||||
// if (call.method == "getPlatformVersion") {
|
||||
// result.success("Android ${android.os.Build.VERSION.RELEASE}")
|
||||
// } else {
|
||||
result.notImplemented()
|
||||
// }
|
||||
}
|
||||
|
||||
override fun onDetachedFromEngine(@NonNull binding: FlutterPlugin.FlutterPluginBinding) {
|
||||
channel.setMethodCallHandler(null)
|
||||
// channel.setMethodCallHandler(null)
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user