Android gradle 签名配置错误

标签 android

我尝试像 this link 那样签署我的应用程序. 我编写了我的 signingConfigs 设置,但出现“找不到属性”错误。

这是我的 build.gradle

apply plugin: 'android'

    android {
        compileSdkVersion 19
        buildToolsVersion '19.0.3'
        defaultConfig {
            minSdkVersion 11
            targetSdkVersion 19
            versionCode 1
            versionName "Andy Warhol"
        }
        buildTypes {
            debug {
                proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
                debuggable false
                jniDebugBuild false
                signingConfig signingConfigs.myconfig
            }
            release {
                proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
                debuggable false
                jniDebugBuild false
            }
        }
        signingConfigs {
            myconfig {
                keyAlias 'xxx'
                keyPassword 'xxx'
                storeFile file('xxx')
                storePassword 'xxx'
            }
        }
    }

    dependencies {
        compile 'com.android.support:appcompat-v7:+'
        compile 'com.google.android.gms:play-services:4.0.30'
        compile fileTree(dir: 'libs', include: ['*.jar'])
        compile files('libs/picasso-2.2.0.jar')
        compile files('libs/acra-4.5.0.jar')
        compile files('libs/libGoogleAnalyticsServices.jar')
    }

这是我的错误

Gradle 'BulentTirasMobileApp' project refresh failed: Could not find property 'myconfig' on SigningConfig container.

最佳答案

将您的 signingConfigs block 移动到您的 buildTypes block 之前:

    signingConfigs {
        myconfig {
            keyAlias 'xxx'
            keyPassword 'xxx'
            storeFile file('xxx')
            storePassword 'xxx'
        }
    }
    buildTypes {
        debug {
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
            debuggable false
            jniDebugBuild false
            signingConfig signingConfigs.myconfig
        }
        release {
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
            debuggable false
            jniDebugBuild false
        }
    }

您需要先定义配置才能使用它。

关于Android gradle 签名配置错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22790801/

相关文章:

android - 如何在 android 中读取 USSD 消息?

android - Android 上 Fragments 的立方体翻转动画

android - java.lang.NoClassDefFoundError : com. 谷歌.android.gms.common.AccountPicker

android - 铃声首选项默认为无声,即使设置了默认值

android - Firestore 排除数据序列化

android - 如何使 Android 应用程序不可移动?

android - TradeMark(TM) 标志在设备上显示为问号

android - Robolectric & 测试 startActivityForResult

android - 将屏幕方向固定为纵向

java - 在android中调用View内部的View