Android Error Cannot resolve symbol 'R' - android

I am having trouble with getting rid of the error Cannot resolve symbol 'R'. I have done some research but none has worked. Among the tips i have tried out include Tools->Android->Sync Project with Gradle Files after which I executed the Build->Clean Project. The clean project command resulted with the following error;
Execution failed for task ':app:mergeDebugResources'. > Crunching Cruncher abc_btn_radio_to_on_mtrl_000.png failed
My xml files have the following error:
NOTE: This project contains Java compilation errors, which can cause rendering failures for custom views. Fix compilation problems first
Exception raised during rendering: action_bar
What might I be missing? I will appreciate any help or pointers.

In the comments above, #Udit posted a link to another sort of related question from which I was able to get a solution. Incase you run into a similar problem, the solution is quite simple. Reboot Android Studio and then go to Build->Rebuild Project. Hope this will sort out your issue as it did mine. Thank you all for your contribution.

Execution failed for task ':app:mergeDebugResources'. > Crunching
Cruncher abc_btn_radio_to_on_mtrl_000.png failed
--->Is this error message from the gradle console?
Because this happened to me once when the PNG file I used wasn't a "pure" PNG file. Like for example: An image I found from the internet that wasn't really a PNG file(ex: jpg/Gif image) but I just renamed it to to a ".PNG" file upon saving it then directly copied this to res/drawable. So to fix this I deleted the image and used a real PNG file by either editing it on Photoshop or a real png file from the internet or whatever and then did #Biko's advice which was to Reboot Android Studio and then go to Build->Rebuild Project.

Related

Build error related to Jar file in Flutter

I am working on flutter and trying to include map_view in my app. But I have a build error as:
FAILURE: Build failed with an exception.
* What went wrong:
Could not resolve all files for configuration ':map_view:androidApis'.
> Failed to transform file 'android.jar' to match attributes {artifactType=android-platform-attr} using transform PlatformAttrTransform
> java.io.FileNotFoundException: C:\Users\Harsh Goyal\AppData\Local\Android\sdk\platforms\android-27\android.jar (The system cannot find the file specified)
It seems to be related to some missing file. I dont know what to do and can't find any solutions!
Any help is appreciated. :)
I just reinstalled my Android SDK and everything worked perfectly. An answer was posted on a github issue where I posted this question. Here is the link in case it is required:
https://github.com/apptreesoftware/flutter_google_map_view/issues/129#issuecomment-500956688
android.jar file must be broken or missing.
Download and paste .jar file from https://github.com/Sable/android-platforms according to your api level.
Usually you don't need to restart. If doesn't works, restart and retry

Error:Some file crunching failed, see logs for details afer update gradle

Afer update gradle version to classpath 'com.android.tools.build:gradle:2.3.0' I got this error.
Error:Some file crunching failed, see logs for details
Error:Execution failed for task ':app:mergeDebugResources'.
> Error: Some file crunching failed, see logs for details
AAPT err(Facade for 596378712): \\?\C:\Users\Я\.android\build-cache\2fe51ff37440fab8f5f875609a799aebf31c9e02\output\res\drawable-xxxhdpi-v4\abc_ic_menu_share_mtrl_alpha.png ERROR: Unable to open PNG file
AAPT err(Facade for 596378712): \\?\C:\Users\Я\.android\build-cache\2fe51ff37440fab8f5f875609a799aebf31c9e02\output\res\drawable-xxxhdpi-v4\abc_tab_indicator_mtrl_alpha.9.png ERROR: Unable to open PNG file
AAPT err(Facade for 596378712): \\?\C:\Users\Я\.android\build-cache\2fe51ff37440fab8f5f875609a799aebf31c9e02\output\res\drawable-hdpi-v4\abc_btn_radio_to_on_mtrl_015.png ERROR: Unable to open PNG file
I'm not using 9.png files. How can I fix it?
I have exactly same problem in Android Studio 2.3.
I wasted 2 days to solve this problem.
Your problem is
AAPT err(Facade for 596378712): \\?\C:\Users\Я\.android\build- .....
Folder name of your account(reverse R?) is not ascii folder name, so build-cache cannot recognize your folder.
To Solve:
Change folder name : it's impossible in windows 10.
not use build cache: Leos Literak's answer. not good solution.
Best solution: change build-cache path.
refer to https://developer.android.com/studio/build/build-cache.html
For Ex:
in gradle.properties
android.buildCacheDir=D:/android-studio/build-cache
You can build your app cleanly.
Thanks.
I have upgraded to Studio 2.3 as well and this error suddenly occured.
AAPT: \\?\C:\Users\Leoš\.android\build-cache\ce4c6faf7b6acf7c9a9f7875a69dc5776c2cfd5b\output\res\drawable-xhdpi-v4\msbp_math_compass.png ERROR: Unable to open PNG file
I realized one similarity in your and my logs: non-ASCII characters in user name. Then I found that it is a build cache directory. And there was info how to turn it on. So I tried to turn it off with:
gradle.properties
android.enableBuildCache=false
And it works! I can compile my project again. I submitted issue 236304 to Google.
Another option is to change build cache location:
android.enableBuildCache=true
android.buildCacheDir c:\\Dev\\Android\\cache\\
I started getting this error too with Android Studio 2.3 on Mac. Neither disabling the buildCache nor changing the location of the buildCache resolved the problem.
Renaming all of my 9-patch drawables from 'xyz.9.png' to 'xyz.png' - removing the '.9' in the filename - fixed the problem.
Check your png files, in my case that was the problem (One picture was a JPEG file with .png at is end)
Remove it/them and remplace it/them by "real" png files and it may works
The path of the file might be too long for the compiler to build with it. Try moving your project to another location to reduce the length of the destination.
I ran into the same situation as #wooldridgetm.
Later I found that if my 9-patch file has marked stretch area for both left and top side, not only one side, then the problem is solved.
I don't know if it is allowed to have only one side before. Hope this help.
The problem is related to 1 corrupted image file in drawable.
I changed it and the problem was solved very quickly.
The answer is very simple, but the error message is rather ambiguous.
I changed the gradle and android studio, but the solution was very simple than what I thought.
In my case, it was some corrupted PNG file in resources too.
Try going through all of your images and see if you are able to view them in some external preview program.

