码迷,mamicode.com
首页 > 移动开发 > 详细

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

时间:2017-07-29 15:13:36      阅读:230      评论:0      收藏:0      [点我收藏+]

标签:sla   ide   clu   hot   span   2.0   ips   view   int   

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:1.1.3@aar‘

    compile ‘com.ogaclejapan.smarttablayout:utils-v4:1.1.3@aar‘

    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:1.0.0-SNAPSHOT@aar‘

    compile ‘org.lucasr.twowayview:layouts:1.0.0-SNAPSHOT@aar‘

    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教程链接:链接地址

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

标签:sla   ide   clu   hot   span   2.0   ips   view   int   

原文地址:http://www.cnblogs.com/clnchanpin/p/7255667.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!