Initial MeshPort SDK and cross-platform client

This commit is contained in:
shenlei
2026-10-10 15:16:32 +09:00
commit e73e599165
664 changed files with 209894 additions and 0 deletions
+14
View File
@@ -0,0 +1,14 @@
gradle-wrapper.jar
/.gradle
/captures/
/gradlew
/gradlew.bat
/local.properties
GeneratedPluginRegistrant.java
.cxx/
# Remember to never publicly share your keystore.
# See https://flutter.dev/to/reference-keystore
key.properties
**/*.keystore
**/*.jks
@@ -0,0 +1,53 @@
plugins {
id("com.android.application")
id("kotlin-android")
// The Flutter Gradle Plugin must be applied after the Android and Kotlin Gradle plugins.
id("dev.flutter.flutter-gradle-plugin")
}
android {
buildFeatures { buildConfig = true }
namespace = "com.example.meshport_lab"
compileSdk = flutter.compileSdkVersion
ndkVersion = "28.2.13676358"
compileOptions {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}
kotlinOptions {
jvmTarget = JavaVersion.VERSION_17.toString()
}
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId = "com.example.meshport_lab"
// You can update the following values to match your application needs.
// For more information, see: https://flutter.dev/to/review-gradle-config.
minSdk = 26
ndk { abiFilters += listOf("arm64-v8a") }
externalNativeBuild { cmake {
arguments += "-DANDROID_STL=c++_shared"
abiFilters += "arm64-v8a"
} }
targetSdk = flutter.targetSdkVersion
versionCode = flutter.versionCode
versionName = flutter.versionName
}
buildTypes {
debug { ndk { abiFilters.clear(); abiFilters += "arm64-v8a" } }
release {
proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro")
// TODO: Add your own signing config for the release build.
// Signing with the debug keys for now, so `flutter run --release` works.
signingConfig = signingConfigs.getByName("debug")
}
}
externalNativeBuild { cmake { path = file("src/main/cpp/CMakeLists.txt"); version = "3.22.1" } }
}
flutter {
source = "../.."
}
+2
View File
@@ -0,0 +1,2 @@
# JNI resolves this class and static callback by name.
-keep class com.example.meshport_lab.NativeBridge { *; }
@@ -0,0 +1,7 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<!-- The INTERNET permission is required for development. Specifically,
the Flutter tool needs it to communicate with the running application
to allow setting breakpoints, to provide hot reload, etc.
-->
<uses-permission android:name="android.permission.INTERNET"/>
</manifest>
@@ -0,0 +1,54 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_SPECIAL_USE" />
<application
android:allowBackup="false"
android:label="MeshPort"
android:name="${applicationName}"
android:icon="@mipmap/ic_launcher">
<service android:name=".MeshVpnService" android:exported="false"
android:permission="android.permission.BIND_VPN_SERVICE" android:foregroundServiceType="specialUse">
<intent-filter><action android:name="android.net.VpnService" /></intent-filter>
<property android:name="android.app.PROPERTY_SPECIAL_USE_FGS_SUBTYPE" android:value="User initiated mesh networking VPN" />
</service>
<activity
android:name=".MainActivity"
android:exported="true"
android:launchMode="singleTop"
android:taskAffinity=""
android:theme="@style/LaunchTheme"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
android:hardwareAccelerated="true"
android:windowSoftInputMode="adjustResize">
<!-- Specifies an Android theme to apply to this Activity as soon as
the Android process has started. This theme is visible to the user
while the Flutter UI initializes. After that, this theme continues
to determine the Window background behind the Flutter UI. -->
<meta-data
android:name="io.flutter.embedding.android.NormalTheme"
android:resource="@style/NormalTheme"
/>
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<!-- Don't delete the meta-data below.
This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
<meta-data
android:name="flutterEmbedding"
android:value="2" />
</application>
<!-- Required to query activities that can process text, see:
https://developer.android.com/training/package-visibility and
https://developer.android.com/reference/android/content/Intent#ACTION_PROCESS_TEXT.
In particular, this is used by the Flutter engine in io.flutter.plugin.text.ProcessTextPlugin. -->
<queries>
<intent>
<action android:name="android.intent.action.PROCESS_TEXT"/>
<data android:mimeType="text/plain"/>
</intent>
</queries>
</manifest>
@@ -0,0 +1,7 @@
cmake_minimum_required(VERSION 3.22.1)
project(meshport_android)
add_library(meshport_ffi SHARED IMPORTED)
set_target_properties(meshport_ffi PROPERTIES IMPORTED_LOCATION "${CMAKE_CURRENT_SOURCE_DIR}/../jniLibs/${ANDROID_ABI}/libmeshport_ffi.so")
add_library(meshport_android SHARED bridge.cpp)
target_link_libraries(meshport_android meshport_ffi)
target_link_options(meshport_android PRIVATE "-Wl,-z,max-page-size=16384")
@@ -0,0 +1,59 @@
#include <jni.h>
#include <cstdint>
#include <cstring>
#include <string>
extern "C" {
uint64_t meshport_context_new();
void meshport_context_free(uint64_t);
char* meshport_call(uint64_t, const char*);
void meshport_string_free(char*);
void meshport_set_android_socket_protector(bool (*callback)(int));
}
static JavaVM* vm;
static jclass bridge;
static jmethodID protectMethod;
static bool protectSocket(int fd) {
JNIEnv* env = nullptr;
bool attached = vm->GetEnv(reinterpret_cast<void**>(&env), JNI_VERSION_1_6) == JNI_EDETACHED;
if (attached && vm->AttachCurrentThread(&env, nullptr) != JNI_OK) return false;
bool ok = env && env->CallStaticBooleanMethod(bridge, protectMethod, fd);
if (env && env->ExceptionCheck()) { env->ExceptionClear(); ok = false; }
if (attached) vm->DetachCurrentThread();
return ok;
}
extern "C" JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM* value, void*) {
vm = value;
JNIEnv* env = nullptr;
if (vm->GetEnv(reinterpret_cast<void**>(&env), JNI_VERSION_1_6) != JNI_OK) return JNI_ERR;
auto cls = env->FindClass("com/example/meshport_lab/NativeBridge");
if (!cls) return JNI_ERR;
bridge = static_cast<jclass>(env->NewGlobalRef(cls));
protectMethod = env->GetStaticMethodID(bridge, "protectFd", "(I)Z");
if (!protectMethod) return JNI_ERR;
meshport_set_android_socket_protector(protectSocket);
return JNI_VERSION_1_6;
}
extern "C" JNIEXPORT jlong JNICALL Java_com_example_meshport_1lab_NativeBridge_newContext(JNIEnv*, jobject) {
return static_cast<jlong>(meshport_context_new());
}
extern "C" JNIEXPORT void JNICALL Java_com_example_meshport_1lab_NativeBridge_freeContext(JNIEnv*, jobject, jlong handle) {
meshport_context_free(static_cast<uint64_t>(handle));
}
extern "C" JNIEXPORT jstring JNICALL Java_com_example_meshport_1lab_NativeBridge_call(JNIEnv* env, jobject, jlong handle, jstring text) {
auto stringClass = env->FindClass("java/lang/String");
auto charset = env->NewStringUTF("UTF-8");
auto getBytes = env->GetMethodID(stringClass, "getBytes", "(Ljava/lang/String;)[B");
auto bytes = static_cast<jbyteArray>(env->CallObjectMethod(text, getBytes, charset));
if (!bytes || env->ExceptionCheck()) return nullptr;
auto size = env->GetArrayLength(bytes);
if (size > 131072) return env->NewStringUTF("{\"ok\":false,\"error\":\"Request too large\"}");
std::string input(size, '\0');
env->GetByteArrayRegion(bytes, 0, size, reinterpret_cast<jbyte*>(input.data()));
char* response = meshport_call(static_cast<uint64_t>(handle), input.c_str());
if (!response) return nullptr;
auto output = env->NewByteArray(static_cast<jsize>(strlen(response)));
env->SetByteArrayRegion(output, 0, env->GetArrayLength(output), reinterpret_cast<jbyte*>(response));
meshport_string_free(response);
auto constructor = env->GetMethodID(stringClass, "<init>", "([BLjava/lang/String;)V");
return static_cast<jstring>(env->NewObject(stringClass, constructor, output, charset));
}
@@ -0,0 +1,92 @@
package com.example.meshport_lab
import io.flutter.embedding.android.FlutterActivity
import io.flutter.embedding.engine.FlutterEngine
import io.flutter.plugin.common.MethodChannel
import android.app.Activity
import android.content.Intent
import android.net.VpnService
import android.os.Handler
import android.os.Looper
import org.json.JSONObject
import java.util.concurrent.Executors
class MainActivity : FlutterActivity() {
private val background = Executors.newSingleThreadExecutor()
private val main = Handler(Looper.getMainLooper())
private var permissionResult: MethodChannel.Result? = null
override fun configureFlutterEngine(flutterEngine: FlutterEngine) {
super.configureFlutterEngine(flutterEngine)
MethodChannel(flutterEngine.dartExecutor.binaryMessenger, "meshport/system_vpn").setMethodCallHandler { call, result ->
if (call.method == "prepare_android_vpn") {
if (permissionResult != null) { result.error("VPN_BUSY", "VPN authorization pending", null); return@setMethodCallHandler }
val intent = VpnService.prepare(this)
if (intent == null) result.success(null)
else { permissionResult = result; startActivityForResult(intent, 1001) }
return@setMethodCallHandler
}
background.execute {
try {
val profiles = ProfileStore(this)
when (call.method) {
"load_profile" -> { val value = profiles.load(); main.post { result.success(value) } }
"save_profile" -> { profiles.save(call.arguments as String); main.post { result.success(null) } }
"delete_profile" -> { profiles.delete(); main.post { result.success(null) } }
"debug_storage_self_test" -> {
check(BuildConfig.DEBUG)
val isolated = ProfileStore(this, "device_validation")
try {
isolated.save("MeshPort 测试 🌍 test-only")
check(ProfileStore(this, "device_validation").load() == "MeshPort 测试 🌍 test-only")
isolated.delete(); check(isolated.load() == null)
main.post { result.success(true) }
} finally { isolated.delete() }
}
"android_vpn_request" -> {
val request = JSONObject(call.arguments as String)
require(request.toString().toByteArray(Charsets.UTF_8).size <= 131072)
if (request.getString("op") == "start" && MeshVpnService.current == null) {
check(VpnService.prepare(this) == null) { "Android VPN authorization required" }
startForegroundService(Intent(this, MeshVpnService::class.java))
for (attempt in 0 until 100) {
if (MeshVpnService.current != null) break
Thread.sleep(50)
}
}
val service = MeshVpnService.current
if (service == null) {
check(request.getString("op") in listOf("stop", "status", "diagnostics_enable")) { "VPN service not running" }
val data = JSONObject().put("state", "Stopped").put("peer_count", 0).put("enabled", false)
val reply = JSONObject().put("ok", true).put("data", data).toString()
main.post { result.success(reply) }
} else {
service.worker.execute {
try {
val reply = service.request(request).toString()
main.post { result.success(reply) }
} catch (error: Exception) { main.post { result.error("VPN_REQUEST", error.message, null) } }
}
}
}
else -> main.post { result.notImplemented() }
}
} catch (error: Exception) { main.post { result.error("PLATFORM_REQUEST", error.message, null) } }
}
}
}
@Deprecated("Legacy VPN permission result")
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
super.onActivityResult(requestCode, resultCode, data)
if (requestCode == 1001) {
val pending = permissionResult; permissionResult = null
if (resultCode == Activity.RESULT_OK) pending?.success(null)
else pending?.error("VPN_DENIED", "Android VPN authorization cancelled", null)
}
}
override fun onDestroy() {
permissionResult?.error("VPN_CANCELLED", "Activity closed during VPN authorization", null)
permissionResult = null
background.shutdown()
super.onDestroy()
}
}
@@ -0,0 +1,129 @@
package com.example.meshport_lab
import android.app.Notification
import android.app.NotificationChannel
import android.app.NotificationManager
import android.app.PendingIntent
import android.content.Intent
import android.net.VpnService
import android.os.ParcelFileDescriptor
import android.system.OsConstants
import android.util.Log
import org.json.JSONObject
import java.net.InetAddress
import java.util.concurrent.ScheduledThreadPoolExecutor
import java.util.concurrent.TimeUnit
class MeshVpnService : VpnService() {
companion object { @Volatile var current: MeshVpnService? = null; private set }
val worker = ScheduledThreadPoolExecutor(1)
private var handle = 0L
private var tun: ParcelFileDescriptor? = null
private var ipv4 = ""
private var installed = emptyList<String>()
private var running = false
private var failure: String? = null
override fun onCreate() {
super.onCreate()
current = this
val manager = getSystemService(NotificationManager::class.java)
manager.createNotificationChannel(NotificationChannel("meshport_vpn", "MeshPort 组网", NotificationManager.IMPORTANCE_LOW))
val open = PendingIntent.getActivity(this, 0, Intent(this, MainActivity::class.java), PendingIntent.FLAG_IMMUTABLE)
startForeground(77, Notification.Builder(this, "meshport_vpn")
.setContentTitle("MeshPort").setContentText("虚拟组网服务正在运行")
.setSmallIcon(R.drawable.ic_stat_meshport).setContentIntent(open).setOngoing(true).build())
worker.scheduleWithFixedDelay({
if (running) try {
val snapshot = native(JSONObject().put("op", "status")).getJSONObject("data")
val routes = snapshot.getJSONObject("platform_network").getJSONArray("subnet_routes")
val next = (0 until routes.length()).map { routes.getString(it) }.sorted()
if (next != installed) rebuild(next)
} catch (_: Exception) { failure = "VPN 路由更新失败,请重新连接"; shutdown() }
}, 2, 2, TimeUnit.SECONDS)
}
private fun native(request: JSONObject): JSONObject {
check(handle != 0L) { "VPN context not started" }
val response = JSONObject(NativeBridge.call(handle, request.toString()))
check(response.optBoolean("ok")) { response.optString("error", "Native request failed") }
return response
}
fun request(request: JSONObject): JSONObject {
return when (request.getString("op")) {
"start" -> {
check(!running) { "VPN already started" }
failure = null
Log.i("MeshPortVPN", "Creating native VPN context")
handle = NativeBridge.newContext()
try {
val config = request.getString("toml")
val validation = native(JSONObject().put("op", "validate").put("toml", config).put("include_profile", true)).getJSONObject("data")
check(validation.getString("runtime_mode") == "system_vpn")
ipv4 = validation.getJSONObject("profile").getString("ipv4")
Log.i("MeshPortVPN", "Starting native engine")
val result = native(request)
Log.i("MeshPortVPN", "Native engine started")
running = true
rebuild(emptyList())
result
} catch (error: Exception) { shutdown(); stopSelf(); throw error }
}
"stop" -> { shutdown(); stopSelf(); JSONObject().put("ok", true).put("data", JSONObject()) }
"status" -> {
if (!running) JSONObject().put("ok", true).put("data", JSONObject().put("state", if (failure == null) "Stopped" else "Failed").put("peer_count", 0))
else native(request).also { reply ->
reply.getJSONObject("data").getJSONObject("platform_network")
.put("installed_subnet_routes", org.json.JSONArray(installed)).put("route_installation", "android_vpn")
}
}
"diagnostics_enable" -> {
if (handle == 0L) JSONObject().put("ok", true).put("data", JSONObject().put("enabled", false)) else native(request)
}
else -> native(request)
}
}
private fun rebuild(routes: List<String>) {
val parts = ipv4.split('/')
val address = parts[0]
val prefix = if (parts.size == 2) parts[1].toInt() else 24
val raw = InetAddress.getByName(address).address
val network = raw.mapIndexed { index, byte ->
val bits = (prefix - index * 8).coerceIn(0, 8)
(byte.toInt() and (0xff shl (8 - bits))).and(0xff)
}.joinToString(".")
val builder = Builder().setSession("MeshPort").setMtu(1280)
.addAddress(address, prefix).addRoute(network, prefix).allowFamily(OsConstants.AF_INET6)
for (route in routes) {
val cidr = route.split('/')
builder.addRoute(cidr[0], cidr[1].toInt())
}
Log.i("MeshPortVPN", "Establishing TUN with ${routes.size} learned routes")
val next = builder.establish() ?: error("Android VPN authorization revoked")
val previous = tun
try {
Log.i("MeshPortVPN", "Attaching TUN to native engine")
native(JSONObject().put("op", "attach_tun").put("fd", next.fd))
var ready = false
for (attempt in 0 until 50) {
val state = native(JSONObject().put("op", "status")).getJSONObject("data")
if (state.getJSONObject("platform_network").optBoolean("ready")) { ready = true; break }
Thread.sleep(100)
}
check(ready) { "Native TUN attachment timed out" }
Log.i("MeshPortVPN", "TUN ready")
tun = next
installed = routes
previous?.close()
} catch (error: Exception) { next.close(); throw error }
}
private fun shutdown() {
running = false
if (handle != 0L) { NativeBridge.freeContext(handle); handle = 0L }
tun?.close(); tun = null; installed = emptyList()
}
override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int = START_NOT_STICKY
override fun onRevoke() { worker.execute { shutdown(); stopSelf() } }
override fun onDestroy() {
worker.execute { shutdown(); if (current === this) current = null; worker.shutdown() }
super.onDestroy()
}
}
@@ -0,0 +1,9 @@
package com.example.meshport_lab
object NativeBridge {
init { System.loadLibrary("meshport_android") }
external fun newContext(): Long
external fun freeContext(handle: Long)
external fun call(handle: Long, request: String): String
@JvmStatic fun protectFd(fd: Int): Boolean = MeshVpnService.current?.protect(fd) ?: true
}
@@ -0,0 +1,40 @@
package com.example.meshport_lab
import android.content.Context
import android.security.keystore.KeyGenParameterSpec
import android.security.keystore.KeyProperties
import android.util.Base64
import java.security.KeyStore
import javax.crypto.Cipher
import javax.crypto.KeyGenerator
import javax.crypto.SecretKey
import javax.crypto.spec.GCMParameterSpec
class ProfileStore(context: Context, namespace: String = "profile") {
private val prefs = context.getSharedPreferences("meshport_$namespace", Context.MODE_PRIVATE)
private val alias = "MeshPort.Network.$namespace"
private fun key(): SecretKey {
val store = KeyStore.getInstance("AndroidKeyStore").apply { load(null) }
(store.getKey(alias, null) as? SecretKey)?.let { return it }
return KeyGenerator.getInstance(KeyProperties.KEY_ALGORITHM_AES, "AndroidKeyStore").apply {
init(KeyGenParameterSpec.Builder(alias, KeyProperties.PURPOSE_ENCRYPT or KeyProperties.PURPOSE_DECRYPT)
.setBlockModes(KeyProperties.BLOCK_MODE_GCM).setEncryptionPaddings(KeyProperties.ENCRYPTION_PADDING_NONE).build())
}.generateKey()
}
fun save(config: String) {
require(config.toByteArray(Charsets.UTF_8).size <= 65536)
val cipher = Cipher.getInstance("AES/GCM/NoPadding")
cipher.init(Cipher.ENCRYPT_MODE, key())
val data = cipher.doFinal(config.toByteArray(Charsets.UTF_8))
check(prefs.edit().putString("data", Base64.encodeToString(data, Base64.NO_WRAP))
.putString("iv", Base64.encodeToString(cipher.iv, Base64.NO_WRAP)).commit())
}
fun load(): String? {
val data = prefs.getString("data", null) ?: return null
val iv = prefs.getString("iv", null) ?: error("Missing profile IV")
val cipher = Cipher.getInstance("AES/GCM/NoPadding")
cipher.init(Cipher.DECRYPT_MODE, key(), GCMParameterSpec(128, Base64.decode(iv, Base64.NO_WRAP)))
return cipher.doFinal(Base64.decode(data, Base64.NO_WRAP)).toString(Charsets.UTF_8)
}
fun delete() { check(prefs.edit().clear().commit()) }
}
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Modify this file to customize your launch splash screen -->
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="?android:colorBackground" />
<!-- You can insert your own image assets here -->
<!-- <item>
<bitmap
android:gravity="center"
android:src="@mipmap/launch_image" />
</item> -->
</layer-list>
@@ -0,0 +1,3 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android" android:width="24dp" android:height="24dp" android:viewportWidth="24" android:viewportHeight="24">
<path android:fillColor="#FFFFFFFF" android:pathData="M3,4h4l5,5 5,-5h4v16h-4V9l-5,5 -5,-5v11H3z" />
</vector>
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Modify this file to customize your launch splash screen -->
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@android:color/white" />
<!-- You can insert your own image assets here -->
<!-- <item>
<bitmap
android:gravity="center"
android:src="@mipmap/launch_image" />
</item> -->
</layer-list>
Binary file not shown.

