"Cannot resolve symbol ..." error with "R" but project builds fine - java

I started working on a new app (min API: 24, target/compile: 27) yesterday and updated Android Studio to version 3.6 after creating the project. Now I keep running into the same problem over and over:
When I add a new UI item with an id or if I change an existing id, then access the e.g. R.id.activity1 in my code, there's no suggestion popup for the id. When I just type it out, the code turns red and it's marked as an error on the sidebar and in the class name. The app still builds and runs fine.
Contrary to this question not all of the R occurances are marked though, only the ones that I changed/created since the last restart.
What I've tried:
Build - Clean Project
Build - Rebuild Project
File - Sync Project with Gradle Files
Neither works. I have to restart Android Studio to get rid of the fake errors (no need to invalidate caches).
The gradle file looks fine as far as I can see (appcompat and design are version 27.1.1) and there's only a single error in the xml files that is connected to the problem:
This project contains Java compilation errors, which can cause
rendering failures for custom views. Fix compilation problems first.
How do I fix this, so I can actually create/edit ids without restarting Android Studio every time?

Related

Unusable project in Android Studio

I have been working on an app for 2 years, 1 month ago I stopped updating it to focus on other things and today I wanted to resume the project. The last time I made changes it was working fine. Today I opened Android Studio and without making changes I tried to run my app on the device that I always use for testing but never compiled, I received "Read time out", Restart Android Studio and now all the classes in the app appear with errors that do not exist (context and type errors: cannot resolve method, cannot find symbol),I have tried using the options:
Invalidate caches / restart
Clean project
Rebuilt project
But the problem continues, I am not attaching code because it is not a programming error, I assume it is from Android Studio... I have no idea what could happen or how to solve it, I will appreciate every answer
Try deleting .gradle and .idea folders of the project. Then open the Android Studio and clean and rebuild the project again.
If the problem persist try checking the android dependencies and see which one is creating the problem.

Gradle 'APP' project refresh failed Cause:Java.Lang.NullPointerException

sincerely, I tried almost EVERYTHING that is on the internet.Even not directly related to this specific problem.This problem is happening in Android Studio even before I Installed the latest version.I was about a month without working in Android Studio.The only thing related to Gradle that I messed with, was adding the LibGDX to Eclipse for a University work.I may be talking nonsense, but a think the problem appeared after that, because I had to install the SDK for Eclipse and this may be caused the issue.
When I open Android, I can't build my apk.So I made several changes to the app and noticed that nothing changed.So I Looked to the Gradle build and saw:
Error:Failed to complete Gradle execution. Cause: unknown.
in Gradle Sync I got:
Gradle 'BluetoothConnector' project refresh failed
So I tried:PrintScreen of the Android Studio error
◘Updating Android Studio
◘Turning off Oflline mode.
◘Reinstalling(I did it several times with false hopes) every thing
related to Java(JDK,Java,JRE,Eclipse,Android Studio).
◘Checked the project Structure, add Dependecies entries.
◘Invalidade Cache/Restart
◘Export/Reimport.
So as you fellow programmers can see, I'm kind of struggling hard with this problem.Before I ask a question, a very long battle has already been going on for quite a while.And I simply don't know what else to do.
I tried starting a new application, and the same refresh error appears. All my other apps as well.
Unfortunely the only solution was a clean formating of the PC.I have no Idea what caused this, but it was the only thing left to do.And it worked.If Anyone come across this issue, that's really what do to.
Try this, it worked for me.
1. Change compile to implementation or api (As compile is now deprecated)
2. Clean the project
Check following links for more details:
Gradle Project refresh failed error
Use the new dependency configurations

New Android apps can't find Theme.AppCompat.Light

I've made a couple of Android apps that went really well, and no errors came up. But now, in Eclipse, whenever I try to make a new Android Project, errors come up saying
error: Error retrieving parent for item: No resource found that matches the given name '
Theme.AppCompat.Light'.
Even though the exact same theme/style is in my other, perfectly working Android projects, the projects I try to start have these errors, and don't generate a R.java file. Any ideas why? And yes, I imported AppCompat, v7.
EDIT:
It shows up in 'Android' under Properties w/ a red X, when I add it again it has a green check, but if I close and reopen properties it changes to an X again. WHY!?!?!?!? I've tried cleaning, too, but it doesn't change anything. There's no R.java generated, errors in the MainActivity, somer AppCompat problem that doesn't even exists w/ my earlier projects. What's causing this?

Error in appcompat_v7 and every eclipse project

I just started android programming and downloaded the latest versions of ADT and android SDK. However, any new project I try to create is having 4 errors.
One of the errors is " Error executing aapt. Please check aapt is present at /home/nikhil/Android/adt-bundle-linux-x86_64-20140702/sdk/build-tools/android-4.4W/aapt " .
The type of the error is Android Packaging Problem and the problem occurs in appcompat_v7.
The aapt file is exactly at the specified place but somehow eclipse cant execute it.
The other 3 errors are "R cannot be resolved to a variable" and it occurs in MainActivity.java.
I am running Arch Linux 64 bit and using Eclipse IDE for Android Developers 23.0.2.1259578.
I am trying to create My First App and is puzzled to see errors before i wrote a single line of code!
This happends occasionaly and the usual way I fix this is to go into Projects -> Properties -> Android -> then choose appcompat from the list, apply, then go. The R cannot be resolved to a variable is usually because there is an error in one of your XML files which you have to resolve.

multiple eclipse error when starting eclipse, opening project

yesterday i just tried to run my application on real mobile device, and it did. just that the application itself have coding error. but then when i open my other project, start eclipse today, there are manny errors. i forgot exactly which error appear when.
.java.util.ConcurrentModificationException,No repository found at file, , Plug-in com.android.ide.eclipse.adt was unable to load class com.android.ide.eclipse.adt.ToolsLocator. An error occurred while automatically activating bundle com.android.ide.eclipse.adt (2), :/C:/Users/My%20Name/Downloads/. right now all my import the "android" becomes cannot be resolved. along with all my other object can't work. like LocationManager, button, onClickListener,String..com.google.android.gms.maps, setContentView, Bundle...and more..
i do not know what cause these error, my eclipse seems to be missing some files. i never download anything extra on eclipse before. i tried updating but it has nothing to update. should i uninstall and reinstall eclipse? i prefer to avoid that to save me working all over again but it seem there are no other choices? i uses eclipse for a long time that nothing like that happened before..

Categories

Resources