mirror of
https://github.com/GitJournal/GitJournal.git
synced 2025-06-30 03:19:11 +08:00
Add POC Android JNI integration
I want to stop using jgit and instead of libgit2 instead. I feel far more confident with the latter, and I need to use it for ios anyway. Currently I cannot use the latest version of jgit as that requires a higher minSDKVersion, and I want to target older android devices as well.
This commit is contained in:
@ -44,6 +44,11 @@ android {
|
|||||||
versionCode flutterVersionCode.toInteger()
|
versionCode flutterVersionCode.toInteger()
|
||||||
versionName flutterVersionName
|
versionName flutterVersionName
|
||||||
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
|
||||||
|
externalNativeBuild {
|
||||||
|
cmake {
|
||||||
|
cppFlags ""
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
signingConfigs {
|
signingConfigs {
|
||||||
@ -59,6 +64,11 @@ android {
|
|||||||
signingConfig signingConfigs.release
|
signingConfig signingConfigs.release
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
externalNativeBuild {
|
||||||
|
cmake {
|
||||||
|
path "src/main/cpp/CMakeLists.txt"
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
flutter {
|
flutter {
|
||||||
|
6
android/app/src/main/cpp/CMakeLists.txt
Normal file
6
android/app/src/main/cpp/CMakeLists.txt
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
cmake_minimum_required(VERSION 3.4.1)
|
||||||
|
|
||||||
|
|
||||||
|
add_library( native-lib
|
||||||
|
SHARED
|
||||||
|
native-lib.cpp )
|
10
android/app/src/main/cpp/native-lib.cpp
Normal file
10
android/app/src/main/cpp/native-lib.cpp
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
#include <jni.h>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
extern "C" JNIEXPORT jstring JNICALL
|
||||||
|
Java_io_gitjournal_gitjournal_MainActivity_stringFromJNI(
|
||||||
|
JNIEnv* env,
|
||||||
|
jobject /* this */) {
|
||||||
|
std::string hello = "Hello from C++";
|
||||||
|
return env->NewStringUTF(hello.c_str());
|
||||||
|
}
|
@ -21,11 +21,24 @@ import io.flutter.util.PathUtils;
|
|||||||
// For MethodChannel
|
// For MethodChannel
|
||||||
|
|
||||||
public class MainActivity extends FlutterActivity implements MethodCallHandler {
|
public class MainActivity extends FlutterActivity implements MethodCallHandler {
|
||||||
|
static {
|
||||||
|
System.loadLibrary("native-lib");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A native method that is implemented by the 'native-lib' native library,
|
||||||
|
* which is packaged with this application.
|
||||||
|
*/
|
||||||
|
public native String stringFromJNI();
|
||||||
|
|
||||||
|
|
||||||
private static final String CHANNEL_NAME = "gitjournal.io/git";
|
private static final String CHANNEL_NAME = "gitjournal.io/git";
|
||||||
static MethodChannel channel;
|
static MethodChannel channel;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
Log.d("VISH", stringFromJNI());
|
||||||
|
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
GeneratedPluginRegistrant.registerWith(this);
|
GeneratedPluginRegistrant.registerWith(this);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user