繁体   English   中英

Android Studio:在发布模式下生成签名的apk,但我仍然可以在调试列表中看到它

[英]Android Studio: generate signed apk in release mode ,but i still can see it in debug list

Android Studio:在发布模式下生成签名的apk,但我仍然可以在调试列表中看到我的应用程序(android studio设备对话框),手机的开发人员选项:选择要调试的应用程序也可以显示我的应用程序

我的build.gradle文件:

    android {
    compileSdkVersion 21
buildToolsVersion "21.1.2"

defaultConfig {
    applicationId "com.lydiabox.android"
    minSdkVersion 15
    targetSdkVersion 21
    versionCode 49
    versionName "1.8.7"
//        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
android {
    packagingOptions {
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/NOTICE.txt'
        exclude 'LICENSE.txt'
    }
    dexOptions{
        preDexLibraries = false;
    }

}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}
}

谢谢答案

检查您的应用程序是否使用以下命令签名:

$ jarsigner -verify hello_world.apk

jarsigner在您的JDK / bin文件夹中。

编辑:您可以在manifest.xml(在application标签中)中使用android:debuggable="false"禁用调试

这是示例build.gradle

    apply plugin: 'com.android.application'
android {
    compileSdkVersion 21
    buildToolsVersion '21.1.1'
    defaultConfig {
        applicationId 'com.example'
        minSdkVersion 14
        targetSdkVersion 21
        versionCode 1
        versionName '1.0'
    }
    signingConfigs {
release {
            storeFile file("releasekeystore.jks")
            storePassword "password"
            keyAlias "ReleaseAlias"
            keyPassword "password"
        }
    }
    buildTypes {

        release {
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        signingConfig signingConfigs.release
        }
    }
    productFlavors {
    }


    packagingOptions {
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/NOTICE'
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/NOTICE.txt'
        exclude 'META-INF/DEPENDENCIES'
    }
}
dependencies {
    ...
}

那么您需要先运行../gradlew clean,然后再运行../gradlew assembleRelease以生成发行版APK,如果您的android模块名称为app,则它将出现在app / build / outputs / apks / app-release.apk中。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM