Files under the "build" folder are generated and should not be edited - java

This morning I was coding an app following a tutorial (https://www.youtube.com/watch?v=iFdtSi1v1Vk/) and after adding
compile 'com.microsoft.projectoxford:emotion:1.0.355'
as stated in the tutorial to the build.gradle and then syncing the gradle, almost everything in my manifest turned red and I got the message stating "Files under the 'build' folder are generated and should not be edited." How do I fix this? I have tried everything in other stackoverflow forums related to this query to no avail. I really do not want to start over as I have put a large amount of effort into this app and would be devastated.
Screenshots -- https://imgur.com/a/g46Ws

Fixed by removing the line of code that caused the issue and rebuilding the project, as well as syncing the gradle.

I solved the error by cleaning the project. In the android studio, navigate to the Build, the click on CLean Project. It will solve.

Related

Why can't i find the layout I have created my MainActivity.java file?

I was following the instructions online in android app development course for beginners and I encountered this problem.
The instructor was demonstrating how we could use the layouts we created for the activity. He was able to find the layout he created using R.layout., but I could not.
The activity_main_listview.xml is the View that I created. I am an absolute beginner so I don't know what is wrong here.
Is there any way I could resolve this problem?
I have tried to Synchronize both the .xml files and the MainActivity.java file. I have also tried to clean and rebuild the project.
This is a picture of the part where it did not work
This is common problem which occurs with Android Studio!
Its not your problem, it is bug of Android Studio!
To resolve this, Just Clean your project and Restart Android Studio!
I had the same problem, fixed by replacing R with com.example.appname.R obviously put your package reference in there instead. Or just add this line to your file:
import com.testapp.activitydemo.package.R
Or even better, try removing this line from your code if exists:
import android.support.compat.R
If your XML's contain errors your generated file might not build try erasing most of their content and making sure id's and file names are not duplicated and no capitals and spaces are used. If it works you can start adding stuff.
Another note:
Sync Project With Gradle File Once you update the Gradle plugin you need to sync project with the Gradle file. Open android studio and click on Files > Sync Project with Gradle Files option.
Clean and Rebuild Project The most effective solution is the simplest: clean and rebuild your project. Select Build > Clean Project from the Android Studio toolbar, wait a few moments, and then build your project by selecting Build > Rebuild Project.

R.layout.main Cannot Be Found / Cannot Resolve Symbol R

All of a sudden I am getting red underlinings under my references to elements e.g R.textboxID. I did some googling around and I found that the error occurs when Android Studio can’t generate your R.java file correctly.
My question is how does Android Studio just suddenly not know how to generate my R file correctly when it was generating it well all along? How can I fix this problem permanently?
Select Build > Clean Project from the Android Studio toolbar, wait a few moments, and then build your project by selecting Build > Rebuild Project.
If a single clean/rebuild cycle doesn’t work, then try repeating this process a few times, multiple clean/rebuild cycles in quick succession usually work.
This usually happens when some unexpected event, like an IDE error occurs and the project needs to be rebuilt. Just hit Build -> Rebuild Project.
Sometines this may occur after you modify your build.gradle file, and sometimes, if it only occurs within one of your classes, you might not be inflating it correctly.
Gradle sync succeded? Try one of the following:
Clean end rebuild your project
From Android studio menu: File->Invalidate cache/restart, then clean and rebuild project
If none of above helps, close Android studio and remove ~/.gradle directory. Then run Android Studio, open your project, wait for finish sync, then rebuild project
Also make sure your gradle configuration is correct and resource xml files syntax is correct.
Please check the import statements at the top of file some times there may be import com.android .R will be there so you should delete that statement and it will work fine

Error while trying to add AndEngine to my example project

I've downloaded the latest AndEngine from Nicolas on his Github repo. Made all the extensions compile on my workspace, everything was okay.
Created a project to start testing the Engine, but whenever I go to my example project properties > Android and try to add AndEngine or any of its extensions, there's a green tick... so I accept when I apply the changes, but when I open the Android configuration again and see the library imports, there's a red "X" on every import, like it failed.
Here's the screenshot:
Does anyone has encountered this problem before? How do I solve it?
No worries, made it work thanks to a guy from this forum
http://www.andengine.org/forums/tutorials/getting-started-with-andengine-t4858-180.html
Going to quote what he said, it really worked:
Hey, look, I can contribute! (Sorry, I'm just excited to be able to
add something here)
I had this same issue and resolved it by moving the libraries
(AndEngine, etc.) into my Eclipse workspace.
For instance, I originally had all my AndEngine files in C:\Users[my
user name]\git\AndEngine\ and encountered the same errors you
describe. After some Googling, I found that I had to move the
AndEngine library from .../git/ to my eclipse workspace, which is
located at F:\android-workspace
So in the end my project's files were located at:
F:\android-workspace[project_name]
And the AndEngine files were located at:
F:\android-workspace\AndEngine
Be sure to re-link the library to your project after moving it. Also,
I apologize for my verboseness, I just wanted to be clear.

R.java is missing on a clean Android Project

I'm creating a clean project on ADT and I noticed that the gen folder is empty (with no R.java in it), not letting me run the project. I'm running ADT with all stuff up-to-date (as you can see here)
I already cleaned and built it in every possible way. I also tried to reimport the project, and nothing. There are no errors in the XML files.
I searched for a solution and I found a lot of people with the same problem, and in most cases the solution was to update the SDK tools, but it didn't work for me.
Is there a reason for this?
at the top of screen, click build -> rebuild project
Give it a few seconds. it worked for me, i hope it save you aswell
im using Android Studio(beta) 0.8.9
My R disappeared after i fiddled with sound files in my res/raw directory(converted them to different formats, figuring out how SoundPool class works...and suddenly there is red "R"'s everywhere!
Try right clicking on the project, then going to Android Tools > Fix Project Properties.
If that doesn't work, then try cleaning it before and possibly after that.
If R.java disappears, you usually have to recreate the project from scratch again.
There are many reasons for R.java missing issue, i use to face this issue frequently, some of my thoughts to debug this issue.
Try creating another test project using File->New->Project->Android->Android Application Project. After creating the project run the project in emulator. If every thing works then your setup is perfect.
Check your imports section of your java files, some times default R.java gets included which is from android package. In this case Remove that import and add correct import statement.
Check your "res" folder all the xml's should be well formed and valid.
Hope these debugging steps may help to find the root cause.
try deleting the r.java file in gen folder. when you run again after cleaning and building the project. It should recreate those files and it should work after that. Try that.
Other wise you might have to reinstall Eclipse as you have tried in so many different projects
Something I just noticed was that after I removed the auto-generated code for the menus (which I wasn't using) it started causing errors. Eventually when I cleaned with the menu xml's still in the file structure, my R file disappeared. I removed all entries in the menu folder and then cleaned again. This worked for my specific instance. Hope this helps others as well.

R.Java not showing up

I've tried everything i can think of and i still can't get the R.java file to show up.
It's supposed to be in the "gen" folder in eclipse when i create a new project i believe.
I tried the following:
I went to Project > Clean...
I heard that there might be issues in the xml files, i couldn't find any errors there.
I tried using both android 2.1 and 2.2(my goal is to program in 2.2 but i tried both anyway).
Please help. I've seen a few other questions regarding the same issue on here; i've tried using the suggestions found in the answers to those questions but unfortunately, no luck.
Progress: 1
SOLVED: I found out i was missing Android SDK Platform Tools. If you're having the same problem, make sure you have it installed.
Go to Window > Android Sdk and Avd Manager > Available Packages > Android Repository > Android SDK Platform Tools(the latest version) > Install. Sorry for causing any confusions. I will one-up those who put some effort into helping me. Thank you very much for your efforts. :)
Try a right-click on the project and select "Refresh". This usually does the trick for me when "Clean" does not.
you shall find the answer here..tat works for me. just try...
R file is missing android
I have faced the same problem many times untill and unless u wont remove errors from ur
xml file or any java file.
Then clean uo ur project....
Cleaning of project wont work in case there is errors,plz check for the same
if above option not working then try project->built automatically checked then clean project then try to run it

Categories