gpt4 book ai didi

android - Grade Plugin 3-alpha1 outputFile 导致错误

转载 作者:塔克拉玛干 更新时间:2023-11-02 07:55:25 24 4
gpt4 key购买 nike

我正在尝试将项目更新到 Android Studio 3。

build.gradle 文件中不再接受以下代码段。

applicationVariants.all { variant ->

variant.outputs.each { out ->

def oFile =out.outputFile // This line causes failure

//...
}
}

错误是一个简单的“无效”,但智能感知表明它是正确的,因为它可以自动完成。

检查 idea.log 显示以下异常:

Caused by: java.lang.RuntimeException: Not valid.
at com.android.ide.common.build.ApkData.getMainOutputFile(ApkData.java:136)
at com.android.build.gradle.internal.api.BaseVariantOutputImpl.getOutputFile(BaseVariantOutputImpl.java:60)
at com.android.build.gradle.internal.api.ApkVariantOutputImpl_Decorated.getOutputFile(Unknown Source)
at org.gradle.internal.metaobject.BeanDynamicObject$MetaClassAdapter.getProperty(BeanDynamicObject.java:228)
at org.gradle.internal.metaobject.BeanDynamicObject.tryGetProperty(BeanDynamicObject.java:171)
at org.gradle.internal.metaobject.CompositeDynamicObject.tryGetProperty(CompositeDynamicObject.java:55)
at org.gradle.internal.metaobject.AbstractDynamicObject.getProperty(AbstractDynamicObject.java:59)
at com.android.build.gradle.internal.api.ApkVariantOutputImpl_Decorated.getProperty(Unknown Source)

我找不到关于 Gradle 4 的文档。这可能是错误还是已弃用的函数?

也提交于:https://issuetracker.google.com/issues/38408231

最佳答案

更新:修复 APK 重命名:

使用all 迭代器而不是each:

android.applicationVariants.all { variant ->
variant.outputs.all {
outputFileName = "${variant.name}-${variant.versionName}.apk"
}
}

之前的答案,仍然有效:这是新插件的一个已知问题:

This build error occurs because variant-specific tasks are no longer created during the configuration stage. This results in the plugin not knowing all of its outputs up front, but it also means faster configuration times. As an alternative, we will introduce new APIs to provide similar functionality.

根据Migration Guide,我们需要等待另一种方式来做到这一点 .

关于android - Grade Plugin 3-alpha1 outputFile 导致错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44044031/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com