使用 Android Studio 生成未签名的发布 apk [英] Generating unsigned, release apk with Android Studio

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

问题描述

我需要生成一个未签名的发布 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:

  • 无法创建 Artifact(在任何地方都找不到任何带有Artifacts"的菜单,但对于编辑配置,我找到了选择自定义 Artifact 的选项)[可能是最好的选择]
  • 创建一个空的签名配置
  • 创建自定义风格
  • 使用终端运行 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天全站免登陆