Error:Execution failed for task app:processDebugResources

I get this following error when syncing android project with gradle:
Error:Execution failed for task ':app:processDebugResources'.
> com.android.ide.common.process.ProcessException: Failed to execute aapt
What does it mean? How do I fix it?
processDebugResources = You have resources (xml files, layouts, images, etc) that have errors or simply need rebuilt.
Cleaning the project may fix the error, but if not, there is often the actual error message within the Gradle console that tells which resource is the problem.
So, the solution to fixing it is usually to read what the full error says, not just the root exception.
First Clean Project and check that you have the latest build tools.(make sure to update support libraries to your current build tool version)
If error still exists Check if you added a resource that violates the conventions.
E.g. cannot have capital letters and such. eg : file_name.PNG
Or may be you rename a resource folder.In that case clear caches and restart!

Error:Execution failed for task ':app:transformClassesWithMultidexlistForDebugAndroidTest'

I am not able to figure out why this error is coming
Here is full error
Error:Execution failed for task
':app:transformClassesWithMultidexlistForDebugAndroidTest'.
> java.io.IOException: The output jar is empty. Did you specify the proper
'-keep' options?
My gradle android project was not having "androidTest" so I created manually and test folder here is screenshot of folder structure
I would not consider it as perfect answer but this is what i did.
I removed testInstrumentationRunner="android.support.test.runner....." from build.gradle file and restarted
It starts working :)
It is just for information

Blocked with Android studio compilation issue ManifestMerger2$MergeFailureException

With Android studio v0.8.2, I am blocked with the following exception. With the beta release it was working very well. I have updated my IDE to 0.8.2 and deleted my target directory and trying to build again. I am struck now.
Execution failed for task ':app:processDebugManifest'.
com.android.manifmerger.ManifestMerger2$MergeFailureException: java.io.FileNotFoundException: /home/gopinath/code/bitbucket/android/productionapp/build/intermediates/exploded-aar/com.jakewharton.hugo/hugo-runtime/1.1.0/AndroidManifest.xml (No such file or directory)
As reported by the error, the file is actually missing in the mentioned path. For my other project in which I have hugo-runtime, the file exists and compilation is proper.
Is anyone else facing this issue? Is there a workaround for this?
Click the build tab and clean Project. Boom!
Posting so that it might help others:
I ran into this issue as well. The error is from ManifestMerger and it made me believe it has something to do with my manifest file and that took me on a wrong path. This error can also happen in case of an invalid XML file in your resources. In my case it was a layout file that got left over from a merge conflict with nothing in it (an empty layout file) which in turn caused the issue. it also cloud be any other xml file so I would suggest opening your xml resources one at a time and see if there is any error in them (you will get the lint error when opening the file)

Categories

Resources