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',