I have a problem. When I start a new project in Android Studio and select a navigation drawer activity it happens. I don't have access to my activiy_main_drawer.xml on "Design" and it keeps saying "Waiting for build to finish.". I really don't know what I have to do. I tried to uninstall and reinstall Android Studio, and it didn't help.
I've just run into the exact same problem. I simply solved it by choosing Sync Project with Gradle Files. This will trigger a Gradle re-import and a build.
As of Android Studio v3.2, the icon is located near the top right tool bar. You can also find it using Find Action shortcut CtrlShiftA.
You can do the following:
"File > Sync Project with Gradle files" (worked for me)
File > Invalidate Cache & Restart > Just Restart
OR
File > Invalidate Cache & Restart > Invalidate & Restart
Close Project and Re-Import the Project
File -> Sync project with Gradle files
What worked for me was, from the top menu:
Build -> Clean
Build -> Rebuild Project
After that the xml design worked
Syncing gradle, reopening, rebuilding, invalidating caches and restarting, trying different Android studio versions. None of these helped. When I would open XML preview I would still see that damn issue.
What helped in the end is closing Android studio, going to gradle directory:
cd ~/.gradle/
And deleting caches folder:
rm -rf caches
After that reopening Android studio will take some time as it still has some rebuilding to do, but afterwards all xml layouts were being properly rendered again.
I am using Android Studio 3.1.3 (#AI-173.4819257), Android Build Plugin for Gradle 3.1.3 and Gradle 4.4. I tried all possible options mentioned on various posts but nothing worked for me. I want to use ConstraintLayout which is default with AS 3.1.3. My observation and workaround are as follows.
Observation: This issue occurs when a new project created with empty activity and default layout. I also get "IDE Error Occurred" once Gradle sync finishes.
Workaround: Create an empty activity, activity class (MainActivity.java) and layout (activity_main.xml). Once it is done, create a new layout file (say activity_cltest.xml) using New -> Android Resource File after clicking right button on "app". Create new layout as per your requirements. Once done, update MainActivity.java by replacing R.layout.activity_main with R.layout.activity_cltest.
I also tried to copy content of activity_cltest.xml to activity_main.xml but still for activity_main.xml, error persists. Effectively, once a new project is created, activity_main.xml should not be used and deleted.
However, for some reasons, syntax highlighting of "R.layout.activity_cltest" within MainActivity.java doesn't work.
Just create a new XML file using the same name and copy paste activiy_main_drawer.xml file codes. It works for me.
Have the save problem, the Android SDK was missing from my system.
After installation of this missing SDK, its running fine.
In my case it was because I specified recycler view's tools:listItem="<item_layout>" in body of <item_layout> (nested recyclerviews). Just removing this tools option solved it.
I uninstalled my 3.1.2 and installed version 3.2 Canary 18 from Android Studio download archives. Everything is fine now.
We welcome all constructive edits, but please make them substantial. Avoid trivial edits unless absolutely necessary.
Ah... I resolved it with the help on this page and a little bit more effort.
I installed Android Studio v.3.3.1 today on my Zenbook. I was stuck with the same error "waiting for a build to finish" and Display tab was not showing up for activity_main.xml
Here is what I did to resolve this error.
Step 1. I searched for SDK tools and downloaded required SDK versions.
Step 2. downloaded Gradle 5.2.1 and extracted the files in Program Files\Android\Android Studio\gradle
Step 3. File>Settings>Build..>Gradle and choose the local distribution of Gradle 5.2.1
Step 4. Go to File>Sync Project with Gradle files and allow some time to sync...
finish() :) developing android with Kotlin
My experience: I was accidentally importing "myself" into the view, creating infinite loop:
item_task.xml
<androidx.recyclerview.widget.RecyclerView
...
tools:itemCount="3"
tools:listitem="#layout/item_task" /> <---- circular dependency mistake
Setting a correct list item in the recycler view solved the issue.
I upgraded to AS 3.6 RC1 because of this time-waster but it still intermittently occurs!
Simply restarting AS has so far been working for me.
I've also faced this problem. The above solution wasn't worked for me.
I just restarted my Android Studio by closing the Android Studio application and opening it again from Start Menu. It works for me. Try this solution if the above not working. Hope this will helpful for you.
In my case, I was using an alpha version of material design lib, and it was not able to render any view in the project. Solved by downgrading to a stable version.
Stuck w/ the issue for a month, got it after AndroidX update.
Tried to invalidate caches, manually remove them (project, grade, studio), re-install studio, re-import project - nothing helped.
This script resolved it finally (w/ -nuke option)
https://github.com/rock3r/deep-clean
Sometimes while converting the code from java to kotlin some library may get imported like import android.R
Just remove this library.
Check this tools:context=".MainActivity" in xml while copying another XML the class name will also get copy.
Else try File -> Sync project with gradle or rebuild the project.
Related
I am new to AndroidStudio AND Gradle.
I imported a project from eclipse, created a module, and tried to run the project, but I got this error:
AndroidManifest.xml doesn't exist or has incorrect root tag
I have been looking at this previous solution for it:
How to build an android library with Android Studio and gradle?
But that solution is WAY too advanced for me.
Could someone please help me understand in simpler terms what is going wrong and how I can fix it?
Thank you!
Update after one of the answers:
These are the options I have under the build menu:
clicking on Sync project with Gradle files button will solve your problem.
That button is under File section on Android Studio 3.6.1
Close your Android Studio
Goto C:\Users\user\.AndroidStudioX.X\system and DELETE the cache
folder
Launch the Android Studio
Goto Build (menu) -> Clean Project when done click the
Build (menu) again and click rebuild project.
That should solve the problem.
For me the issue went away once I opened the android folder of the project in Android Studio to run the project.
So basically, because I was trying to run the Android project from the Root folder, it gave me the error. We need to run the project by selecting the android folder of the project only.
Hope this helps someone!
Click on File > Invalidate Cache/Restart, and that's it. Your project should start working.
For me clicking on Sync project with Gradle files button did not solve the problem alone.
After Syncing project with Gradle files, I explicitly had to invalidate the cache and restart studio. Only after this action, the red cross-mark over configuration disappeared and everything started working.
In my case, my android project got corrupted and some of the files were showing characters, binary numbers, etc. I tried the following solutions
Invalidate & Restart
Rebuild Project
Sync with Gradle File
But none of the above solutions worked for me.
Then I just deleted the cache folder under C:\Users\username\.AndroidStudio3.6\system
and all the invalid characters disappeared and the actual contents of all the files were displayed. This solution worked for me.
Every Android project needs a file called AndroidManifest.xml to tell Android about itself. Either your project doesn't have one, or it's not in the place that Android Studio expects it to be. Try to find it, and move it to the root folder of the project.
1.Check whether the manifest file is there or not.
2.If it is there, check whether the package name is correct or not..
3.If you project has small number of classes, then you create new project in android and then copy paste your code from eclipse. It will be simple. But it is recommended only for small project.
And finally click 'Sync' in the Gradle file. Followed by Rebuilding the project will do a trick.
In my case the Manifest file seemed to be corrupted or maybe its meta data. Trying to open it in Android Studio will show some characters that you see when opening a binary file with a text editor, for ex. Anyway, my project is under Git, so I just deleted it and restored it back, problem fixed.
Go to C drive click User then select your android studio folder then select System find Cache folder and delete this folder before doing this close your android Studio.It will surely work.
I also had this problem, things I tried:
I delete user->gradle-> delete cache folder
Android studio-> file-> Invalid cache/restart
Using my problem is get resolved
I also had this problem, things I tried:
Syncing the file with gradle
Invalidate/Restart
But the problem was still there in the manifest folder-> manifest.xml file it had only 1 line.
So I went to User-> your_username -> Android Studio v -> caches and Deleted the cache folder.
Started Android Studio, and my problem was gone.
But I am not sure which of these might solve yours.
I have opened AndroidManifest.xml in file editor. Add some letters, save it, then android studio found AndroidManifest.
After this I can build project successfully
if your AndroidManifest.xml looks wierd than you can try checking local history or git history. by doing that you can copy paste the previous version AndroidManifest.xml
Experienced that too, there is a line on your manifest code that's incorrect, simply go through it and make necessary corrections.
I'm importing twitter4j in AndroidStudio, using the following in my build.gradle:
dependencies {
compile 'com.android.support:support-v4:18.0.+'
compile files('libs/twitter4j-core-3.0.4.jar')
}
The project compiles fine, and I can create twitter objects without a problem. However, in Android studio, anything referencing that library shows "cannot resolve symbol" and displays in red. What do I need to do to get Android Studio to recognize the library?
I have already tried rebuilding the project, ./gradlew clean, and closing and re-opening my project.
No idea if this will work or not but my only thought so far: right click the jar file in file tree within AS and select "Add as library..."
EDIT: You can do "File" -> "Invalidate Caches...", and select "Invalidate and Restart" option to fix this.
EDIT 2: This fix should work for all similar incidents and is not a twitter4j specific resolution.
Try changing the order of dependencies in File > Project Structure > (select your project) > Dependencies.
Invalidate Caches didn't work for me, but moving my build from the bottom of the list to the top did.
This is what worked for me.
In the Project panel, right click on the project name, and
select Open Module Settings from the popup menu.
then change the Compile SDK Version to the minimum version available (the minimum sdk version you set in the project).
wait for android studio to load everything.
It will give you some errors, ignore those.
Now go to your java file and android studio will suggest you import
import android.support.v4.app.FragmentActivity;
Import it, then go back to Open Module Settings and change the compile sdk version back to what it was before.
Wait for things to load and voila.
For mine was caused by the imported library project, type something in build.gradle and delete it again and press sync now, the error gone.
I also had this issue with my Android app depending on some of my own Android libraries (using Android Studio 3.0 and 3.1.1).
Whenever I updated a lib and go back to the app, triggering a Gradle Sync, Android Studio was not able to detect the code changes I made to the lib. Compilation worked fine, but Android Studio showed red error lines on some code using the lib.
After investigating, I found that it's because gradle keeps pointing to an old compiled version of my libs.
If you go to yourProject/.idea/libraries/ you'll see a list of xml files that contains the link to the compiled version of your libs. These files starts with Gradle__artifacts_*.xml (where * is the name of your libs).
So in order for Android Studio to take the latest version of your libs, you need to delete these Gradle__artifacts_*.xml files, and Android Studio will regenerate them, pointing to the latest compiled version of your libs.
If you don't want to do that manually every time you click on "Gradle sync" (who would want to do that...), you can add this small gradle task in the build.gradle file of your app.
task deleteArtifacts {
doFirst {
File librariesFolderPath = file(getProjectDir().absolutePath + "/../.idea/libraries/")
File[] files = librariesFolderPath.listFiles({ File file -> file.name.startsWith("Gradle__artifacts_") } as FileFilter)
for (int i = 0; i < files.length; i++) {
files[i].delete()
}
}
}
And in order for your app to always execute this task before doing a gradle sync, you just need to go to the Gradle window, then find the "deleteArtifacts" task under yourApp/Tasks/other/, right click on it and select "Execute Before Sync" (see below).
Now, every time you do a Gradle sync, Android Studio will be forced to use the latest version of your libs.
When i lived to this problem(red color codes but they work correctly) in my project;
As first, i made it that (File -> Indicate Cashes) --> (Invalidate and Restart).
As last, i resync my build.gradle file in my app. After problem was resolved.
Invalidate Caches / Restart didn't work for me this time.
Found a solution like this:
Remove the compile *** or implementation *** line in build.gradle.
Clean and rebuild. Errors should be raised here.
Add the line in step 1 back to build.gradle.
Clean and rebuild.
Weird...
This problem happened for me when my Glass project was not using the SDK installed in Android Studio's default location. I was using another location I had previously from ADT, since I was trying to avoid re-downloading everything. Once I pointed the project back to the SDK location in Android Studio's install location the problem went away.
I had this problem for a couple of days now and finally figured it out!
All other solutions didn't work for me btw.
Solution: I had special characters in my project path!
Just make sure to have none of those and you should be fine or at least one of the other solutions should work for you.
Hope this helps someone!
I had the very same problem recently with Android Studio 1.3. The only working solution was to remove the .gradle and .idea folders and re-import the project into Android Studio.
For those, who tried the accepted answer and have no success,
I tried also the accepted answer and did not work for me. After that, I updated my project with the repository and synchronized the project and the could not resolve warnings are gone.
Invalidate Caches didn't work for me (this time). For me it was enough changing the gradle and syncing again. Or https://stackoverflow.com/a/29565362/2000162
If nothing else helped, you could do as Android Studio suddenly cannot resolve symbols recommends:
Exit Android Studio
Back up your project
Delete all the .iml files and the .idea folder
Relaunch Android Studio and reimport your project
In my case, I had created a new file using the GUI and defined an interface within the file. I kept getting this symbol error because the file was not a "java" file. It had no extension on it at all.
After modifying the file extension to ".java", the system correctly finds the symbols.
In my case the jar file did not have a META-INF/MANIFEST.MF file. After adding one, it worked!
For my case working with AndroidStudio 2.2.3 the solution was to change the gradle wrapper/distribution to use local one in the Gradle Settings (despite of being "recommended").
This worked for me--
(File -> Indicate Cashes) --> (Invalidate and Restart).
I tried Invalidate cache/restart or clean Project -> rebuild project. These didn't work for me.
The final solution was open Project window on the left side of IDE, under Project mode, delete .gradle and .idea folder, THEN you can invalidate caches and restart. This fixed it.
Change compile to implementation in the build.gradle.
Changing the language injection settings worked for me.
Place the cursor on any of the red underlined code and Alt + Enter
Now select Language Injection Settings and a window will open as shown below.
Uncheck the selected option and click Ok
Hope this helps somebody.
It happened to me when I removed the whole files in .gradle/caches, then studio downloaded the dependences. The dependences not showed in the External Libraries but I can build App successfully. rebuild clean Invalidate and Restart have no effect. I solved the problem by the steps:
Close Android Studio completely
Remove .idea package in your project
Restart Android Studio
I have tried this but nothing worked for me:
Invalidate Caches / Restart
Changing the order of dependencies
Sync project with Gradle Files
Clean -> Rebuild Project
In my case, just do:
Delete all files in .idea/libraries folder
Rebuild Project
For me I updated gradle-wrapper.properties into 4.4
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip
I found easiest way
Identify the library which is causing syntax error in Studio.
For Example if AppCompatActivity is showing error then you will perform below operation on AppCompat Dependency.
Remove dependency which is showing syntax error & Sync.
Add again & Sync.
That's It, error gone!
Before
After
None of the answers above works for me.
After a lots of attempts, I upgraded com.android.tools.build:gradle in Project/build.gradle from 2.3.0 to 3.0.1, and it works.
I guess the version of the com.android.tools.build:gradle should be match to the version of AndroidStudio, and my AS version is 3.2.1
I tried all of the posted solutions and none of them worked for me. (Though invalidate caches does normally. This time it made no difference). After trying everything posted here the "Error cannot resolve" were still present. And the project did build and run successfully, only the IDE seemed to be confused, not the actual app or device.
My Version of Android Studio is 2021.3.1:
The solution that did finally work for me was updating the "Android Gradle Plugin Version" configuration inside of File -> Project Structure.
It was originally 3.2.1 when it wasn't working. I updated it to 3.5.3 because I have another project that was working fine and it was on that setting.
After making this change and then sync'ing gradle the symbols not resolved error goes away and the IDE once again knows what those classes are.
Closing all files and closing Android Studio works for me.
You need to restart Android Studio.
I have installed Android Studio version 1.0.1. I have imported my projects from eclipse and it works fine.
Then I deleted a module and reimported it into my Android Studio project. The gradle build says "BUILD SUCCESSFUL" but it pops up an alert window with the message
Failed to complete Gradle execution.
Cause:
Already disposed: Module: 'MYMODULENAME'
I can't start my app now. Any idea what I can do?
Edit:
I solved the problem with the following instructions:
Switch project view from Android to Project
Remove entry include 'MYMODULENAME' in settings.gradle
The blue box in the module symbol don't show. Then you can delete the module in the context menu
Import the module
Note: this is purely an IDEA/AS issue, gradlew clean | Build > Clean | Build > Rebuild will just waste your time.
Most of the solutions here are blind stabbings in the dark. Here's what I found to be the root cause:
Some of the .iml files may be missing (maybe because we deleted it),
check if the module erroring has .iml.
If it is missing, check if .idea/modules.xml has an entry for that module
While syncing I noticed that IDEA/AS tries to put a new duplicate entry into .idea/modules.xml while there's already one. This duplicate entry is probably disposed of twice while the sync tries to reset the modules in memory.
Quick Solution: In order to make it work the easiest is to delete .idea/modules.xml along with the .iml files. Additionally may worth deleting .idea/modules/ folder if it exists. Restart Android Studio (no need to clear cache) and force a Gradle sync from Gradle view or toolbar to recreate the files.
I figured out this problem by:
./gradlew clean
Restart Android Studio
Simplest solution. (Try this first).
Quit and Restart Android studio. (Quit not close)
Build > Clean your project if needed.
works for me:
File -> Invalidate Caches / Restart... -> Invalidate and Restart
Sometimes gradlew clean or Invalidate Cache and Restart does not help, because these methods do not clean Android Studio specific files by themselves.
In this case, close AS and remove .idea directory and .iml file in a root project where settings.gradle file exists. This will make AS rebuild from the fresh ground.
For me this happened when i deleted a module and built a new one with the same package name
Solution:
Clean & Restart Studio
In the left pane, change to "Project" view.
Delete MYMODULENAME.iml
For an alternative solution, check if you added your app to settings.gradle successfully
include ':app'
For me this happened when I removed a module and tried to build the project:
Simple solution was to Invalidate the cache & Restart.
Android Studio>File>Invalidate Caches>Invalidate & Restart
Had a similar issue when working with RN components in my Android project and the only way to get around this issue was to ignore the gradle project.
To do this:
Click on the gradle tab on the right hand side of AS
Right click the gradle module which is causing an issue
Click "Ignore Gradle Project"
Perform a gradle sync which should be successful now
If you need this module perform the 4 above steps again, this time when right click on the gradle project it'll show "Unignore Gradle Project"
Gradle sync should now work
No idea what causes this but I've had this happen to me when using React Native Maps.
Note: If you're still having issues following this. Try to refresh the gradle project which was causing issues.
If gradle clean and/or Build -> Clean Project didn't help try to re-open the project:
Close the project
Click "Open an existing Android Studio project" on the "Welcome to Android Studio" screen
Select gradle file to open
Warning Be aware it's a destructive operation - you're going to loose the project bookmarks, breakpoints and shelves
below solution works for me
Delete all .iml files
Rebuild project
For Solve this issue take it this simple steps.
Find the .idea folder in your Android studio under the Folder Project.
In .idea --> Find this one. .idea/.modules
Simple Delete that .modules folder and restart Your studio.
when it reopens gradle sync Automatically and also recreate .modules folder and files.
Error has gone !
I also face this problem sometimes. Click on gradle console in bottom bar of android studio, at right side. It will show the exact error in logs. My problem was that I had compile SDK 22 and imported appcomact library was of sdk 23.
I had the same problem,
after delete some gradle files (of aws)
i solved it by mark them "ignore gradle"
I believe it is not the best answer but it solve it for me
Gradle (at the right bar)--> right click on the problematic gradle --> ignore
Although the accepted answer didn't work for me (unfortunately I can't leave a comment), it led me in the right direction.
in .idea/libraries i found that there were some duplicate xml files (the duplicates were named with a 2 before the _aar.xml bit).
deleting those, restarting android studio and sync fixed the error
I was having this issue because gradle and Android Studio were using a different path for the jvm. In the Event Log there was an option for AS and gradle to use the same path. Selecting this and then doing an invalidate cache & restart resolved the issue for me.
In my case, same as in this question, it happened because I had my project in a symbolic link directory. After reopening the project in the real directory and reconfiguring gradle (File -> Sync with Gradle files) the problem went away. Shame on you, Android Studio!
I'm importing twitter4j in AndroidStudio, using the following in my build.gradle:
dependencies {
compile 'com.android.support:support-v4:18.0.+'
compile files('libs/twitter4j-core-3.0.4.jar')
}
The project compiles fine, and I can create twitter objects without a problem. However, in Android studio, anything referencing that library shows "cannot resolve symbol" and displays in red. What do I need to do to get Android Studio to recognize the library?
I have already tried rebuilding the project, ./gradlew clean, and closing and re-opening my project.
No idea if this will work or not but my only thought so far: right click the jar file in file tree within AS and select "Add as library..."
EDIT: You can do "File" -> "Invalidate Caches...", and select "Invalidate and Restart" option to fix this.
EDIT 2: This fix should work for all similar incidents and is not a twitter4j specific resolution.
Try changing the order of dependencies in File > Project Structure > (select your project) > Dependencies.
Invalidate Caches didn't work for me, but moving my build from the bottom of the list to the top did.
This is what worked for me.
In the Project panel, right click on the project name, and
select Open Module Settings from the popup menu.
then change the Compile SDK Version to the minimum version available (the minimum sdk version you set in the project).
wait for android studio to load everything.
It will give you some errors, ignore those.
Now go to your java file and android studio will suggest you import
import android.support.v4.app.FragmentActivity;
Import it, then go back to Open Module Settings and change the compile sdk version back to what it was before.
Wait for things to load and voila.
For mine was caused by the imported library project, type something in build.gradle and delete it again and press sync now, the error gone.
I also had this issue with my Android app depending on some of my own Android libraries (using Android Studio 3.0 and 3.1.1).
Whenever I updated a lib and go back to the app, triggering a Gradle Sync, Android Studio was not able to detect the code changes I made to the lib. Compilation worked fine, but Android Studio showed red error lines on some code using the lib.
After investigating, I found that it's because gradle keeps pointing to an old compiled version of my libs.
If you go to yourProject/.idea/libraries/ you'll see a list of xml files that contains the link to the compiled version of your libs. These files starts with Gradle__artifacts_*.xml (where * is the name of your libs).
So in order for Android Studio to take the latest version of your libs, you need to delete these Gradle__artifacts_*.xml files, and Android Studio will regenerate them, pointing to the latest compiled version of your libs.
If you don't want to do that manually every time you click on "Gradle sync" (who would want to do that...), you can add this small gradle task in the build.gradle file of your app.
task deleteArtifacts {
doFirst {
File librariesFolderPath = file(getProjectDir().absolutePath + "/../.idea/libraries/")
File[] files = librariesFolderPath.listFiles({ File file -> file.name.startsWith("Gradle__artifacts_") } as FileFilter)
for (int i = 0; i < files.length; i++) {
files[i].delete()
}
}
}
And in order for your app to always execute this task before doing a gradle sync, you just need to go to the Gradle window, then find the "deleteArtifacts" task under yourApp/Tasks/other/, right click on it and select "Execute Before Sync" (see below).
Now, every time you do a Gradle sync, Android Studio will be forced to use the latest version of your libs.
When i lived to this problem(red color codes but they work correctly) in my project;
As first, i made it that (File -> Indicate Cashes) --> (Invalidate and Restart).
As last, i resync my build.gradle file in my app. After problem was resolved.
Invalidate Caches / Restart didn't work for me this time.
Found a solution like this:
Remove the compile *** or implementation *** line in build.gradle.
Clean and rebuild. Errors should be raised here.
Add the line in step 1 back to build.gradle.
Clean and rebuild.
Weird...
This problem happened for me when my Glass project was not using the SDK installed in Android Studio's default location. I was using another location I had previously from ADT, since I was trying to avoid re-downloading everything. Once I pointed the project back to the SDK location in Android Studio's install location the problem went away.
I had this problem for a couple of days now and finally figured it out!
All other solutions didn't work for me btw.
Solution: I had special characters in my project path!
Just make sure to have none of those and you should be fine or at least one of the other solutions should work for you.
Hope this helps someone!
I had the very same problem recently with Android Studio 1.3. The only working solution was to remove the .gradle and .idea folders and re-import the project into Android Studio.
For those, who tried the accepted answer and have no success,
I tried also the accepted answer and did not work for me. After that, I updated my project with the repository and synchronized the project and the could not resolve warnings are gone.
Invalidate Caches didn't work for me (this time). For me it was enough changing the gradle and syncing again. Or https://stackoverflow.com/a/29565362/2000162
If nothing else helped, you could do as Android Studio suddenly cannot resolve symbols recommends:
Exit Android Studio
Back up your project
Delete all the .iml files and the .idea folder
Relaunch Android Studio and reimport your project
In my case, I had created a new file using the GUI and defined an interface within the file. I kept getting this symbol error because the file was not a "java" file. It had no extension on it at all.
After modifying the file extension to ".java", the system correctly finds the symbols.
In my case the jar file did not have a META-INF/MANIFEST.MF file. After adding one, it worked!
For my case working with AndroidStudio 2.2.3 the solution was to change the gradle wrapper/distribution to use local one in the Gradle Settings (despite of being "recommended").
This worked for me--
(File -> Indicate Cashes) --> (Invalidate and Restart).
I tried Invalidate cache/restart or clean Project -> rebuild project. These didn't work for me.
The final solution was open Project window on the left side of IDE, under Project mode, delete .gradle and .idea folder, THEN you can invalidate caches and restart. This fixed it.
Change compile to implementation in the build.gradle.
Changing the language injection settings worked for me.
Place the cursor on any of the red underlined code and Alt + Enter
Now select Language Injection Settings and a window will open as shown below.
Uncheck the selected option and click Ok
Hope this helps somebody.
It happened to me when I removed the whole files in .gradle/caches, then studio downloaded the dependences. The dependences not showed in the External Libraries but I can build App successfully. rebuild clean Invalidate and Restart have no effect. I solved the problem by the steps:
Close Android Studio completely
Remove .idea package in your project
Restart Android Studio
I have tried this but nothing worked for me:
Invalidate Caches / Restart
Changing the order of dependencies
Sync project with Gradle Files
Clean -> Rebuild Project
In my case, just do:
Delete all files in .idea/libraries folder
Rebuild Project
For me I updated gradle-wrapper.properties into 4.4
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip
I found easiest way
Identify the library which is causing syntax error in Studio.
For Example if AppCompatActivity is showing error then you will perform below operation on AppCompat Dependency.
Remove dependency which is showing syntax error & Sync.
Add again & Sync.
That's It, error gone!
Before
After
None of the answers above works for me.
After a lots of attempts, I upgraded com.android.tools.build:gradle in Project/build.gradle from 2.3.0 to 3.0.1, and it works.
I guess the version of the com.android.tools.build:gradle should be match to the version of AndroidStudio, and my AS version is 3.2.1
I tried all of the posted solutions and none of them worked for me. (Though invalidate caches does normally. This time it made no difference). After trying everything posted here the "Error cannot resolve" were still present. And the project did build and run successfully, only the IDE seemed to be confused, not the actual app or device.
My Version of Android Studio is 2021.3.1:
The solution that did finally work for me was updating the "Android Gradle Plugin Version" configuration inside of File -> Project Structure.
It was originally 3.2.1 when it wasn't working. I updated it to 3.5.3 because I have another project that was working fine and it was on that setting.
After making this change and then sync'ing gradle the symbols not resolved error goes away and the IDE once again knows what those classes are.
Closing all files and closing Android Studio works for me.
You need to restart Android Studio.
I am using Eclipse Classic 3.7.2 working only on Android. I use Ubuntu as my OS. When I run any basic Android application on Eclipse say "Hello World", it results an error called Your Project contains error(s), please fix them before running your application.
Now I have googled and checked here and may others but I did not get the solution.
I also tried Project > clean... but it isn't working.
Windows->Show Views->Problems shows 2 errors:
Error generating final archive: java.io.FileNotFoundException:/home/android/Desktop/helloworld/bin/resources.ap_does not exist.
Unable to parse aapt...
It may be be because of Eclipse's debug certificate expiration.
Please look at to my this answer.
Close and restart Eclipse. It works everytime !
Its bug with deleting android projects I think.
I have faced exactly same type of issue. Just update your eclipse ADT plugin to latest version.
After update clean build the project.
Go to your .android folder and delete your debug certificate. In my computer it is in this path
E:\Users\(ur profyle)\.android
Inside that there is a file name 'debug.keystore'. Delete that,clean and try to build the project again. Sometimes this error is caused when the certificate expires.
You need to update your Eclipse to the latest available version(Indigo) and then need to update the ADT(level 16 I think), as the latest ADT updates works on Indigo only. After the updates close and reopen the Eclipse, it should work now.
Go to Project Properties -> Java Build Path
Select Libraries and remove Android Dependencies
After this my problem solved.
The error was because of updating
Set your Android sdk path once again and restart Eclipse. It fixes the issue (window-preferences-android-sdklocation).
Or, just update your Android tools and restart Eclipse works.
Check your libs folder ..
some libraries cause this ,
it happened to me once and i was use Apache POI .. i tried to delete the jars from libs folder and it's worked ..
I had this problem in Eclipse after executing Project => Clean... That option deletes all the compiled stuff from your project and, therefore, the java classes start looking like if they all have errros.
To fix that problem I had to:
1. open my java clases and XML layout files(for android dev)
2. do a small change, something like a adding a space
3. Hitting Crt+S to ask eclipse to save and compile the class once again.
This solution may or may not work for you. I recommend looking at your specific problems using the Problems tab of Eclipse (Found at Windows=>Show View=>Problems) since it tells you about the exact errors and other very useful information.
If you're using android support library make sure you have not added jar files ( android-support-v4.jar and android-support-v7-appcompat.jar ) in your libs folder.
you only need to add android-support-v7-appcompat as library on your project.
It worked for me the time I had the same issue
My project had no errors in it but I noticed another open (unrelated) project which did have errors. I closed that project and my other project worked fine again.
Now the "unrelated" project used to be related but I'd removed the dependency ages ago. Closing it solved my problem so I have to assume there is some Eclipse bug in there somewhere which is still linking to it in some way. I'd say if I created a new project and copied everything in it might have achieved the same result.
As a test for yourself.. maybe close all other projects except the one you are working on.