Transfering Keystore and app ID to Flutter

I previously released an app on Google Play in 2015. The app was created using AppInventor, including using a keystore created by AppInventor.

I am now re-writing this app in Flutter. I have the app working and it’s able to run on my phone. I made the following changes that I expect to make it be able to replace my old app:

  1. Added a key.properties file in the /android/ folder which points to my old keystore file from AppInventor
  2. Updated the version code to be version 9 (the previous version of the app was version 8)
  3. Referenced the key.properties file in /android/app/build.gradle
  4. Updated both the namespace and the applicationId in the /android/app/build.gradle file to be the id that I find in the URL of my app on the playstore
  5. Updated the android:label property in the /android/app/AnrdoidManifest.xml file to include the correct name of the app
  6. Updated the buildTypes and signingConfigs in /android/app/build.gradle as described in the documentation

The tricky thing is that these changes make it so that my app doesn’t run on an emulator. Flutter will compile an APK still and it will install on my phone, but when I try to run it, I simply get the error message: Dice has stopped.

Any thoughts on how I can go about debugging it to figure out what is causing the error? The debugger isn’t throwing anything because the emulator won’t start the app. Also, did I do any of those above steps wrong?

Here’s the full git diff for the breaking changes (excluding the key.properties file which is untracked):

diff --git a/android/app/build.gradle b/android/app/build.gradle
index f7d59a4..ba9652b 100644
--- a/android/app/build.gradle
+++ b/android/app/build.gradle
@@ -14,16 +14,22 @@ if (localPropertiesFile.exists()) {
 
 def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
 if (flutterVersionCode == null) {
-    flutterVersionCode="1"
+    flutterVersionCode="9"
 }
 
 def flutterVersionName = localProperties.getProperty('flutter.versionName')
 if (flutterVersionName == null) {
-    flutterVersionName="1.0"
+    flutterVersionName="9.0"
+}
+
+def keystoreProperties = new Properties()
+def keystorePropertiesFile = rootProject.file('key.properties')
+if (keystorePropertiesFile.exists()) {
+    keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
 }
 
 android {
-    namespace "com.example.dice"
+    namespace "appinventor.ai_ansonsavage.DiceRole_Magic8Ball_Extension_Two_Die"
     compileSdkVersion flutter.compileSdkVersion
     ndkVersion flutter.ndkVersion
 
@@ -42,7 +48,7 @@ android {
 
     defaultConfig {
         // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
-        applicationId "com.example.dice"
+        applicationId "appinventor.ai_ansonsavage.DiceRole_Magic8Ball_Extension_Two_Die"
         // You can update the following values to match your application needs.
         // For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration.
         minSdkVersion 21
@@ -51,13 +57,20 @@ android {
         versionName flutterVersionName
     }
 
-    buildTypes {
-        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
-        }
-    }
+   signingConfigs {
+       release {
+           keyAlias keystoreProperties['keyAlias']
+           keyPassword keystoreProperties['keyPassword']
+           storeFile keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']) : null
+           storePassword keystoreProperties['storePassword']
+       }
+   }
+   buildTypes {
+       release {
+           signingConfig signingConfigs.release
+       }
+   }
+
 }
 
 flutter {
diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml
index dc22b8f..a1533b1 100644
--- a/android/app/src/main/AndroidManifest.xml
+++ b/android/app/src/main/AndroidManifest.xml
@@ -1,6 +1,7 @@
 <manifest xmlns:android="http://schemas.android.com/apk/res/android">
+    <uses-permission android:name="android.permission.INTERNET"/>
     <application
-        android:label="dice"
+        android:label="Dice"
         android:name="${applicationName}"
         android:icon="@mipmap/ic_launcher">
         <activity
diff --git a/pubspec.yaml b/pubspec.yaml
index 5b70c5f..874236b 100644
--- a/pubspec.yaml
+++ b/pubspec.yaml
@@ -16,7 +16,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
 # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
 # In Windows, build-name is used as the major, minor, and patch parts
 # of the product and file versions while build-number is used as the build suffix.
-version: 1.0.0+1
+version: 9.0.0+1
 
 environment:
   sdk: '>=3.2.3 <4.0.0'

Leave a Comment