我正在开发一个可以从 Google Play 下载的应用程序(目前只有 android)。
我已经在手机上安装了发布的应用程序。但是,每当我使用 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>
关于android - Flutter,如何在同一设备上发布和调试应用程序?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62125323/