After

Width:  |  Height:  |  Size: 8.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 41 KiB

@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- Theme applied to the Android Window while the process is starting when the OS's Dark Mode setting is on -->
<style name="LaunchTheme" parent="@android:style/Theme.Black.NoTitleBar">
<!-- Show a splash screen on the activity. Automatically removed when
the Flutter engine draws its first frame -->
<item name="android:windowBackground">@drawable/launch_background</item>
</style>
<!-- Theme applied to the Android Window as soon as the process has started.
This theme determines the color of the Android Window while your
Flutter UI initializes, as well as behind your Flutter UI while its
running.
This Theme is only used starting with V2 of Flutter's Android embedding. -->
<style name="NormalTheme" parent="@android:style/Theme.Black.NoTitleBar">
<item name="android:windowBackground">?android:colorBackground</item>
</style>
</resources>
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- Theme applied to the Android Window while the process is starting when the OS's Dark Mode setting is off -->
<style name="LaunchTheme" parent="@android:style/Theme.Light.NoTitleBar">
<!-- Show a splash screen on the activity. Automatically removed when
the Flutter engine draws its first frame -->
<item name="android:windowBackground">@drawable/launch_background</item>
</style>
<!-- Theme applied to the Android Window as soon as the process has started.
This theme determines the color of the Android Window while your
Flutter UI initializes, as well as behind your Flutter UI while its
running.
This Theme is only used starting with V2 of Flutter's Android embedding. -->
<style name="NormalTheme" parent="@android:style/Theme.Light.NoTitleBar">
<item name="android:windowBackground">?android:colorBackground</item>
</style>
</resources>
@@ -0,0 +1,7 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<!-- The INTERNET permission is required for development. Specifically,
the Flutter tool needs it to communicate with the running application
to allow setting breakpoints, to provide hot reload, etc.
-->
<uses-permission android:name="android.permission.INTERNET"/>
</manifest>
@@ -0,0 +1,24 @@
allprojects {
repositories {
google()
mavenCentral()
}
}
val newBuildDir: Directory =
rootProject.layout.buildDirectory
.dir("../../build")
.get()
rootProject.layout.buildDirectory.value(newBuildDir)
subprojects {
val newSubprojectBuildDir: Directory = newBuildDir.dir(project.name)
project.layout.buildDirectory.value(newSubprojectBuildDir)
}
subprojects {
project.evaluationDependsOn(":app")
}
tasks.register<Delete>("clean") {
delete(rootProject.layout.buildDirectory)
}
@@ -0,0 +1,2 @@
org.gradle.jvmargs=-Xmx8G -XX:MaxMetaspaceSize=4G -XX:ReservedCodeCacheSize=512m -XX:+HeapDumpOnOutOfMemoryError
android.useAndroidX=true
@@ -0,0 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14-all.zip
@@ -0,0 +1,26 @@
pluginManagement {
val flutterSdkPath =
run {
val properties = java.util.Properties()
file("local.properties").inputStream().use { properties.load(it) }
val flutterSdkPath = properties.getProperty("flutter.sdk")
require(flutterSdkPath != null) { "flutter.sdk not set in local.properties" }
flutterSdkPath
}
includeBuild("$flutterSdkPath/packages/flutter_tools/gradle")
repositories {
google()
mavenCentral()
gradlePluginPortal()
}
}
plugins {
id("dev.flutter.flutter-plugin-loader") version "1.0.0"
id("com.android.application") version "8.11.1" apply false
id("org.jetbrains.kotlin.android") version "2.2.20" apply false
}
include(":app")