我正在使用可从Google Play下载的应用程序(目前仅适用于Android)上的Flutter。
我已经在手机上安装了发布的应用程序。但是,每当我使用android studio在设备上启动调试时,它都会删除已发布的版本。
我想要同时拥有两个应用程序,例如我的设备上的“App”和“App_debug”。

如何设置项目,以便调试和发布应用程序之间没有冲突?

谢谢。

最佳答案

我设法找到一个解决方案(仅适用于android)。

为了不从Google Play删除“已发布的应用”下载,我将这些行添加到android/app/build.gradle文件中:

android {
    buildTypes {
        // ------ Start Changes -----
        debug {
            applicationIdSuffix ".debug"
        }
        // ----- End Changes -----
    }
}

这样,该软件包对于发行版应用程序将为com.example.app,对于我的调试应用程序而言将为com.example.app.debug,并且不再存在冲突。

但是,我也想要一个不同的应用程序名称,以便区分两个应用程序。
为此,我遵循this comment:

在文件android/app/src/main/AndroidManifest.xml中,我做了以下更改:

<manifest ...>
    <application
        // before : android:label="App"
        android:label="@string/app_name"    // <- After my changes
    >
    </application>
</manifest>

然后,为发布应用设置名称,创建或修改文件android/app/src/main/res/values/string.xml:

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <string name="app_name">App</string>
</resources>

对于调试版本,创建或修改文件android/app/src/debug/res/values/string.xml:

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <string name="app_name">App Debug</string>
</resources>

10-04 11:18
查看更多