-
Notifications
You must be signed in to change notification settings - Fork 40
Added example with proguard rules #26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
butterbrain
wants to merge
1
commit into
Rexios80:master
from
butterbrain:garmin_release_build_fixes
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,7 @@ | ||
| # macOS | ||
| .DS_Store | ||
| .DS_Store | ||
| /watch_connectivity_garmin/example/android/.gradle | ||
| /watch_connectivity_garmin/example/android/app/.cxx | ||
| watch_connectivity_garmin/example/android/local.properties | ||
| watch_connectivity_garmin/example/.flutter-plugins | ||
| watch_connectivity_garmin/example/.flutter-plugins-dependencies |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -73,6 +73,45 @@ void example() { | |
|
|
||
| ``` | ||
|
|
||
| As of this moment you will have to develop your own Garmin watch app to send and receive messages, but here's a little start | ||
| ```cpp | ||
| public function onMessageReceived(message) as Void { | ||
| if (message != null && message.isValid()) { | ||
| // this is a good message to use show this received data (the message is a map) | ||
| var messageFromPhone = message.content(); | ||
| // and update our view for this message data | ||
| WatchUi.requestUpdate(); | ||
| } | ||
| } | ||
|
|
||
| public function onTap(event as ClickEvent) as Void { | ||
| var listener = new $.CommListener(); | ||
| var app = $.getApp(); | ||
| Communications.transmit({ | ||
| "clickX" => event.getCoordinates()[0], | ||
| "clickY" => event.getCoordinates()[1], | ||
| "content" => "Hello from the watch!", | ||
| }, null, listener); | ||
| } | ||
| ``` | ||
|
|
||
| ## Releasing (Android release build) | ||
| The app communicates with the Garmin classes via its namespace. So when released these can be minified | ||
| making them uncontactable. To prevent this from happening you will need to include the exclusions in your | ||
| `proguard-rules.pro` file as in the example: | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This doesn't need to be in the readme. The plugin can provide these rules to consumer applications. |
||
| ```yaml | ||
| -keep class com.garmin.** { *; } | ||
| -keep class com.garmin.android.connectiq.** { *; } | ||
| -keep class com.garmin.android.apps.connectmobile.** { *; } | ||
| ``` | ||
|
|
||
| OR in your `build.gradle` you can set | ||
| ```yaml | ||
| shrinkResources false | ||
| minifyEnabled false | ||
| ``` | ||
| * but this is not recommended as your code will be larger than it needs to be | ||
|
|
||
| ## Unsupported Features | ||
|
|
||
| The following features are not supported by Garmin watches: | ||
|
|
||
70 changes: 70 additions & 0 deletions
70
watch_connectivity_garmin/example/android/app/build.gradle
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,70 @@ | ||
| plugins { | ||
| id "com.android.application" | ||
| id "kotlin-android" | ||
| id "dev.flutter.flutter-gradle-plugin" | ||
| } | ||
|
|
||
| def localProperties = new Properties() | ||
| def localPropertiesFile = rootProject.file('local.properties') | ||
| if (localPropertiesFile.exists()) { | ||
| localPropertiesFile.withReader('UTF-8') { reader -> localProperties.load(reader) | ||
| } | ||
| } | ||
|
|
||
| def flutterVersionCode = localProperties.getProperty('flutter.versionCode') | ||
| if (flutterVersionCode == null) { | ||
| flutterVersionCode = '1' | ||
| } | ||
|
|
||
| def flutterVersionName = localProperties.getProperty('flutter.versionName') | ||
| if (flutterVersionName == null) { | ||
| flutterVersionName = '1.0' | ||
| } | ||
|
|
||
| android { | ||
| compileSdkVersion flutter.compileSdkVersion | ||
|
|
||
| compileOptions { | ||
| sourceCompatibility JavaVersion.VERSION_1_8 | ||
| targetCompatibility JavaVersion.VERSION_1_8 | ||
| } | ||
|
|
||
| kotlinOptions { | ||
| jvmTarget = '1.8' | ||
| } | ||
|
|
||
| sourceSets { | ||
| main.java.srcDirs += 'src/main/kotlin' | ||
| } | ||
|
|
||
| defaultConfig { | ||
| // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). | ||
| applicationId "dev.rexios.watch_connectivity_garmin" | ||
| minSdkVersion 23 | ||
| targetSdkVersion flutter.targetSdkVersion | ||
| versionCode flutterVersionCode.toInteger() | ||
| versionName flutterVersionName | ||
| } | ||
|
|
||
| buildTypes { | ||
| debug { | ||
| signingConfig signingConfigs.debug | ||
| } | ||
| release { | ||
| // TODO: Add your own signing config for the release build. | ||
| // Signing with the debug keys for now, so `flutter run --release` works. | ||
| signingConfig signingConfigs.debug | ||
| shrinkResources true | ||
| minifyEnabled true | ||
| // because we are connecting to the Garmin watch via namespaced plugin access | ||
| // we need the special proguard rules to pevent obsfuscation of these classes | ||
| proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' | ||
|
|
||
| } | ||
| } | ||
| namespace 'dev.rexios.watch_connectivity_garmin' | ||
| } | ||
|
|
||
| flutter { | ||
| source '../..' | ||
| } |
7 changes: 7 additions & 0 deletions
7
watch_connectivity_garmin/example/android/app/src/debug/AndroidManifest.xml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| <manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
| package="dev.rexios.watch_connectivity_garmin"> | ||
| <!-- Flutter 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> |
34 changes: 34 additions & 0 deletions
34
watch_connectivity_garmin/example/android/app/src/main/AndroidManifest.xml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| <manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
| package="dev.rexios.watch_connectivity_garmin"> | ||
| <application | ||
| android:label="Example App" | ||
| android:name="${applicationName}" | ||
| android:icon="@mipmap/ic_launcher"> | ||
| <activity | ||
| android:name=".MainActivity" | ||
| android:exported="true" | ||
| android:launchMode="singleTop" | ||
| 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> | ||
| </manifest> |
29 changes: 29 additions & 0 deletions
29
...armin/example/android/app/src/main/java/io/flutter/plugins/GeneratedPluginRegistrant.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| package io.flutter.plugins; | ||
|
|
||
| import androidx.annotation.Keep; | ||
| import androidx.annotation.NonNull; | ||
| import io.flutter.Log; | ||
|
|
||
| import io.flutter.embedding.engine.FlutterEngine; | ||
|
|
||
| /** | ||
| * Generated file. Do not edit. | ||
| * This file is generated by the Flutter tool based on the | ||
| * plugins that support the Android platform. | ||
| */ | ||
| @Keep | ||
| public final class GeneratedPluginRegistrant { | ||
| private static final String TAG = "GeneratedPluginRegistrant"; | ||
| public static void registerWith(@NonNull FlutterEngine flutterEngine) { | ||
| try { | ||
| flutterEngine.getPlugins().add(new dev.rexios.watch_connectivity.WatchConnectivityPlugin()); | ||
| } catch (Exception e) { | ||
| Log.e(TAG, "Error registering plugin watch_connectivity, dev.rexios.watch_connectivity.WatchConnectivityPlugin", e); | ||
| } | ||
| try { | ||
| flutterEngine.getPlugins().add(new dev.rexios.watch_connectivity_garmin.WatchConnectivityGarminPlugin()); | ||
| } catch (Exception e) { | ||
| Log.e(TAG, "Error registering plugin watch_connectivity_garmin, dev.rexios.watch_connectivity_garmin.WatchConnectivityGarminPlugin", e); | ||
| } | ||
| } | ||
| } |
6 changes: 6 additions & 0 deletions
6
...in/example/android/app/src/main/kotlin/dev/rexios/watchconnectivitygarmin/MainActivity.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| package dev.rexios.watch_connectivity_garmin | ||
|
|
||
| import io.flutter.embedding.android.FlutterActivity | ||
|
|
||
| class MainActivity: FlutterActivity() { | ||
| } |
12 changes: 12 additions & 0 deletions
12
...h_connectivity_garmin/example/android/app/src/main/res/drawable-v21/launch_background.xml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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> |
12 changes: 12 additions & 0 deletions
12
watch_connectivity_garmin/example/android/app/src/main/res/drawable/launch_background.xml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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 added
BIN
+544 Bytes
...onnectivity_garmin/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+442 Bytes
...onnectivity_garmin/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+721 Bytes
...nnectivity_garmin/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+1.01 KB
...nectivity_garmin/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+1.41 KB
...ectivity_garmin/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
18 changes: 18 additions & 0 deletions
18
watch_connectivity_garmin/example/android/app/src/main/res/values-night/styles.xml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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 | ||
| Flutter 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> |
18 changes: 18 additions & 0 deletions
18
watch_connectivity_garmin/example/android/app/src/main/res/values/styles.xml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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 | ||
| Flutter 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> |
7 changes: 7 additions & 0 deletions
7
watch_connectivity_garmin/example/android/app/src/profile/AndroidManifest.xml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| <manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
| package="dev.rexios.watch_connectivity_garmin"> | ||
| <!-- Flutter 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> |
18 changes: 18 additions & 0 deletions
18
watch_connectivity_garmin/example/android/app/src/proguard-rules.pro
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| ## Flutter wrapper | ||
| -keepattributes Signature | ||
| -keepattributes LineNumberTable,SourceFile | ||
| -renamesourcefileattribute SourceFile | ||
| -keep class io.flutter.app.** { *; } | ||
| -keep class io.flutter.plugin.** { *; } | ||
| -keep class io.flutter.util.** { *; } | ||
| -keep class io.flutter.view.** { *; } | ||
| -keep class io.flutter.** { *; } | ||
| -keep class io.flutter.plugins.** { *; } | ||
| -dontwarn io.flutter.embedding.** | ||
| -keep class com.google.firebase.** { *; } | ||
| -keep class com.garmin.** { *; } | ||
| -keep class com.garmin.android.connectiq.** { *; } | ||
| -keep class com.garmin.android.apps.connectmobile.** { *; } | ||
| -keepattributes JavascriptInterface | ||
| -keepattributes Annotation | ||
| -optimizations !method/inlining |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| allprojects { | ||
| repositories { | ||
| google() | ||
| mavenCentral() | ||
| } | ||
| } | ||
|
|
||
| rootProject.buildDir = '../build' | ||
| subprojects { | ||
| project.buildDir = "${rootProject.buildDir}/${project.name}" | ||
| } | ||
| subprojects { | ||
| project.evaluationDependsOn(':app') | ||
| } | ||
|
|
||
| tasks.register("clean", Delete) { | ||
| delete rootProject.buildDir | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| org.gradle.jvmargs=-Xmx1536M | ||
| android.useAndroidX=true | ||
| android.enableJetifier=true | ||
| android.defaults.buildfeatures.buildconfig=true | ||
| android.nonTransitiveRClass=false | ||
| android.nonFinalResIds=false |
Binary file added
BIN
+52.4 KB
watch_connectivity_garmin/example/android/gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
7 changes: 7 additions & 0 deletions
7
watch_connectivity_garmin/example/android/gradle/wrapper/gradle-wrapper.properties
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| distributionBase=GRADLE_USER_HOME | ||
| distributionPath=wrapper/dists | ||
| distributionUrl=https\://services.gradle.org/distributions/gradle-8.11.1-bin.zip | ||
| networkTimeout=10000 | ||
| validateDistributionUrl=true | ||
| zipStoreBase=GRADLE_USER_HOME | ||
| zipStorePath=wrapper/dists |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These should be in the examples gitignore file