Search code examples
androidandroid-studiobuildandroid-gradle-pluginapk

Generating unsigned, release apk with 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:

  • 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)

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'
}

Thank you for any and all help.

Post-Help Edit: 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.


Solution

  • 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.

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

    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.