From 58655531f07f8676a15f7e5dcb5204b1a647e21c Mon Sep 17 00:00:00 2001 From: tajniak81 <13187254+tajniak81@users.noreply.github.com> Date: Tue, 21 Jul 2026 21:11:17 +0200 Subject: [PATCH] Give the Fly App its own identity instead of the DJI sample's MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The app still shipped under the identity of the DJI MSDK Flutter sample it was started from, so every install, log line and crash report named a DJI sample rather than PilotVault. Rename both namespaces: Android com.dji.flutter.dji_msdk_sample -> com.pilotvault.flyapp Dart dji_msdk_sample -> pilotvault_fly The Kotlin sources move under com/pilotvault/flyapp to match. The manifest's meta-data name stays com.dji.sdk.API_KEY — that string is fixed by the SDK's own lookup and is not ours to rename. A DJI App Key is bound to the application id, so the old key died with the old id and a new one was registered against com.pilotvault.flyapp. That forced the key to be touched anyway, so stop committing it: the Gradle property becomes PILOTVAULT_FLY_API_KEY and now lives in the developer's ~/.gradle/gradle.properties, which Gradle merges into every build. android/gradle.properties keeps the build flags — gitignoring it wholesale would have taken useAndroidX and the Flutter migrator flags out of version control with it — and documents where the key belongs. A missing key prints a banner rather than silently baking the placeholder into an APK that cannot register, which otherwise only surfaces as a registration failure once the tablet is out at the aircraft. That warning uses println because `flutter build` filters Gradle's warn-level output. The rename means Android treats this as a new app: uninstall com.dji.flutter.dji_msdk_sample before installing, or both will sit on the tablet. Co-Authored-By: Claude Opus 4.8 --- Fly App/README.md | 20 ++++++++++++--- Fly App/android/app/build.gradle | 25 +++++++++++++++---- .../android/app/src/main/AndroidManifest.xml | 6 +++-- .../flyapp}/AccountBridge.kt | 2 +- .../flyapp}/CameraBridge.kt | 2 +- .../flyapp}/DjiApplication.kt | 2 +- .../flyapp}/DjiSdkBridge.kt | 2 +- .../flyapp}/DjiVideoView.kt | 2 +- .../flyapp}/FlightControllerBridge.kt | 2 +- .../flyapp}/GimbalBridge.kt | 2 +- .../flyapp}/MainActivity.kt | 2 +- .../flyapp}/MediaBridge.kt | 2 +- .../flyapp}/MissionBridge.kt | 2 +- Fly App/android/gradle.properties | 17 +++++++++---- .../pubspec_pocketbase.yaml | 2 +- Fly App/lib/ui/map_page.dart | 2 +- Fly App/pubspec.yaml | 2 +- Fly App/test/widget_test.dart | 2 +- 18 files changed, 66 insertions(+), 30 deletions(-) rename Fly App/android/app/src/main/kotlin/com/{dji/flutter/dji_msdk_sample => pilotvault/flyapp}/AccountBridge.kt (98%) rename Fly App/android/app/src/main/kotlin/com/{dji/flutter/dji_msdk_sample => pilotvault/flyapp}/CameraBridge.kt (99%) rename Fly App/android/app/src/main/kotlin/com/{dji/flutter/dji_msdk_sample => pilotvault/flyapp}/DjiApplication.kt (94%) rename Fly App/android/app/src/main/kotlin/com/{dji/flutter/dji_msdk_sample => pilotvault/flyapp}/DjiSdkBridge.kt (99%) rename Fly App/android/app/src/main/kotlin/com/{dji/flutter/dji_msdk_sample => pilotvault/flyapp}/DjiVideoView.kt (98%) rename Fly App/android/app/src/main/kotlin/com/{dji/flutter/dji_msdk_sample => pilotvault/flyapp}/FlightControllerBridge.kt (99%) rename Fly App/android/app/src/main/kotlin/com/{dji/flutter/dji_msdk_sample => pilotvault/flyapp}/GimbalBridge.kt (97%) rename Fly App/android/app/src/main/kotlin/com/{dji/flutter/dji_msdk_sample => pilotvault/flyapp}/MainActivity.kt (98%) rename Fly App/android/app/src/main/kotlin/com/{dji/flutter/dji_msdk_sample => pilotvault/flyapp}/MediaBridge.kt (99%) rename Fly App/android/app/src/main/kotlin/com/{dji/flutter/dji_msdk_sample => pilotvault/flyapp}/MissionBridge.kt (99%) diff --git a/Fly App/README.md b/Fly App/README.md index 38f706d..9845fc8 100644 --- a/Fly App/README.md +++ b/Fly App/README.md @@ -46,17 +46,29 @@ SDK registration will fail without a valid App Key bound to this app's application id. 1. Sign in at and create a new app. - - **Package name** must be exactly: `com.dji.flutter.dji_msdk_sample` + - **Package name** must be exactly: `com.pilotvault.flyapp` - SDK: **Mobile SDK** 2. Copy the generated **App Key**. -3. Paste it into [`android/gradle.properties`](android/gradle.properties): +3. Put it in your **user-global** Gradle properties — *not* in the repo. Gradle + merges this file into every build, so the key stays off version control: + + - Linux/macOS: `~/.gradle/gradle.properties` + - Windows: `%USERPROFILE%\.gradle\gradle.properties` ```properties - DJI_API_KEY=your_real_app_key_here + PILOTVAULT_FLY_API_KEY=your_real_app_key_here + ``` + + For a one-off build you can pass it inline instead: + + ```bash + flutter build apk --debug -PPILOTVAULT_FLY_API_KEY=your_real_app_key_here ``` The key is injected into `AndroidManifest.xml` at build time via a - `manifestPlaceholder` (`com.dji.sdk.API_KEY`). + `manifestPlaceholder` (`com.dji.sdk.API_KEY`). If it is missing the build + still succeeds but prints a warning, and SDK registration fails on the + aircraft — so watch for that warning. ## Run diff --git a/Fly App/android/app/build.gradle b/Fly App/android/app/build.gradle index 9805838..8411ad6 100644 --- a/Fly App/android/app/build.gradle +++ b/Fly App/android/app/build.gradle @@ -6,7 +6,7 @@ plugins { } android { - namespace = "com.dji.flutter.dji_msdk_sample" + namespace = "com.pilotvault.flyapp" compileSdk = 35 // DJI MSDK V4 ships prebuilt native (.so) libraries; pin a known-good NDK. ndkVersion = flutter.ndkVersion @@ -21,7 +21,7 @@ android { } defaultConfig { - applicationId = "com.dji.flutter.dji_msdk_sample" + applicationId = "com.pilotvault.flyapp" // DJI MSDK V4 requires Android 5.0+ (API 21). minSdkVersion = flutter.minSdkVersion targetSdk = 34 @@ -37,9 +37,24 @@ android { } // The DJI App Key is injected into AndroidManifest.xml at build time. - // Set DJI_API_KEY in android/gradle.properties (or pass -PDJI_API_KEY=...). - manifestPlaceholders["DJI_API_KEY"] = - (project.findProperty("DJI_API_KEY") ?: "PASTE_YOUR_DJI_APP_KEY_HERE") + // It is deliberately not stored in the repo — see android/gradle.properties + // for where to put it (~/.gradle/gradle.properties, or -P on the command + // line). Warn loudly when it is missing: the build still succeeds, but the + // resulting APK fails DJI SDK registration once it is on the aircraft. + // println, not logger.warn: `flutter build` filters Gradle's warn-level + // output, so a logger.warn here is never seen by the person building. + def djiAppKey = project.findProperty("PILOTVAULT_FLY_API_KEY") + if (!djiAppKey) { + println( + "\n**************************************************************\n" + + "WARNING: PILOTVAULT_FLY_API_KEY is not set.\n" + + "The APK will build, but DJI SDK registration will FAIL at\n" + + "runtime. Set the key in ~/.gradle/gradle.properties - see\n" + + "android/gradle.properties for details.\n" + + "**************************************************************\n") + } + manifestPlaceholders["PILOTVAULT_FLY_API_KEY"] = + (djiAppKey ?: "PASTE_YOUR_DJI_APP_KEY_HERE") } buildTypes { diff --git a/Fly App/android/app/src/main/AndroidManifest.xml b/Fly App/android/app/src/main/AndroidManifest.xml index 17f893a..e22900f 100644 --- a/Fly App/android/app/src/main/AndroidManifest.xml +++ b/Fly App/android/app/src/main/AndroidManifest.xml @@ -48,10 +48,12 @@ android:name="org.apache.http.legacy" android:required="false" /> - + + android:value="${PILOTVAULT_FLY_API_KEY}" /> { children: [ TileLayer( urlTemplate: 'https://tile.openstreetmap.org/{z}/{x}/{y}.png', - userAgentPackageName: 'com.dji.flutter.dji_msdk_sample', + userAgentPackageName: 'com.pilotvault.flyapp', ), if (_waypoints.length >= 2) PolylineLayer(polylines: >[ diff --git a/Fly App/pubspec.yaml b/Fly App/pubspec.yaml index 318372f..fab581d 100644 --- a/Fly App/pubspec.yaml +++ b/Fly App/pubspec.yaml @@ -1,4 +1,4 @@ -name: dji_msdk_sample +name: pilotvault_fly description: "PilotVault Fly App — drone telemetry client built with Flutter (DJI Mobile SDK V4)" # The following line prevents the package from being accidentally published to # pub.dev using `flutter pub publish`. This is preferred for private packages. diff --git a/Fly App/test/widget_test.dart b/Fly App/test/widget_test.dart index 99884a8..5af8e12 100644 --- a/Fly App/test/widget_test.dart +++ b/Fly App/test/widget_test.dart @@ -1,6 +1,6 @@ import 'package:flutter_test/flutter_test.dart'; -import 'package:dji_msdk_sample/main.dart'; +import 'package:pilotvault_fly/main.dart'; void main() { testWidgets('Shows the login screen when signed out',