Android开发之如何在debug模式下打出release正式包
生活随笔
收集整理的這篇文章主要介紹了
Android开发之如何在debug模式下打出release正式包
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
公司項目中我們公司測試使用測試包測試。因為用到了百度地圖導致debug版本的簽名只能在我的電腦打debug才可以用,release版本沒有問題。所以要解決這個問題。
于是我想著在debug模式下面直接調用正式版本的簽名不就好了,所以有了這邊文章。
如何使用?
很簡單:
apply plugin: 'com.android.application'android {compileSdkVersion rootProject.ext.android.compileSdkVersionsigningConfigs {config {keyAlias 'demo'keyPassword '123456'storeFile file('./user.jks')storePassword '123456'}}defaultConfig {// applicationId "com.yhsh.wallet"minSdkVersion rootProject.ext.android.minSdkVersiontargetSdkVersion rootProject.ext.android.targetSdkVersionversionCode rootProject.ext.android.versionCodeversionName rootProject.ext.android.versionNameflavorDimensions "versionCode"defaultPublishConfig 'debug'// publishNonDefault true}buildTypes {debug {ext.enableCrashlytics = falsesigningConfig signingConfigs.config}release {minifyEnabled falsezipAlignEnabled trueshrinkResources false/*此debuggable設置成true后在debug模式下也可用正式簽名*/debuggable truesigningConfig signingConfigs.configproguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'delete fileTree(project.rootDir.absolutePath + "/") {include '*v1.0.apk'}/* android.applicationVariants.all { variant ->variant.outputs.all {variant.getPackageApplication().outputDirectory = new File(project.rootDir.absolutePath + "/")outputFileName = "${variant.productFlavors[0].manifestPlaceholders.get("UMENG_CHANNEL_VALUE")}_${variant.productFlavors[0].name}_v${defaultConfig.versionName}.apk"}}*/}}} 只需要在debug里面配置release版本一樣的配置即可也就是:signingConfig signingConfigs.config這行配置 然后要在release配置里面加上一行代碼:/*此debuggable設置成true后在debug模式下也可用正式簽名*/ debuggable true 就可以了,每次直接運行就是正式簽名包了,可解決第三方分享,微信支付等需要正式簽名包的調試了。?
總結
以上是生活随笔為你收集整理的Android开发之如何在debug模式下打出release正式包的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 《卧龙:苍天陨落》登顶 Steam 热销
- 下一篇: 特斯拉宏图前两个篇章的目标都实现了吗?并