Android 同时安装debug release版, 并且显示不同名字

来源:互联网 发布:券妈妈优惠券淘宝 编辑:程序博客网 时间:2024/06/05 05:43

同一部手机上安装app的debug版和release版, 不会相互覆盖.

build.gradle

buildTypes {        release {            applicationIdSuffix ".release"            resValue "string", "app_name", "@string/app_name_release"        }        debug {            applicationIdSuffix ".debug"            resValue "string", "app_name", "@string/app_name_debug"        }

strings.xml

<resources>    <string name="app_name_release">Release</string>    <string name="app_name_debug">Debug</string></resources>

AndroidManifest.xml

<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"            android:label="@string/app_name">            <intent-filter>                <action android:name="android.intent.action.MAIN" />                <category android:name="android.intent.category.LAUNCHER" />            </intent-filter>        </activity>    </application>

另外, 也可以让debug release版使用不同的ic_launcher
在src下面创建debug-res-mipmap-xx, 放入对应的ic_launcher.png用对应版本编译就行了.
这里写图片描述

这里写图片描述

原创粉丝点击