Gradle fails with “Ambiguous method overloading for method java.io.File#

前端 未结 3 874
你的背包
你的背包 2021-02-03 21:54

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

FAILURE: Build failed with an exception.

  • Where:
    Build fi

相关标签:
3条回答
  • 2021-02-03 21:56

    I'm doing this every day, creating local.properties by issuing following command (-p is path to my manifest file, -t is current target):

    android project update -p . -t android-19
    

    In case of Gradle Builds:

    android project update .p ./YourApp/src/main/ -t android-19
    cp ./YourApp/src/main/local.properties ./local.properties # or ln if you feel so
    
    0 讨论(0)
  • 2021-02-03 22:03

    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.


    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 location not found. Define location with sdk.dir in the local.properties file or with an ANDROID_HOME environment variable.

    You can fix it:

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

    • By setting the SDK location in environment variable ANDROID_HOME: you just need to set the environment variable by adding ANDROID_HOME=/path/to/sdk before gradle.

      Example: ANDROID_HOME=/path/to/sdk gradle build.

    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.

    0 讨论(0)
  • 2021-02-03 22:16

    In my case I had to set the Android NDK and SDK location in the module settings of my Android Studio project.

    0 讨论(0)
提交回复
热议问题