生成未签名的Android Studio版本APK [英] Generating unsigned, release apk with Android Studio

查看:1068
本文介绍了生成未签名的Android Studio版本APK的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要生成一个未签名的 release APK(其他人将对其进行签名,然后将其发布到商店中-由其他人处理密钥和其他所有内容).我的问题是,每当我尝试构建时,Android Studio都会引发错误:

I need to generate an unsigned, release APK (where someone else will then sign it and release it to the store- with the someone else handling the keys and everything else). My problem is that Android Studio throws an error whenever I try to build:

app-flavorUnsigned-release-unsigned.apk is not signed. Please configure the signing information for the selected flavor using the Project Structure dialog.

我已经尝试了几种以前的方法:

I've tried several, previous methods:

  • 无法创建伪像(尽管在编辑配置时我发现可以选择自定义伪像的选项,但是在任何地方都找不到带有伪像"的菜单)[可能是最好的选择]
  • 创建一个空的签名配置
  • 创建自定义风味
  • 使用终端运行gradle assemblegradle assembleRelease(由于尝试构建我的重要模块库之一而失败)
  • Failed at creating an Artifact (can't find any menus with "Artifacts" anywhere, although for editing configurations I found the option to choose a custom Artifact) [Probably best bet]
  • Creating an empty signing config
  • Creating a custom flavor
  • Using the terminal to run gradle assemble or gradle assembleRelease (which fail due to one of my important module libraries trying to be built)

这是我当前的[应用程序] build.gradle:

Here is my current [app's] build.gradle:

apply plugin: 'com.android.application'

android {
    signingConfigs {
        unsigned {
            storePassword = ""
            keyAlias = ""
            keyPassword = ""
        }
    }
    compileSdkVersion 19
    buildToolsVersion "20.0.0"
    defaultConfig {
        applicationId "hiddenForClientPrivacy"
        minSdkVersion 13
        targetSdkVersion 20
        versionCode 1
        versionName "1.0"
        signingConfig signingConfigs.unsigned
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            signingConfig signingConfigs.unsigned
        }
        unsignedBuild {
            debuggable false
            versionNameSuffix '-unsigned'
            signingConfig signingConfigs.unsigned
        }
        debug {

        }
    }
    productFlavors {
        flavorUnsigned {
            versionCode = 1;
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:20.0.0'
    compile project(':SlidingMenu')
    compile 'com.android.support:support-v13:20.0.0'
    compile 'com.github.castorflex.verticalviewpager:library:19.0.1'
}

感谢您提供任何帮助.

帮助后 如标记为已接受的答案所示,我必须清除释放块.此外,我单击了运行"按钮-应该正确显示一个错误,因为我无法在仿真器或设备上运行未签名的发行版APK.接受的答案描述了一切.

Post-Help As the marked accepted answer shows, I had to clear out the release block. Furthermore, I was clicking on the "Run" button- which should appropriately show an error as I can't run an unsigned release apk on an emulator or device. The accepted answer describes everything.

推荐答案

release构建类型中,根本不要指定signingConfig,并且不会对您的构建进行签名.发行版本不会采用调试版本获得的默认签名配置,因此它应适用于这些版本.

In the release build type, don't specify a signingConfig at all, and your build won't be signed. Release builds don't pick up the default signing config that debug builds get, so it should work for those.

在讨论区上有讨论.有关此内容的adt-dev邮件列表.

There's a discussion on the adt-dev mailing list about it.

请记住,要从Android Studio进行构建,您需要转到Gradle任务窗口并选择assembleRelease任务;通过"Make Project"进行的常规构建实际上并没有构建最终的APK.

Bear in mind that to build from Android Studio, you'll need to go to the Gradle tasks window and choose the assembleRelease task; normal builds via "Make Project" don't actually build the final APK.

这篇关于生成未签名的Android Studio版本APK的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