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?
Related
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?
Picture one:
http://www.directupload.net/file/d/3572/gkx2b7ge_jpg.htm
Picture two:
http://www.directupload.net/file/d/3572/knljgb8m_jpg.htm
Hey Community.
I have a Problem as follows: After i cleaned my Project Test2 in Eclipse, Eclipse doesn`t seem to find any views or xml files from R.java anymore.
The Problem message for every view or xml:
"view name or xml" cannot be resolved or is not a field.
What i've tried so far:
I cleaned the project several times, and built it again - doesn't work.
I disabled automatic building and tried again - does´t work.
I deleted the project from the workspace and imported it again - doesn't work.
I deleted Eclipse, set up a whole new workspace and imported my project - doesn't work.
I tried this solution ("id cannot be resolved or is not a field" error?) checking if i imported R manually. Which i did. After i took it out of the code the problem is still there though.
Trying to update Eclipse failed. It seems to not find any updated.
My code was working fine just before i cleaned the Project. As you can see in the second Picture, there is no errors concerning any other Problems.
If R does not generate after a build anymore. It means that you have errors in your xml files.
Try right click on your project -> click Android Tools -> Fix Project Properties
Tell me the possible solution for R.java file missing or "R cannot be resolved to a variable"
I have tried the following still R cannot be resolved as a variable error is coming.These are the following things i have tried:
Make sure that anything the R. links to is not broken. Fix all errors in your XML files. If anything in the ADKs are broken, R will not regenerate.
If you somehow hit something and created import android.R in your activity, remove it. Run Project -> Clean. This will delete and regenerate R and BuildConfig.
Make sure Project -> Build Automatically is ticked. If not, build it manually via Menu -> Project -> Build Project .
Wait a few seconds for the errors to disappear.
If it doesn't work, delete everything inside the /gen/ folder
If it still doesn't work, try right-clicking your project -> Android Tools -> Fix Project Properties.
Check your *.properties files (in the root folder of your app folder) and make sure that the links in there are not broken.
Right-click your project > properties > Android.
Look at the Project Build Target and Library sections on the right side of the page. Your Build Target should match the target in your AndroidManifest.xml. So if it's set to target 17 in AndroidManifest, make sure that the Target Name is Android 4.2. If your Library has an X under the reference, remove and re-add the library until there's a green tick. This might happen if you've moved a few files and folders around.
What to do if R doesn't regenerate
This usually happens when you have a broken xml file.
Check errors inside your XML files, mainly within the /res/ folder
Common places are /layout/ and /values/ especially if you've changed one of them recently
Check AndroidManifest.xml, I find that often I change a string, and forget to change the string name from AndroidManifest.xml.
Check that Android SDK Build-tools is installed. Window->Android SDK Manager->Tools->Android SDK Build-tools
Make sure when you update the Android SDK Tools, you also update the Android SDK Platform-tools and Android ASK Build-tools. Build fails silently if they don't match.
If you can't find the issue, right click /gen/ -> Restore from local history... -> tick R.java -> click Restore. This doesn't solve the problem, but it will clear out the extra errors to make the problem easier to find.
I believe you give the effort but only the problem is XML Error in your layout file.You give a wrong id or something like that.Because this also happened with me and finally i found the error in my xml file and when i fix that error and pressing CTRL and Key S.Eclipse builds the R file..!
I also suggest you to get the R file from project backup and again give a try.
always check your res folder first, if there is an error there, the build will fail, resulting to no generation of the gen files
There is some error in your Xml code.
What you have to do is find it and correct it. it may be any error like hwight and width not specified for some view.
once You have done it your R.jaav will be created just fine.
if still not so clean Your Project and recompile will do the Trick.
So I'm trying to import an existing project to eclipse and it's causing me a lot of trouble. I'll explain step by step, exactly how I'm trying to import it and someone please help me finish the importing because no matter how I do it, I still keep getting errors.
So as soon as I finish importing the existing android application there is a red exclamation mark (!) next to the project folder in eclipse. So I right clicked it and selected 'configure build path'
I then click on every single jar and select a new path. First, I found android support v4 in sdk/extras/android/support/v4, then I found google-play-services_lib in sdk/extras/google/google_play_services/libproject/google-play-services_lib/bin, and the last one (google-play-services) is at google-play-services_lib/bin.
So now after I'm done setting paths for those jars, the red exclamation mark disappears and a new error appears.
Now I right clicked the project again and selected properties --> android and this is what I see:
I then imported google-play-services_lib in eclipse as 'library project', but the red cross remained there, so I tried adding it manually with 'add button'.
As for the other 2 missing libraries, I googled about it and found out that CaptureActivity is from zxing barcode scanned library. So I downloaded the newest zxing version (2.2) and imported the library manually, same as I did with google play services. Right after importing CaptureActivity in eclipse and before even adding it to my application, this is what happens and I have no idea how to fix it.
Even though the eclipse gave me an error when importing zxing 2.2, I still added it to my project's libraries and now some errors disappeared. The only error I'm still getting is on qr_portrait_camera in folder layout:
So I right clicked my imported project again to see build paths again and this is what I notice:
So this is it. This is where I'm stuck and can't go forward, I googled a lot, did every kind of research I could and I don't know what to do anymore.
These are the three remaining problems that I've got:
I need to import one more library and I don't know where to find it (PortraitQR):
CaptureActiviy imported library project still shows a lot of red errors and I don't know how to fix that.
There's a CaptureActivity.jar in build path that shows an error and I can't either remove it or find a path to it.
I really need to fix this as soon as possible, I will be very grateful for any kind of help!
I figured it out. I just had to put all jars in libs folder and then download all 3 libraries, The one missing was causing all the trouble.
My laptop recently crashed, so I got an old desktop PC up and running. Got Eclipse installed along with Android SDK.
But when I check my Android project out of Subversion into Eclipse, I get errors that suggest it cannot find the ViewPagerIndicator library (which I did already add to my workspace/projects as a library).
When I go to my Android project's properties, on the Android tab at the bottom, and add the ViewPagerIndicator as a library it shows a green checkbox:
I click OK, and dialog dismisses. But then when I try building I get these errors:
E:\Workspace\foobar\res\values\styles.xml:4: error: Error: No resource found that matches the given name: attr 'vpiTabPageIndicatorStyle'.
E:\Workspace\foobar\res\values\styles.xml:7: error: Error retrieving parent for item: No resource found that matches the given name 'Widget.TabPageIndicator'.
If I go back into my project's properties on the Android tab, the same ViewPagerIndicator library that had a green checkbox not 3 seconds prior now has a red X, and there's question mark beside it in the "Project" column:
Both my project and the ViewPagerIndicator project are set to compile with Java 1.6 and are both targeted at SDK v16.
Oh, and yeah the same Subversion revision was building just fine on my laptop so all the files are identical as they were before.
I don't feel right posting this as the answer to my own question because I'm still at a loss for what I was doing wrong, if anything.
But I ended up removing both my project and the ViewPageIndicator library project from my workspace, then re-adding them back. Everything worked. Go figure. Maybe this will help someone else.