如何为最终发布的 apk 设置我的 gradle [英] How to set my gradle for final release apk

查看:28
本文介绍了如何为最终发布的 apk 设置我的 gradle的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

之前我的 gradle 是这样的:当然是不正确的

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

因此,在上传时,我从 google play 收到错误消息,说 apk 仍处于调试模式,无法上传该 apk.

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.

现在经过搜索,我发现我需要更改我的gradle文件,最后我想出了这个gradle:

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

现在我哪里出错了?

请帮忙.

推荐答案

在 Studio 窗口的左下方有一个名为Build Variants"的停靠视图.

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

打开它并选择发布版本.

Open it and choose the release variant.

ps.您要添加 compile 'com.google.android.gms:play-services:+' 两次.

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

这篇关于如何为最终发布的 apk 设置我的 gradle的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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