当前位置: 代码迷 >> Android >> Android 在同一个手机上安装多个雷同的apk,便于调试
  详细解决方案

Android 在同一个手机上安装多个雷同的apk,便于调试

热度:85   发布时间:2016-04-27 23:34:24.0
Android 在同一个手机上安装多个相同的apk,便于调试

Android studio 在同一个手机上安装多个相同的apk
原文地址:http://yj.itrydo.com/posts/iKJryXL9zkfSGRTZk
先看效果:
这里写图片描述
1.在我使用ecslipse的时候我一直在研究“Android studio 在同一个手机上安装多个相同的apk”这个问题,可是每次都不能如自己所愿,一个最笨的方法就是修改项目的包名,但明显这是一个不靠谱的事情,从去年开始接触android studio,终于找到了怎么在一个手机上安装多个相同的apk了,这还得感谢Gradle-Plugin这个插件,很是强大,废话不多说直接上代码:
下面是我的一个build

apply plugin: 'com.android.application'android {    compileSdkVersion 22    buildToolsVersion "22.0.1"    defaultConfig {        applicationId "com.guoyoujin.gz.gz"        minSdkVersion 14        targetSdkVersion 22        versionCode 1        versionName "1.0"    }    buildTypes {        debug {            applicationIdSuffix "debug"        }        release {            minifyEnabled false            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'        }    }}repositories {    maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }}dependencies {    compile fileTree(include: ['*.jar'], dir: 'libs')    compile 'com.android.support:appcompat-v7:22.2.0'    compile 'com.android.support:support-v4:22.2.0'    compile 'com.nineoldandroids:library:2.4.0'    compile 'com.ogaclejapan.smarttablayout:library:[email protected]'    compile 'com.ogaclejapan.smarttablayout:utils-v4:[email protected]'    compile 'com.android.support:recyclerview-v7:22.2.0'    compile 'com.android.support:support-v13:22.2.0'    compile 'com.google.code.gson:gson:2.2.4'    compile 'com.facebook.fresco:fresco:0.5.0'    compile 'com.orhanobut:logger:1.10'    compile 'org.lucasr.twowayview:core:[email protected]'    compile 'org.lucasr.twowayview:layouts:[email protected]'    compile files('libs/universal-image-loader-1.9.1-with-sources.jar')    compile files('libs/com.hck.book.jar')    compile files('libs/Msc.jar')    compile files('libs/pinyin4j-2.5.0.jar')}

重点就在这里:

 buildTypes {        debug {            applicationIdSuffix "debug"        }        release {            minifyEnabled false            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'        }    }

这个debug的applicationIdSuffix随便改都能生成你想要的测试apk的applicationid啦,懂 android的一定知道这是什么概念了
这意味的你可以随意安装一个不同的app了,这是多么牛逼,你在也不用害怕不能给测试人员装多个apk了,这些apk都能正常使用, 给大家看下效果,看下面我已经安装了多个:
这里写图片描述

这里附上一个权威Gradle-Plugin教程链接:链接地址

版权声明:本文为博主原创文章,未经博主允许不得转载。

  相关解决方案