Removing library from Gradle causes "no resource found" errors - android

Below I've attached 2 screenshots: the first one shows my gradle file, the second one shows the errors. When I remove the chatkit dependency, I get the errors in the second screenshot even though the library is not being used anywhere. Why is this happening?

have you performed a clean project before to re-build the app?
On menu build -> Clean project?

Related

How to investigate why gradle build is using cached resource ids

If have a gradle (5.4.1) project (plugin 3.4.1) with two flavors (main and other) using the same sourceSets. I've come across an issue when renaming a resource id (in a layout XML). Here are the observations:
Android Studio 3.4.1 doesn't show any errors and works as expected, i.e. I can click through from kotlin code to the id in the layout xml.
Rebuilding the main flavor also works as expected (no compilation errors).
Rebuilding the other flavor gives a "unresolved reference" compilation error for the new ID. Gradle clean does not help. However, setting org.gradle.caching=false in the project-level gradle.properties does work (following Gradle sync, Clean, Rebuild). This explains why clean was not helping when caching was enabled.
On closer inspection of the R.java file, it seems to be using IDs from some rather old project state (presumably from the gradle cache stored in the user home directory). Now, I could just delete the gradle cache, but I'd rather find out why resource ID changes are not being processed properly. Whichever way Android Studio is running builds in the background, is working fine, just not when performing Build/Run etc.
All this investigation required a lot of trial and error: switching various gradle.properties settings one by one to see which one was leading to the problem, and I'm still no closer to finding the root cause of the problem.
What is the best approach to solving this type of problem, or is trial and error the only way?

Attribute "imageAspectRatioAdjust" already defined with incompatible format.(APT0000)

My game is able to build and run on debug mode so I was hoping it would be ready to be built in release mode but I'm currently stuck with this error in the title. Anyone knows the solution?
EDIT : I've tried commenting the imageAspectRatioAdjust in common_attrs.xml but it would cause alot more different errors.
EDIT : I've found out that there is two file that contains imageAspectRatioAdjust in the release folder of my game when I tried to build it, but there is only 1 file that contains imageAspectRationAdjust in debug. Even if I tried to delete one or the other, I have to clean and rebuild and it would reappear again in the same folders.
I've added Facebook Android SDK into a sub project which a main project is dependant on, which requires me to add Facebook Android SDK into the main project as well but I've accidentally updated some of the packages in the component on the main project and did not update the packages on the sub project, which seems to be the cause of this error.

android studio cannot resolve symbol R [duplicate]

This question already has answers here:
"cannot resolve symbol R" in Android Studio
(100 answers)
Closed 7 years ago.
I've been working on an app and all was going well, everything was working fine. Then I modified some code in my main activity, and when I tried to run the app, there was an apparent error in my code and the build failed.
After this, all the references to my layout files were no longer working (i.e., R.layout.) R was red and hover over says "Cannot resolve symbol R".
Searching you will find dozens of posts that propose many fixes, like: Clean Project; Rebuild Project; Sync Project with Gradle Files; Invalidate Cashes / Restart; Check xml for errors, restart Studio, etc... I've tried them all.
NONE OF WHICH WORK IN MY SITUATION.
My code is working and without errors because I can create a new Android Studio project, and add my classes and resources. The new Android Studio project will run the the SAME CODE under a different package name.
I encountered this same problem a while back and I vaguely remember deleting something from my project folder (might have been a folder or file). I don't remember what I deleted, but it did fix the problem.
Thanks for any advice.
I finally got Android Studio to build without errors, but honestly I don't know how this happened. It was very puzzling that I could have a project that worked and several copies that didn't (I must have re-created my project 10 times from scratch) each time I would copy the project to an archive directory and start over. One of my build requirements was I needed to compile on Jelly Bean, and I think Android Studio sets some sort of defaults when you open a new project with a Blank Activity. Anyway, each time the R. error occurred the build warning would display this:
<style name="Base.Widget.AppCompat.Spinner.Underlined" parent="android:Widget.Material.Spinner.Underlined
But my code does not contain a spinner, so I really can't figure out where this is coming from. In fact I've tried to replace files in one of my inoperable saved projects with the files from my working copy (manifests, code, gradle.build, etc.) yet once inoperable, it seems a Studio project will remain that way.
I wish I could reproduce the problem but I cannot.
WTF! After thinking I had resolved this the problem, it is back again. From my working project I did 2 things. Added a very simple activity, and added it's reference to the manifest. Tried to run the project and get the SAME error again, referencing the a spinner. The Gradle build message is:
C:\CargoBay\Android\LandApp\app\build\intermediates\res\merged\debug\values-ldltr-v21\values-ldltr-v21.xml
Error:(3) Error retrieving parent for item: No resource found that
matches the given name 'android:Widget.Material.Spinner.Underlined'.
I removed the new code from my project, and it still won't build.
I don't know what to think now.
In Android Studio select your project folder, go to VCS / Local History / Show History. Show History will list any files that were moved or deleted, and give you an option to restore the file.
If you select your main activity code, it shows the history of code changes, and you can restore to previous code that was working.

