Android resource compilation failed after android gradle version update - android

I am developing an android app, everything was going fine until i updated gradle version to 3.2. Whenever i try to build or sync the project it shows 'Android resource compilation failed'
Output: C:\Users\User\AndroidStudioProjects\MyApp\base\build\intermediates\incremental\mergeDebugFeatureResources\merged.dir\values\values.xml:2316: error: <item> inner element must either be a resource reference or empty.
Command: C:\Users\User\.gradle\caches\transforms-1\files-1.1\aapt2-3.2.1-4818971-windows.jar\fc444429c9ac9f1db8d9bb3790bf9413\aapt2-3.2.1-4818971-windows\aapt2.exe compile --legacy \ -o \ C:\Users\User\AndroidStudioProjects\MyApp\base\build\intermediates\res\merged\feature\debug \ C:\Users\User\AndroidStudioProjects\MyApp\base\build\intermediates\incremental\mergeDebugFeatureResources\merged.dir\values\values.xmlDaemon: AAPT2 aapt2-3.2.1-4818971-windows Daemon #0\
The error comes up in this line
<item name="textviewprofile" type="id">Logout</item>
I tried to delete the logout element, but the changes does not reflect after build and it still shows up.It says you cannot edit values.xml. I also tried to clean and invalidate the project but that also didn't worked. I have been trying it for several days but cannot fix it.
Any help would be appreciated
Thanks in advance for it

did you already tried deleting the .gradle file located in your root project dir? That sometimes works for me.
Gradle keeps a cache of the task it runs so by deleting the .gradle folder you are invalidating the gradle cache and forcing to redo it again.

Related

Flutter: Not able to run the app on simulator - gradle error

I am trying to run the default app which comes when creating a flutter file using "flutter run" but it gives me the following error:The error I am facing.
I did try installing gradle, creating a settings.gradle file in my root directory of project and run "gradle wrapper" it was successful but I still face the same error.
UPDATE: One of my parent directories had spaces in the directory name. After removing the spaces it solved the issue.
Your gradle-wrapper is missing. Make sure that you've a gradle distribution added in your PATH variable and restore the wrapper by running this command:
gradle wrapper

debug directory does not exist error running React-native's AwsomeProject

I'm trying to create a react-native android app following react-native "Getting started" here but when I try to run it both through CLI and with Android studio it gives me this error:
A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
> Android resource compilation failed
AAPT: C:\Windows\System32\AwsomeProject\android\app\build\intermediates\res\merged\debug: error: directory does not exist.
I tried deleting the build folder, cleaning the project and re-running it but it doesn't work.
How can I solve this?
If I understand your situation right:
There is absolutely no issue in your Java and XML.
Your project built just fine before this.
You tried to remove the build cache.
In addition to above you should remove the .gradle directory as well.
Unfortunately, some react-native modules have their own build directory inside the node_modules/ directory, so it is possible that you didn't clear the build cache for them.
Of course, it's really hard to go into each module and remove the build cache manually each time, but fortunately, you can change this behavior by adding to build.gradle file something like below:
allprojects {
// ...
buildDir = "${rootProject.rootDir}/.build/${project.name}"
}
Note: This tells gradle to use the same build directory for all projects.
I prefer ".build" as build directory but you may want to change that to "build" in above.

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.

Gradle suddenly doesn't build Arm8Release any more

