Android 在同一個手機上安裝多個同樣的apk,便於調試

來源:互聯網
上載者:User

標籤: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:[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教程連結:連結地址

Android 在同一個手機上安裝多個同樣的apk,便於調試

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.