Android Studio Keep saying Failed to complete Gradle execution - android

Everything fine with the command line
gradle build
But Android Studio keep saying that
Failed to complete Gradle execution
Cause:
A fatal exeption has occurred. Program will exit
If I clear all the cache, and restart everything will be fine, but this dialog will easily comeback again (after a build fail). I guess that the increment build chain is not good, but the message is not helpful at all.
Are there anythings I can do to get a more details message about what going on, why AndroidStudio Gradle failed? where can I put thing like --stacktrace in the Preferences of Android Studio?

If you got a problem like this in Android studio, then don't worry about that, you are missing some thing which are here.
Go to File-->Setting-->Gradle-->Gradle Vm Option,
Now put this value -Xmx256m in the box, and hit the Apply button.
Here you have solved the problem.

At my case, I forgot to include some jars at Libs folder at the Gradle file, actually I forgot to add ".jar" to the end of jar file name.

In my case, it was not VM Option and Clean and Build did not work. My problem was that there were some images in res folder (so no grammatical errors) and Android Studio/IntelliJ return this error and saying nothing about images... check all external data sources in each file.

Related

mergeExtDexDebug failing with type defined multiple times error

I have been experiencing this error for a couple of hours now. I was converting java code to kotlin and stumbled upon this.
Type {module}$someclass$1 is defined multiple types:
...\app\build\intermediates\external_libs_dex_archive\debug\out\{file}.jar:classes.dex,
...\app\build\intermediates\external_libs_dex_archive\debug\out\{file}_0.jar:classes.dex
Even removing the dependency doesn't fix it. It just shows up for another module.
Note: I have multidex enabled. Clean project, rebuild project or invalidate restart did not fix it.
Turns out downgrading gradle fixed the problem. I was using 3.6.3 and going back to 3.6.2 worked.
\app\build\intermediates\external_libs_dex_archive\debug*out*{file}.jar:classes.dex
Just delete the directory or folder I have marked in the above path with bold letters(out).
Then run the project this error does not come. In my case it solve my problem.
Which folder contains the duplicates just delete the folder. when we run the project it will generate the dependencies in that location. no files were there so the error not occured

Clean project error with databinding: Unable to delete file androidx.databinding.library.baseAdapters--setter_store.json

I use Databinding. Sometimes while I make changes project may be broken. Then I go to Build -> Clean project & Re-Build project. And I get some strange error:
Unable to delete file: {path_to_project}\app\build\intermediates\data_binding_dependency_artifacts\debug\dataBindingMergeDependencyArtifactsDebug\out\androidx.databinding.library.baseAdapters--setter_store.json
Every time I don't know how to fix it, because I get this error on clean or rebuild. Even if I make Invalidate caches / Restart the problem isn't gone.
If I try to delete this file manually I get error that file is using by another process. Then I close project and successfully delete this file. But when I open the project and build it I get the same error described above.
As I can see the problem is about databinding, but I'm not sure because I saw the same problem with other files from other users on StackOverflow. Sometimes problem is gone by itself, but usually it isn't. Maybe the problem occurs because of errors in layout files, but how to find it out if there is no errors in build log.
Has anyone meet that error? Any ideas how to fix that situation without crush whole the project in undefined time range?
I close Android Studio, delete the app\build folder then reopen Android Studio. Note that all instances of AS must be closed for Windows to let you delete the build folder.
Put Below command in Android Studio terminal.
gradlew --stop
So, the problem is still here but all answers don't solve it. Project doesn't compile for a reason, usually it's some kind of mistake, and if you just delete build folder (which contains file Android Studio is unable to delete) it will not solve problem.
When you are trying to compile project you may get a dozens of errors in generated files (databinding, room, etc). Unfortunatelly, errors are not displaying in the usual window, but if you expand this generated files with errors, you probably will see the real problem, your mistakes you didn't fix when was changing your classes related to generated files. Just fix these mistakes and compile project again. Note: you probably should to look at warnings too.
But if you already got error Unable to delete file you won't see errors in generated files. You need to restart Android studio (if it won't help, you need to delete app\build) and try to compile your project. After that you will find generated files with errors in build tab.
Hope it helps!
First follow this 4 steps
Remove your file generated (build folder)
Clean your project ( simply run cmd command - > gradlew clean)
Invalidate cache and restart Android Studio
Restart computer
If not helpful please try following steps
Gradle sync;
Reinstall Java JRE & Java SDK;
Reinstall the latest version of Android Studio
Rolling back to the previous AS version
Invalidate cache and restart Android Studio
Delete the gradle and .gradle directories in the project directory;
Delete the .gradle directory in your directory;
Run gradlew clean ( simply run cmd command - > gradlew clean)
I have the same problem, and tried the method mentioned above. I could not find the related class in the error message when I searched in the project directory.
In the end, I suspected that it maybe ~/.gradle problem, and then recompile after deleting, and finally solved.
mv ~/.gradle ~/.gradle_bak
Try to disable the daemon and parallel build in gradle.properties
org.gradle.daemon=false
org.gradle.parallel=false
I tried most of the solutions above but seemed not to find them working.
But here is what I did to get my project up and running again.
I am assuming this is happening because you are using dataBinding.
browse to the dataBinding section in your app gradle file
now disable dataBinding by setting to false.
next, rebuild your project and you will notice an error about something to deal with missing a dataBinding in xml file.
Next enalble dataBinding by setting to true this time.
next, rebuild your project.
It should have cleared that strange error.
Forgive me for the strange explanation but am new to contributing to stackoverflow.
It is because of databinding cache issue. We need to delete that cache by disabling it first. I solved the issue after changing the properties of the gradle.properties file:
org.gradle.daemon=false
org.gradle.parallel=false
android.enableBuildCache=false
org.gradle.caching= false
android.databinding.enableV2=false
and
dataBinding {
enabled = false
}
Clean and rebuild the project. After rebuilding it will show errors. Then change all the configuration (make all properties true) and clean, rebuild. It will work absolutely fine.

