Ok so that's a first..
After upgrading to Android Studio 1.5.1 and updating Gradle (on a Mac).
I'm getting an empty error and it refuses to build.
Gradle 'MyTaskTeam' project refresh failed, Error:
AS highlighted the "dependencies" part in my build file, so maybe it's a hint?
I experienced a similar error after upgrading to 1.5.1. The problem was caused by my Gradle settings being configured to "Use local gradle distribution". I had to switch to "Use default gradle wrapper (recommended)" in several projects to fix it.
This setting is under File -> Settings (Ctrl+Alt+S) under Build, Execution, Deployment -> Build Tools -> Gradle
Related
How do I solve this problem?
in android studio
sitting>Build ,Excution, Deployment> Build Tools> Gradle
Linked Gradle projects:Nothing to show
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
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:Gradle's dependency cache may be corrupt (this sometimes occurs after a network connection timeout.)
Re-download dependencies and sync project (requires network)The state of a Gradle build process (daemon) may be corrupt. Stopping all Gradle daemons may solve this problem.
Stop Gradle build processes (requires restart)Your project may be using a third-party plugin which is not compatible with the other plugins in the project or the version of Gradle requested by the project.In the case of corrupt Gradle processes, you can also try closing the IDE and then killing all Java processes.
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
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.
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.
Export your project from unity to a folder eg: ProjectName_Gradle.
open android studio, make sure you are connected to the internet .
close current project then select "Open Gradle, eclipse ADT, etc;" option and open ProjectName_Gradle folder.
check the version of buildTools installed in your android-SDK by opening android-SDK settings from the android studio itself.
edit "build.gradle" file under Gradle Scripts section or under your project.
and change "buildToolsVersion" to the latest version installed in your SDK.
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.
I've recently updated the android studio version of my project from 2.3 Canary 2 to 2.3 Canary 3. Since then the gradle build is failing every time with this error:
Error:Unable to find method 'org.gradle.api.tasks.Sync.getInputs()Lorg/gradle/api/internal/TaskInputsInternal;'.
Possible causes for this unexpected error include:Gradle's dependency cache may be corrupt (this sometimes occurs after a network connection timeout.)
Re-download dependencies and sync project (requires network)The state of a Gradle build process (daemon) may be corrupt. Stopping all Gradle daemons may solve this problem.
Stop Gradle build processes (requires restart)Your project may be using a third-party plugin which is not compatible with the other plugins in the project or the version of Gradle requested by the project.In the case of corrupt Gradle processes, you can also try closing the IDE and then killing all Java processes.
I've searched google and not found solutions like this exactly but those that are similar are not working. Does anyone know how to fix it?
The solution is to select "Use default gradle wrapper (recommended)" option in the build gradle panel like the image below.
Now you can build with gradle 3.2 (in your gradle-wrapper.properties) and android gradle:2.3.0-alpha3 or beta1 as the time of writing
Don't forget to invalidate cache if you have some trouble using File -> Invalidate Cache / Restart
I had the same problem, fixed with checking gradle home path. This cannary build is no more working with gradle-2.14.1
The below link shows, point gradle path to gradle 3.2 directory.
The problem is the last version of tools 2.3.0-alpha3.
Try to use the 2.3.0-alpha2 in project build.gradle
classpath 'com.android.tools.build:gradle:2.3.0-alpha2'
It's mostly happened when setup new or update version of Android studio. I tried almost all solutions and find some fact that I like to share. It's work for me.
Make sure that updated JDK has set up to your computer and set path location.
Control Panel\System and Security\System-> Advanced system setting -> Advanced -> Enviroment Variables -> edit Path and pest your JDK bin folder location
Ex: C:\Program Files\Java\jdk1.8.0_131\bin
Set Project-level-setting "Use default Gradle wrapper (recommended)" from,
Android Studio -> File -> Setting -> Build, Exeution, Deployment -> Gradle
Set Android Studio JDK location:
Android Studio -> File -> Project Structure -> SDK Location -> JDK location
If this three thing is done then you need to set Gradle version 3.4.1 or see the latest version from gradle.org/releases.
Android Studio -> File -> Project Structure -> Project -> Gradle Version
After complete setting clean cash Android Studio will recover it own.
Android Studio -> File -> Invalidate caches/ Restart...
If you're using the gradle wrapper, make sure that the distributionUrl in your gradle/wrapper/gradle-wrapper.properties is correct and up to date. As of this writing, I use this:
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip
try upgrading the Gradle version to 3.2.1
You may face this problem with your previous Project, We will notice that when you create a new application the Gradle build will complete successfully.
So just copy paste the grade setting from new project to the previous project.
Steps:
1) Replace Dependencies in build.gradle (project) by this code :
classpath 'com.android.tools.build:gradle:2.3.0'
2) Replace distributionUrl in Gradle-wrapper.properties by this code:
distributionUrl=https://services.gradle.org/distributions/gradle-3.3-all.zip
3) Don't forget to use Gradle default wrapper in Project level setting.
See this picture for more information
When updating to android studio 2.3, and then load an existing project for older version of android studio, It might take long if not forever on refreshing project.
I had the same problem but i fixed it as follows:
first of all go to Gradle Distributions and download any gradle of
version greater than 3.2
extract it and save it in a suitable place in your computer.
go to android studio and choose the following path
File->Settings->Build,Execution,Deployment->Gradle
on the right side choose or select Use local gradle distribution
and then browse to where you had saved your downloaded extracted
gradle
click apply, then ok.
thats it, your project should now work normally.
change
build:gradle:
from
dependencies {
classpath 'com.android.tools.build:gradle +'
to
dependencies {
classpath 'com.android.tools.build:gradle:2.2.3'
I'm debugging Gradle issues in Android Studio and see references to "Run gradle sync", but I'm not sure how to run this command.
How do I run "Gradle sync" from Android studio or Mac terminal?
Android studio should have this button in the toolbar marked "Sync project with Gradle Files"
EDIT: I don't know when it was changed but it now looks like this:
EDIT: This is what it looks like on 3.3.1
OR by going to File -> Sync Project with Gradle Files from the menubar.
WARNING: --recompile-scripts command has been deprecated since gradle's version 5.0.
To check your gradle version, run gradle -v.
./gradlew --recompile-scripts
it will do a sync without building anything.
Alternatively, with command line in your root project
./gradlew build
It will sync and build your app, and take longer than just a Gradle sync
To see all available gradle task, use ./gradlew tasks
In Android Studio 3.3 it is here:
According to the answer https://stackoverflow.com/a/49576954/2914140 in Android Studio 3.1 it is here:
This command is moved to File > Sync Project with Gradle Files.
Keyboard shortcut lovers can add a shortcut for running gradle sync manually by going to File -> Settings -> Keymap -> Plugins -> Android Support -> Sync Project with gradle files (Right click on it to add keyboard shortcut) -> Apply -> OK and you are done. Choose any convenient key as your gradle sync shortcut which doesnot conflict with any other shortcut key, (I have choosen Shift + 5 as my gradle sync key), so next when you want to run gradle sync manually just press this keyboard shortcut key.
I presume it is referring to Tools > Android > "Sync Project with Gradle Files" from the Android Studio main menu.
gradle --recompile-scripts
seems to do a sync without building anything.
you can enable automatic building by
gradle --recompile-scripts --continuous
Please refer the docs for more info:
https://docs.gradle.org/current/userguide/gradle_command_line.html
Shortcut (Ubuntu, Windows):
Ctrl + F5
Will sync the project with Gradle files.
I think ./gradlew tasks is same with Android studio sync. Why? I will explain it.
I meet a problem when I test jacoco coverage report. When I run ./gradlew clean :Test:testDebugUnitTest in command line directly , error appear.
Error opening zip file or JAR manifest missing : build/tmp/expandedArchives/org.jacoco.agent-0.8.2.jar_5bdiis3s7lm1rcnv0gawjjfxc/jacocoagent.jar
However, if I click android studio sync firstly , it runs OK. Because the build/../jacocoagent.jar appear naturally.
I dont know why, maybe there is bug in jacoco plugin. Unit I find running .gradlew tasks makes the jar appear as well. So I can get the same result in gralde script.
Besides, gradle --recompile-scripts does not work for the problem.
I have a trouble may proof gradlew clean is not equal to ADT build clean. And Now I am struggling to get it fixed.
Here is what I got:
I set a configProductID=11111 from my gradle.properties, from my build.gradle, I add
resValue "string", "ProductID", configProductID
If I do a build clean from ADT, the resource R.string.ProductID can be generated. Then I can do bellow command successfully.
gradlew assembleDebug
But, as I am trying to setup build server, I don't want help from ADT IDE, so I need to avoid using ADT build clean. Here comes my problem.
Now I change my resource name from "ProductID" to "myProductID", I do:
gradlew clean
I get error
PS D:\work\wctposdemo> .\gradlew.bat clean
FAILURE: Build failed with an exception.
* Where:
Build file 'D:\work\wctposdemo\app\build.gradle'
* What went wrong:
Could not compile build file 'D:\work\wctposdemo\app\build.gradle'.
> startup failed:
General error during semantic analysis: Unsupported class file major version 57
If I try with:
.\gradlew.bat --recompile-scripts
I just get error of
Unknown command-line option '--recompile-scripts'.
Anyone wants to use command line to sync projects with gradle files, please note:
Since Gradle 5.0,
The --recompile-scripts command-line option has been removed.
https://docs.gradle.org/5.0/userguide/upgrading_version_4.html#potential_breaking_changes
https://docs.gradle.org/current/userguide/command_line_interface.html
https://github.com/gradle/gradle/issues/1425
From terminal:
gradle prepareKotlinBuildScriptModel
NOTE: you can see what android studio is doing by inspecting the "Build" tab. There will be difference windows inside there. One should be "Sync"
Just now I updated my android studio from build 130.737825 to build 130.878379. When I create a project for the first time, I am getting following error.
Gradle: A problem occurred configuring project ':MyApplicationadfaldf'.
> Failed to notify project evaluation listener.
> Could not resolve all dependencies for configuration ':MyApplicationadfaldf:_DebugCompile'.
> Could not find any version that matches com.android.support:appcompat-v7:+.
Required by:
MyApplicationadfaldfProject:MyApplicationadfaldf:unspecified
What is the reason?
For others, who may be facing the same problem,
Go to Tools-> Android-> SDK Manager, and update all repositories. Now, everything will work properly.
Same issue in my project was fixed with this:
In Android Studio:
-> Go to File menu -> Settings -> Gradle ->
Now in Gradle Settings just check Use Auto-Import Now update Maven will be updated in Android Studio and this error should be gone.
http://tools.android.com/knownissues#TOC-Bundled-Maven-Repository
you need to install "android support repository"