梁锦锋
梁锦锋

Reputation: 21

gradle error in unity exported android project

I am going to use the build config property "multiDexEnabled true" to break 64K methods limit following link https://developer.android.com/studio/build/multidex.html#about

I update to use unity 5.6.1f1 and android studio 2.3.3. I set "build system" option to "Gradle(New)", which is new added from 5.5, then click "Export" to create an android project.

I open the exported project with android studio, then I get the following error https://i.sstatic.net/MdrQI.png

I try the two blue links, but I keep geting this same result.

For my unity project, I only create an empty project and add a button to a unity scene, then export it. I have also tried to build API directly, it works.

It is important for me to export unity project to andoid studio project, because it can help us to use additional compile options

Do any one know what I miss? Or how to export unity project correctly?

Thanks

The gradle error text, if cannot see the image link

Error:org.gradle.api.internal.tasks.DefaultTaskInputs$TaskInputUnionFileCollection cannot be cast to org.gradle.api.internal.file.collections.DefaultConfigurableFileCollection Possible causes for this unexpected error include:

In the case of corrupt Gradle processes, you can also try closing the IDE and then killing all Java processes.

Upvotes: 2

Views: 4353

Answers (3)

Sarvesh Kesharwani
Sarvesh Kesharwani

Reputation: 61

If you have wasted a lot of time fixing unity Gradle error but nothing worked then you tried unity internal builder but that gave "Parsing Package error"

then try this, it will not help you make your project using unity's Gradle but it will make your project without any error successfully.

  1. Export your project from unity to a folder eg: ProjectName_Gradle.
  2. open android studio, make sure you are connected to the internet .
  3. close current project then select "Open Gradle, eclipse ADT, etc;" option and open ProjectName_Gradle folder.
  4. check the version of buildTools installed in your android-SDK by opening android-SDK settings from the android studio itself.
  5. edit "build.gradle" file under Gradle Scripts section or under your project.
  6. and change "buildToolsVersion" to the latest version installed in your SDK.
  7. then click "syn project with Gradle Files" from file option and let it sync. it may ask to update Gradle version, then click update
    now there should not be any errors. now try building APK.

Upvotes: 0

Tony Zhou
Tony Zhou

Reputation: 1

Check your local gradle version in directory -

C:\Users\yourname\.gradle\wrapper\dists

Modify your project gradle configuration -

project\gradle\wrapper\gradle-wrapper.properties

distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip

Make sure gradle-3.3-all match to your gradle version.

Upvotes: 0

Sergey Gutovskiy
Sergey Gutovskiy

Reputation: 21

I had the same issue with unity 2017.1.0b4 and Android Studio 2.3.3, gradle 3.3.

You should change android plugin for graddle version in Android studio to 2.3.3

You can specify the Android plugin for Gradle version in either the File > Project Structure > Project menu in Android Studio, or the top-level build.gradle file. The plugin version applies to all modules built in that Android Studio project. The following example sets the Android plugin for Gradle to version 2.3.3 from the build.gradle file:

buildscript {
  ...
  dependencies {
    classpath 'com.android.tools.build:gradle:2.3.3'
  }
}

https://developer.android.com/studio/releases/gradle-plugin.html

Upvotes: 2

Related Questions