微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

使用gradle-experimental签署android apk:0.2.0

我已经成功修改了我的build.gradle以使用gradle-experimental,但是当尝试添加signedConfigs块时它失败了.我尽可能遵循http://tools.android.com/tech-docs/new-build-system/gradle-experimental的说明,但我总是得到以下错误

A problem occurred configuring project ‘:app’.

The following model rules are unbound:
model.android.signingConfigs > named(release)
Mutable:
– android.signingConfigs.release (com.android.build.gradle.managed.SigningConfig)

搜索错误但找不到任何相关内容. “以下型号规则未绑定”是什么意思?

这是我的signingConfig块看起来像,它在android块之外并修改为使用=就像使用gradle-experimental时的情况一样.

android.signingConfigs {
    release {
        storeFile = file("myreleasekey.keystore")
        storePassword = "password"
        keyAlias = "MyReleaseKey"
        keyPassword = "password"
    }
}

解决方法:

虽然对于提出这个问题的用户来说已经晚了,但它仍然可以帮助其他人.

以下代码示例对我来说工作正常.我使用以下设置对其进行了测试 – Gradle-experimental-0.4.0,Gradle wrapper – 2.8,Android Studio 2.0预览版.

apply plugin: 'com.android.model.application'

model {
    def signConf // <-- Note the changes made here

    android {
        compileSdkVersion = 23
        buildToolsversion = "23.0.0"

        defaultConfig.with {
            applicationId = "in.atultiwari.helloandroidjni"
            minSdkVersion.apiLevel = 15
            targetSdkVersion.apiLevel = 23
            versionCode = 1
            versionName = "1.0"
        }
    }
    android.buildTypes {
        release {
            minifyEnabled = false
            proguardFiles.add(file("proguard-rules.pro"))
            signingConfig = signConf // <-- Note the changes made here
        }
    }
    android.signingConfigs { // <-- Note the changes made here
        create("signRelease") { // <-- Note the changes made here
            keyAlias = 'myKeyAlias'
            keyPassword = 'myKeyPassword'
            storeFile = file('myKestoreFile.jks')
            storePassword = 'myKeystorePassword'
            signConf = it
        }
    }
    android.ndk {
        moduleName = "hello-android-jni"
    }
}

dependencies {
    compile filetree(include: ['*.jar'], dir: 'libs')
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:23.1.1'
    compile 'com.android.support:design:23.1.1'
}

附: – 它不能与minifyEnabled = true一起使用,在这种情况下会发生与transformClassesAndResourcesWithProguardForRelease相关的错误.

编辑 – 1. minifyEnabled = true正在使用上述设置.事实证明我的proguard规则文件是空的,不知何故它导致了上述错误.

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