10

Earlier my gradle was like this: WHICH IS OFCOURSE INCORRECT

    apply plugin: 'android'

android {
    compileSdkVersion 19
    buildToolsVersion '19.0.3'

    defaultConfig {
        minSdkVersion 11
        targetSdkVersion 19
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            runProguard false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
        }
    }
}

dependencies {
    compile 'com.android.support:gridlayout-v7:19.0.1'
    compile 'com.android.support:appcompat-v7:+'
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:support-v4:+'
    compile 'com.google.android.gms:play-services:+'
    compile 'com.jakewharton:butterknife:4.0.+'
    compile 'com.google.code.gson:gson:2.2.+'
    compile 'com.google.android.gms:play-services:+'
}

So while uploading i got an error from google play saying that the apk is still in debug mode and could not allow to upload that apk.

Now after searching over, I found that i need to change my gradle file finally i have come up with this gradle:

Please guide me if i am correct!!

apply plugin: 'android'

android {
    compileSdkVersion 19
    buildToolsVersion '19.0.3'

    defaultConfig {
        minSdkVersion 11
        targetSdkVersion 19
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            signingConfig signingConfigs.release
        }
    }

    signingConfigs {
        release {
            storeFile file("F:\\MyAppFolder\\AppName.jks")
            storePassword "abc1236"
            keyAlias "prince"
            keyPassword "abc1236"
        }
    }
}

dependencies {
    compile 'com.android.support:gridlayout-v7:19.0.1'
    compile 'com.android.support:appcompat-v7:+'
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:support-v4:+'
    compile 'com.google.android.gms:play-services:+'
    compile 'com.jakewharton:butterknife:4.0.+'
    compile 'com.google.code.gson:gson:2.2.+'
    compile 'com.google.android.gms:play-services:+'
}

Now where am i going wrong?

Please help.

user1991
  • 179
  • 1
  • 2
  • 11
  • What's the symptom? Are you asking for a release build via `./gradle assembleRelease`? Do search Stack Overflow for, say, `[android] gradle release` since there are many questions about this. – Jerry101 Mar 27 '14 at 17:39
  • 2
    make sure you generating the signed apk from `Build > Generate signed apk` ? – Piyush Agarwal Mar 27 '14 at 18:35

2 Answers2

41

On the lower left of the Studio window there's a docked view called "Build Variants".

Open it and choose the release variant.

enter image description here

ps. you are adding compile 'com.google.android.gms:play-services:+' twice.

Gabriele Mariotti
  • 320,139
  • 94
  • 887
  • 841
  • What do you do if "Build Variants" is empty? – Andrew Ebling Jun 23 '14 at 11:06
  • @AndrewEbling - You should be able to define one: Right-click on the module in Android Studio, select Module Settings. In the pane on the left, select the module (e.g. 'app'). Click on the Build Types tab. It's here that the Build Variants are defined. Click the green + button to define a new one. – CJBS Aug 20 '14 at 23:09
0

The comment by pyus13 is what i would go by.

It says in the documentation (http://developer.android.com/tools/publishing/app-signing.html) that:

"Note: Including the passwords for your release key and keystore inside the build file is not a good security practice. Alternatively...have the build process prompt you for these passwords."

So just do Build > Generate signed apk and Android studio will prompt you for the keystore/passwords and generate the apk in release mode. No need to put passwords in build file.

NNN
  • 543
  • 5
  • 14