Duplicate value fo resource 'attr/tint'

I do not know how this error started to happen, I simply closed the android studio yesterday and I turned off the pc, today, I turned on the pc and opened the android studio, then this error appeared soon after opening the android studio.
What have I tried?
invalidate cache
rename and delete files that look like duplicates.
delete .gradle and clear / rebuild project
C:\Users\joaoa.gradle\caches\transforms-1\files-1.1\appcompat-v7-27.0.1.aar\70b6446a0ad42e67664086d0c5dca4d5\res\values\values.xml
C:\Users\joaoa\Desktop\MyPast\myProjects\project001\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values\values.xml
Error:java.util.concurrent.ExecutionException:
com.android.tools.aapt2.Aapt2Exception: AAPT2 error: check logs for
details
Error:Execution failed for task ':app:mergeDebugResources'.
Error: java.util.concurrent.ExecutionException: com.android.tools.aapt2.Aapt2Exception: AAPT2 error: check logs for
details
Please open show log in files and delete all the files where you located and please restart your android studio.
if not solved then Again restart with option like InvalidDate Cache and Restart.
Hope this helps you.
check dependencies in gradle file.
2 or more libraries use in project conflict resource file.
example:
in library A,B in variables in arrts.xml or color.xml
I don't think this is a gradle version issue... I am using Android Studio 3.0 with Gradle Plugin Version 3.0.1 (which uses Gradle 4.1) THE LATEST. And I am getting this same issue. Just rename whatever attribute you've named tint to something like libTint or lib_tint or even more obscure ili_lib_tint so the issue can be resolved. I really want to use this lib and not look else where, please.
This is the xml element causing the issue
ImageLetterIcon/imageletter/src/main/res/values/attrs.xml
<declare-styleable name="TintableImageView">
Android studio creates many files that are not part of the normal source code. If you reboot without saving your project things may get whacked out but this could happen for no apparent reason. You have already cleaned your project so it regenerates some of these files. The .metadata file in the root of your workspace can be deleted but you will need to import all projects already in the workspace. I suggest you check the directory structure of your project using something other than android studio and even delete any generated folders as they will rebuild on the next compile. Perhaps even use a new workspace and copy source code over. First thing you should do is backup everything you want to keep as these suggestions could cause disaster if you are not careful. Consider version control, git repositories or github to save your project in the future as you can roll back to a previous state in the future
The solution works for me is to create a new values-v21 folder and put attr.xml in that, by this it would avoid merging your resources and by doing this your attr will work only from sdk 21 and above.

Eclipse - Several Errors After Altering Proguard and Manifest Files

I have an Android project for which I use the Eclipse IDE and I wanted to try an use the ProGuard tool to obfuscate/shrink my code. Unfortunately I couldn't get it to work with Eclipse throwing up a ProGuard error when I try to export my project.
To resolve this I altered the necessary project properties file to NOT use ProGuard but Eclipse just complained there were errors with the project which needed to be resolved. I tried cleaning the project, refreshing too but all to no avail. As I use a Mercurial for source control I reverted to my last good sources but now Eclipse throws up even more errors which I cannot get rid of:
org.eclipse.core.internal.resources.ResourceException: Resource is out
of sync with the file system: '/XXXXX/AndroidManifest.xml'.
loadAndParseRClass: failed to find manifest package for project
XXXXXXX
I've never been a great fan of Eclipse but how can I clean my project and get it back to a NON proguard state?
I resolved the problem. There's ANOTHER error log in Eclipse called 'Problems' which tells me my Debug certificate has expired on 25/12/2011. Handy how Eclipse labels this as a 'problem' and not an error and gives no indocation other that a red x that there's some sort of problem!
Anyway I resolved this by going here.
Make sure you Refresh your project so that the state of your Workspace/IDE agrees with your state on disk (Right click on the project and select "Refresh"). This will get rid of the first error you have.
And then just do a Team -> Revert on your projects and select the files that you have changed and want to revert to the checked-in version.

Eclipse Android project

I have a problem I can't seem to get around. I've created a project in Eclipse (I recreated it from another project that I thought was corrupted). There are no visible errors in any of the files, including the .xml files. However, the project root [project name] itself has an error (red 'x') and so I can't run it.
On a side note, in the default properties file the line:
target=android-4 is underlined in red with the note that 'android' is not spelled correctly. I have not altered this file since it was generated.
Any clues? Target is 1.6, sdk 4. And I'm new at this :)
You may have already tried this unsuccessfully, but if not, you might want to try the Android Tools > Fix Project Properties action from the context menu of the project root.
Eclipse also thinks android-4 is misspelled in my default.properties, so I doubt that is the cause of your build problem.
Does the Problems view describe any issues? (Window->Show View->Problems)
You could also try cleaning the project in eclipse. Project->Clean..
if the error message you get is
The project cannot be built until the build path errors are resolved.
this might help:
Open the Project -> Properties
Select Java Build Path -> Libraries
Add any new library (to be deleted later) -> OK
Wait for the workspace to refresh or force a refresh
The error should go away
Remove the dummy library
You can stop the spelling error by adding that word to a user dictionary, but a spelling error wouldn't prevent a run.

Categories

Resources