将应用程序迁移到 Flutter 以在 Google Play 商店中使用

问题描述 投票:0回答:1

我之前于 2016 年在 Google Play 上发布了一个 app。该应用程序是使用 AppInventor 创建的,包括使用 AppInventor 创建的密钥库。

我现在正在 Flutter 中重写这个应用程序。我的应用程序在 Flutter 中运行良好,并且可以在我的手机上运行。我尚未成功地将其替换为 Google Play 上的应用程序,据我所知,这需要使用相同的密钥库和应用程序 ID。

根据我所读到的内容,以下是使我的 Flutter 应用程序能够替换 Google Play 中的新应用程序所需的更改:

  1. key.properties
    文件夹中添加一个
    /android/
    文件,该文件指向我来自 AppInventor 的旧密钥库文件
  2. 参考
    key.properties
    中的
    /android/app/build.gradle
  3. 文件
  4. 更新版本代码(在我的例子中为版本 9,因为应用程序的先前版本是版本 8)
  5. namespace
    文件中的
    applicationId
    /android/app/build.gradle
    更新为我在 Playstore 上的应用程序 URL 中找到的 id
  6. 更新
    android:label
    文件中的
    /android/app/AnrdoidManifest.xml
    属性以包含应用程序的正确名称
  7. 按照
    文档
    中的说明更新 
    buildTypes
     中的 
    signingConfigs/android/app/build.gradle

进行这些更改后,我的应用程序不再在模拟器上运行。 Flutter 仍会编译 APK 并将其安装在我的手机上,但当我尝试运行它时,我只是收到错误消息:

Dice has stopped

我的问题是:

  1. 我是否采取了正确的步骤来使我的应用程序能够替换 Google Play 上以前的应用程序?
  2. 调试器不会抛出任何内容,因为模拟器不会启动应用程序。我所做的任何更改是否可能导致重大更改?关于如何调试我的应用程序以找出导致错误的原因有什么想法吗?

这是重大更改的完整 git diff(不包括未跟踪的

key.properties
文件):

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'

谢谢!

flutter keystore
1个回答
0
投票

好吧,看来重大更改是对

namespace
的更改。将其设置回
com.example.dice
后,它再次开始运行。

有什么想法吗?

谢谢! 安森

© www.soinside.com 2019 - 2024. All rights reserved.