Android Studio: Failed to complete gradle execution. Cause is empty

I tried setting different Gradle Vm Option from all the answers found on stackoverflow, but nothing seems to be working out
I'm on Android Studio 1.2.2
I'm getting this error when I try to run the app on either on the emulator or the device.
Only thing that is working for me is that I need to setup new project in different directories, but it only works for 3 instances and then bang, this error pops up. It is a tedious job to do above mentioned process for 10x times.
Edit_1 :
I even tried invalidating caches/restart, doesn't work out
Usually running gradle assembleDebug from hand or from Gradle menu (right side of screen -> app -> Tasks -> build -> assembleDebug) is giving much more info.
In my case it showed problems in resources files.
It has happened to me and the cause has been different every time.
The first was an error in an xml file. I figured it out by reverting to the latest stable commit. The error was a missing "/>" closing tag. I don't know why android studio didn't point it out. This has happened to several of my co workers
The second time the fix was adding a line
-Xmx256m
or
-Xmx512m
In:
File->Setting->Build, Deployment &Execution->Build Tools->Gradle->Gradle Vm Option
Hope it helps
This can be because you have specified any command line option in android studio settings. You can check this by going to
File > Settings > Build, Execution, Deployment > Compiler
and see "Command-line-options" and check if anything is give. (In your case -x). If so remove it and click Apply and Ok. It worked in my case...
Downgraded to version 1.0.1 to make everything work flawlessly. I'm using same project files, it works fine on this version n number of times and same project files are giving above empty error on studio version 1.2.2
If you are deleting the resources like the layouts or strings or anything. Make sure everything is deleted properly every dependency is deleted properly.A thorough clean up. That solved the problem for me
The cause is empty because the problem is in your resources xml or manifest

error in running android project

when i'm trying to run an android project which shows the warning message :
Your project contains error(s), please fix them before running your application.
but there's no error showing in the code or other section on the project except the project name. like :
I've cleaned, refreshed the project but it remains same.
how can i identify and remove the error ?
thanks in advance
All errors and warnings with detailed description could be found on "Problems" view - usually a tab in the bottom right part of the eclipse window. If it isn't there, use Window -> Show View -> Problems to show it.
Let your tooling generate a new certificate by deleting your current certificate, see:
"Debug certificate expired" error in Eclipse Android plugins
Has the project worked before, but suddenly stopped?
Have you changed anything in the res folder? I've found that if you mess up one of your resource files (drawable, layout etc) it can have this effect. Double check to make sure none of your resources have spaces or capital letters in the name. If you have recently added a new drawable, try removing it temporarily to see if that fixes your problem.
Right click your project, click Properties and choose Java Build Path. Check the tabs there and see if you see any errors.
Sometimes resources there go missing due to folders being removed / moved causing the problems you're experiencing.

Categories

Resources