When I say
./gradlew installArm8Release
I get this error:
:app:generateJsonModelArm8Release UP-TO-DATE
:app:externalNativeBuildArm8Release FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:externalNativeBuildArm8Release'.
> java.io.FileNotFoundException: D:\TestApp\app\.externalNativeBuild\cmake\arm8Release\arm64-v8a\android_gradle_build.json (The system cannot find the file specified)
I believe my Gradle configuration has somehow been corrupted because as you can see it says on :app:generateJsonModelArm8Release that it is up to date but as you can see from the error below android_gradle_build.json isn't there at all.
The following line works fine, though:
./gradlew installArm7Release
It's only Arm8Release that fails although it used to work before. This makes me think that somehow something got corrupted. I have already tried the following:
./gradlew clean
./gradlew cleanBuildCache
All to no avail. It refuses to build the Arm8Release target. I have also tried deleting the .externalNativeBuild directory and running
./gradlew wrapper
again. But it didn't solve the issue either.
I have also rebooted the system to make sure any gradle daemon is gone but the error is still there.
I'm pretty much out of ideas now. All targets are working fine except Arm8Release. What else can I try?
Just for the record: Deleting really everything from my build directory except the source and resource files solved this issue. So it seems like
./gradlew clean
./gradlew cleanBuildCache
doesn't really clean everything...
In Android Studio 3.5 (and probably above), that missing file is under a .cxx folder, so deleting the build folder has no effect. Cleaning build doesn't help either. Instead an invalidate cache and restart did the trick for me.
Just add --rerun-tasks to your gradlew command, e.g.
./gradlew installArm8Release --rerun-tasks
just restart Android Studio, it worked for me.

Phonegap error android sdk build.xml:950 : null returned: 1

I'm trying to launch phonegap android app in android sdk, but I am receiving an error:
[phonegap] detecting Android SDK environment...
[phonegap] using the local environment
[phonegap] compiling Android...
[error] An error occurred while building the android project.Error executing "ant debug -f "/Users/me/Projects/one/platforms/android/build.xml"":
BUILD FAILED
/Applications/Android/adt-bundle-mac-x86_64-20131030/sdk/tools/ant/build.xml:932: The following error occurred while executing this line:
/Applications/Android/adt-bundle-mac-x86_64-20131030/sdk/tools/ant/build.xml:950: null returned: 1
I followed this guide http://docs.phonegap.com/en/2.2.0/guide_getting-started_android_index.md.html but it is not working.
What could have caused this?
You are most likely also getting the line
invalid resource directory name:
/YOUR/PROJECT/ROOT/PATH/bin/res/crunch
right before the error codes, so open up terminal and enter the following:
cd YOUR/PROJECT/ROOT/PATH
rm -fR $(find . -type d -name crunch|xargs)
I just had to cd into the platforms/android dir and run ant clean and it fixed this issue for me.
had the same issue. something that can help is to read ant log as recommend here
to do so run ant -logfile //antLogFile.txt release -f ./AppMain/build.xml
or in the folder itself. i.e : platforms\android run ant -logfile ./antLogFile.txt release
My issue was a file with Hebrew characters on its name..
Hi Sorry for the late answer
An alternative to other solutions possibly OS-X Specific but i was having the same issue and none of the solutions for me worked however the mention of assets made me go back and scour over my build logs and i noted this:
[aapt] /Users/rowdoggnz/Development/cordova/surveyapp/platforms/android/assets/www/lib/fa/Icon
[aapt] : error: Invalid filename. Unable to add.
This was the cause of my error which shared the same error code and line references as the original poster.
OS-X seems to generate ghost icon files for some reason which are not visible in finder due to being hidden, i used an app called "Invisiblix" to view my project folder and removed all of the 'Icon' files and my app would build fine.
I'm guessing the iOS build naturally ignores these Icon files however Ant doesn't.
Hope this helps someone.
If you have more than one project and you are using the same assets eg: images, ant will fail to build. You can use ant clean to remove the cache from other projects and avoid this issue as suggested in this post crunch/resource packaging with aapt in ant build uses cache from other projects
Nevertheless, In my case I just have one project with many images, some of them were called with the same name, but with different letter case. Ant's build process is case-insensitive, so those images were duplicated, being error cause.
My particular fix was to rename or eliminate one of the images to allow cordova build my project.
I was having this issue in OSX using Ionic framework. This was my fix:
I ran this on the command line in the project root folder:
find . -name Icon -exec rm {} \;
What the above does descend through the whole project to search for files name Icon. Upon finding them they are deleted.
After this I ran my build process and all was good again.
Make sure you have installed the prerequisites correctly.

Categories

Resources