標籤: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,便於調試