Generally, when the project is in the later stage, it is necessary to switch frequently between the test version and the official version. What should I do? If you are a rich man, you can consider using two machines and testing them at the same time. However, in order to facilitate testing and save costs, the best way is of course to install different versions on the same machine.
However, in principle, it is impossible to install two APPs at the same time due to the signature and package name problem. However, under the universal way of heaven, there are only things you can't imagine, and nothing can be done. First, let's analyze the reasons, 1. Signature and 2 package names. In other words, as long as these two problems are solved, we will be half successful. The first one is naturally easy to solve. We just need to specify different signatures for debug and release respectively. What should I do with the second one? Do you need to copy a copy of the code and modify the package name? Wouldn't this seem too low? Moreover, it is easy to make mistakes when following up maintenance between two projects. The most important thing is that it doesn’t show off! At this time, the universal gradle came out (then who, don’t throw your shoes!………)
1. Find (Module: app)
Find BuildTypes to add the following code
buildTypes { release { applicationIdSuffix ".release" resValue "string", "app_name", "@string/app_name_release" // minifyEnabled false // proguardFiles getDefaultProguardFile(''), '' } debug { applicationIdSuffix ".debug" resValue "string", "app_name", "@string/app_name_debug" } }
2. Find
Add code
<string name="app_name_release">ReleaseVersion</string> <string name="app_name_debug">DebugVersion</string>
3. Find
<application android:allowBackup="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:supportsRtl="true" android:theme="@style/AppTheme"> <activity android:name=".MainActivity"> <intent-filter> <action android:name="" /> <category android:name="" /> </intent-filter> </activity> </application>
The above is all the content of this article. I hope it will be helpful to everyone's study and I hope everyone will support me more.