摇篮失败,"不明确的方法重载的方法java.io.File中的#< INIT>"方法、摇篮、不明确、QUOT

2023-09-06 13:22:14 作者:心碎无痕

摇篮构建荷兰国际集团我的项目,我得到这个错误:

When gradle building my project, I'm getting this error:

失败:建立失败,一个异常

FAILURE: Build failed with an exception.   

其中:构建文件应用/ build.gradle'行:45

Where: Build file 'App/build.gradle' line: 45

这是怎么回事:发生评估项目中的问题:应用程序。 暧昧方法重载的方法   的java.io.File#。照片无法解析调用了哪些方法   [空,类java.lang.String]由于重叠原型   间: [java.lang.String类,类java.lang.String]   [类java.io.File,java.lang.String类]

What went wrong: A problem occurred evaluating project ':App'.Ambiguous method overloading for method java.io.File#. Cannot resolve which method to invoke for [null, class java.lang.String] due to overlapping prototypes between: [class java.lang.String, class java.lang.String] [class java.io.File, class java.lang.String]

说行是第一个 proguardFile 规则:

buildTypes {
    release {
        debuggable false
        jniDebugBuild false
        signingConfig signingConfigs.(System.getenv("SIGNING_CONFIG") ?: "release")
        runProguard true
        proguardFile getDefaultProguardFile('proguard-android-optimize.txt')
        proguardFile 'proguard-rules.txt'
    }
}

我还没有得到任何 local.properties 的文件,也没有在Android的Studio中打开该项目。

I haven't got any local.properties file, nor opened the project in Android Studio.

什么是错我的项目?如何解决这个问题?

What is wrong with my project? How can I fix this error?

推荐答案

的该错误消息已在2014年9月改为现在是更清晰,明确地指出,问题是,摇篮找不到SDK;答案的其余部分仍然适用于旧版本(小于0.13)的摇篮插件

The error message has been changed in September 2014. It is now clearer and explicitely points out that the problem is that Gradle can't find the SDK; the rest of the answer still applies to old versions (<0.13) of the Gradle plugin.

这是因为摇篮未能找到SDK的位置,从而做一些需要Android SDK的时候,如获取默认Proguard的文件位置failling。

This is due to Gradle not being able to find the SDK location, and thus failling when doing something that needs the Android SDK, such as getting the default Proguard file location.

其实,这就是摇篮会告诉你,如果你暂时注释掉该行:

Actually, this is what Gradle will tell you if you temporarily comment out that line:

SDK的位置没有找到。与sdk.dir在local.properties文件,或与ANDROID_HOME环境变量定义的位置。

各行业最受欢迎的编程语言

SDK location not found. Define location with sdk.dir in the local.properties file or with an ANDROID_HOME environment variable.

您可以修复它​​:

通过在 local.properties 定义SDK位置:只需添加 sdk.dir = /路径/到/ SDK 该文件。

By defining the SDK location in local.properties: simply add sdk.dir=/path/to/sdk to that file.

通过在环境变量 ANDROID_HOME 设置SDK位置:你只需要通过将设置环境变量 ANDROID_HOME = /路径/要/ SDK 摇篮

例如: ANDROID_HOME = /路径/要/ SDK摇篮构建

在使用版本控制系统,这是完全没有在自己的本地设置位置 local.properties ,每次需要时间,手动设置环境变量使用摇篮将是恼人。只要确保没有检查到你的资料库。

When using a version control system, it is perfectly fine to set the location locally in your own local.properties, as manually setting the environment variable every time you need to use Gradle would be annoying. Just make sure to not check it into your repository.