Android 直接运行签名包

231 阅读1分钟

当需要运行是正式包的时候

plugins {
    id 'com.android.application'
}

android {
    compileSdkVersion androidAll.compileSdkVersion
    buildToolsVersion androidAll.buildToolsVersion

    defaultConfig {
        applicationId androidAll.applicationId
        minSdkVersion androidAll.minSdkVersion
        targetSdkVersion androidAll.targetSdkVersion
        versionCode androidAll.versionCode
        versionName androidAll.versionName

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }

    signingConfigs { //signingConfigs 一定要放在buildTypes 因为有可能会造成错误

        debug {                                             // 签名配置的名字,可以随意起,比如debug
            keyAlias 'pluto'                                // 签名别名  比如设置的pluto
            keyPassword '123456'                            // 别名对应的密码
            storeFile file('/Users/sven/Desktop/pluto.jks') // 正式签名文件位置
            storePassword '123456'                           // 签名密码
        }
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
        debug{
            signingConfig signingConfigs.debug // 这里代表直接运行的时候就是正式包了 debug 就是刚才起的名字
        }
    }

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

}

dependencies {

    implementation(rootAll.appcompat)
    implementation(rootAll.material)
    implementation(rootAll.constraintlayout)
    testImplementation(rootAll.junit)
    androidTestImplementation(rootAll.extjunit)
    androidTestImplementation(rootAll.espressocore)


}