All my projects in eclipse are showing error? - android

I opened my eclipse SDK and there all my projects are showing some sort of error. It is showing error in the java files. Even the imports are throwing error.. Please help me with this....!
I even tried restarting it several times.

You should check in Configure Build Path -> Android and check which android version is selected and check whether your application manifest has same sdkversion specified in this path or not.If not same then select sdk version that you have given in manifest and rebuild your code.

try to change as below inside your project manifest file.
instead of
android:style/Theme.Holo.Light.DarkActionBar"
add
#android:style/Theme.Holo.Light.DarkActionBar
ie, android:theme="#android:style/Theme.Holo.Light.DarkActionBar
This will fix it..

Try updating your SDK, check whether you have a valid JRE and JDK path defined in Java Build Path. Check whether all your dependencies are all updated and properly linked.

Instead of re-installing Eclipse try changing your current Workspace directory and importing all your projects there.

Related

Please fix the 'sdk.dir' property in the local.properties file. Studio removed slashes in path. Import project error. How to solve, debug?

I am trying to import a project. It gives an error for local.properties
Please fix the 'sdk.dir' property in the local.properties file.
Found one similar question here, but no solutions worked.
Error is:
The SDK directory C:\MyProject\C:AndroidSdk does not exists
I edit local.properties and set sdk.dir=C\:\\AndroidSdk and hit Try again, but it is showing the same error and also removed slashes and saved C:AndroidSdk as property value in newly generated local.properties.
I am Working on windows, Android Studio version : 3.3.1
When you import or try to open a dev to dev project, Android Studio try to sync the project SDK, showing a message informing a SDK error. Do not click on the OK button.
Just close the message and try to execute the project.
Instead of importing the project, try to open it as an existing project, then you will get a prompt from the android studio that it didn't find the default path so it chose one specific to your computer
Couldn't find what actual problem was. But upgrading Android Studio to 3.4 solved this problem.
If i delete the local.properties and rerun the build all works.
File --> Invalidate caches/restart

APK path is not specified for module "Example-Example"

I am newbie in the world of android app development. I was creating a project Example on Android Studio. I have my LunchList.java file in src/main/java/apt.tutorial.lunchlist .Till yesterday Everything was working fine. But when I open android Studio today I got an error saying
"The modules below have been removed from Gradle structure. Check
those to be removed from the project too:"
☑ LunchList
☑ LunchList-LunchList
And there is OK and Cancel Button. I don't want to remove them. So I click cancel and proceed.
Then when I tried to run the application in emulator the emulator runs but nothing happens. And I got this error
Waiting for device.
Target device: emulator-5554 (Android)
ERROR: APK path is not specified for module "LunchList-LunchList"
I don't know what went wrong. Please help me.
[Edit: I tried unchecking both of them and click OK. But after that I'm not getting the first error but still getting the second error ]
Exit Android studio. Launch it with Administrator Privilege.
This solved the problem with Android Studio v0.1 in Windows 7.
I had the same issue, I unselected the 2 files and then received the error
"ERROR: APK path is not specified for module"
I just restarted Android Studio and reopened the project and then it worked normal again.
It is indeed a bug but there's a simple work around.
Here's what worked for me: delete .idea/ and *.iml files, then open a project again (as gradle project) - all the idea files will be recreated - and everything works fine
I had the same error with IntelliJ CE.
I fixed it by choosing "Inherit project compile output path" in the strong text imodule settings (Paths tab > Compiler output)
In my case, I imported the same project over again. Android Studio overrode the old settings. Then this error went away!
this happened when i update to 2.0. i had to change the dependencies in the build.gradle file under src dir not gradle dir. change from
dependencies {
classpath 'com.android.tools.build:gradle:0.4.0'
}
to
dependencies {
classpath 'com.android.tools.build:gradle:0.5.+'
}
Not sure how much help this will be, but I saw that same error this morning after updating to Android Studio 0.2.0. First, I needed to modifying my build.gradle file to indicate that the correct gradle plugin to use with my project was version 0.5.0 (rather than 0.4). After modifying build.gradle, I saw the "APK path is not specified for module .." error when attempting to build. I solved this by simply quitting and restarting Android Studio.
I had the same issue and found the solution.
Stackoverflow Question
this is the same way to fix the error
Also lower down in there is "SDKs" i also had to make them match.
Name and Build Target.
Hope it helps it did me. apparently the IntelliJ is what Android Studio is.
I've found that the issue is usually if you've changed or moved the folder to a different location.
If you open up the .idea folder in AndroidStudio, have a search for any reference to the old location. If you find some, just replace with the new location. It would seem some of the lines are hardcoded.
There is a manual "how to move project" here
I moved progect, got your problem, followed this manual, got window like you and choose "OK".
And now it works very well.
It helped me to set the right SDK...
I used the one in Program Files, what did not work!
Then i found out to use the following SDK (set in local.properties):
sdk.dir=C:/Program Files (x86)/Android/android-studio/sdk
Hope this helps...
I find this:
http://www.chrisdew.com/blog/2013/07/17/android-studio-nosuchmethoderror-lazystringarraylist/
it is realy help for me.
Thus, in my case, the problem was to have two libraries:
protobuf-2.4.1.jar
and new protobuf-2.5.0.jar
it resulted error:
APK path is not specified for module “Example-Example”
To correct this, rename file protobuf-2.4.1.jar to protobuf-2.4.1.jar.disabled
mv protobuf-2.4.1.jar protobuf-2.4.1.jar.disabled
Finally! Updated solution found here:
Android APK path is not specified for module
Open Project structure
Click on Modules tab
Expand your project and click on Android
On right side click on Compiler tab
Looking for "APK path" field
Enter your project root folder, i.e. /Users/bla/project/my.apk
Click Apply and Ok

Eclipse error : Your project contains error(s),please fix them

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.

"R cannot be resolved to a variable"? [duplicate]

This question already has answers here:
Developing for Android in Eclipse: R.java not regenerating
(64 answers)
Closed 9 years ago.
In Eclipse, I've created a project from a source and now it shows errors - "R cannot be resolved to a variable". From what I found here, I had cleared and rebuilt the project, but still the R file doesn't appear in the /gen folder.
Any ideas?
Dont worry. First you may clean the project, then run the project. If this does not work then follow the following links:
Here is the best way to solve this problem: [Android Development- Where is my R.Java file?][2]
R.java not regenerating
R cannot be resolved - Android error
R cannot be resolved to a variable
R cannot be resolved to a variable -- mailing list entry
Fixed: R cannot be resolved to a variable
If Clean/Rebuild Project doesn't work try to check our package name in AndroidManifest.xml.
The problem "R cannot be resolved" happens when you change your package name in the AndroidManifest.xml file. It uses your Android package name to create a subdirectory under the "gen" directory where it stores the R.java file.
For me the error got fixed by making some changes in Android SDK Manager.
Whatever be the latest API level available, install its "SDK Platform". For me latest API level available was 16, so I installed its's SDK Platform as shown in the image below. It works fine now.
Cheers, Mayank
Did you just update both sdk and adt(from 21 to 22), then you need to install a new item: Android SDK Build-tools
Refer to:
Eclipse giving error, missing R.java file after recent update
For me somehow the Project properties; Android; Project Build Target was not set. I chose a Android version there (e.g. 4.2) and it fixed it.
for me, the best solution to suggest to people that have problems with the "R" file would be to try the next steps (order doesn't matter) :
update ADT & SDK , Eclipse and Java.
remove gen folder , and create it again .
do a clean-project.
right click the project and choose android-tools -> fix-project-properties .
right click the project and choose properties -> java-build-path -> order-and-export. make sure the order is :
Android 4.3 (always the latest version)
Android private libraries
android dependencies
your library project/s if needed
yourAppProject/gen
yourAppProject/src
make sure all files in the res folder's subfolders have names that are ok : only lowercase letters, digits and underscore ("_") .
always make sure the targetSdk is pointed to the latest API (currently 18) , and set it in the project.properties file
For me, there was a missing slash at the end of my SDK. In Eclipse > Preferences > Android > SDK Location
For example, change
/home/matt/android-sdk-linux
to
/home/matt/android-sdk-linux/
your android manifest must start with correct package
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="HERE - Correct package NAME"
android:versionCode="1"
android:versionName="1.0" >`
I got similar problem and solution I found out was in resources any of
the file aka background, sound etc must not contain capital letters or
any special symbol other than _
What you really need to do it just install "build-tools" from sdk manager,
and r.java will be generated automatically.
I had the same error. Error was that, I had placed a file in res/raw folder with invalid filename.
As soon as I corrected the file name to a valid one, error was resolved!
Allowed characters for naming a file:-
1. a-z
2. . _
3. 0-9
4. no capital letters
Capital letters were the issue in my case!
Sometimes you can accidentially add an import to "R", so if at the top of your code you see some weird import about that that you did not add yourself, delete the reference, and everything should go back to normal
My problem was strange and took some time to find. Somehow the package of the src file changed so that the last entry in the package was deleted. So for example initially my class MyActivity.java was in package com.abc.client.test.app but after I added a user permission, the app got removed and the package was renamed to com.abc.client.test. I don't know how it happened. Renaming the package and putting the java file in the correct place fixed the problem.
I found this problem when trying to run the Notepadv3 programme from Googles 'first lesson'..
For me it was an issue with the xml file, due to the API level I was using. I renamed each case of Match_Parent to the older type of Fill_Parent. Oh and if you have already auto-built the project then you need to delete 'import android.R' on NoteEdit.java and Notepadv3.java, clean the project (click 'Project', then 'clean...') before saving.
Solved it for me. Came from this post Android NDK r4 san-angeles problem
Can't believe Google dosen't warn of this problem - I have been setting up another PC to start programming again and even with a bit of prior knowledge this was a pain.. How do you set the API when importing an existing project??? Can't see where there is any dialogue option when you 'File' 'Import' etc ..
Scamparelli
Check the androidmanifest.xml file and layoutfolder xml files. They should be created properly as the starting and ending clause in xml should be placed properly. Update the files, clean and build. And all set!
I had this problem and none of the other guides helped, and then I realized I didn't have the java jdk installed on my system. If you haven't done this either go download the version corresponding to the version of eclipse you installed (x86 or x64)
It is possible you have an error in your *.xml files: layouts and etc.
Try to modify AndroidManifest file.
For example add space and delete this space. After this OPERATION, save project. Resources will be refreshed. It can help.
I solved the problem with resolving R resource on fc19.x86_64 and ADT v22.0.5-757759 by installing additional libraries after Fedora and ADT upgrade.
yum install ld-linux.so.2
yum install libstdc++.so.6
yum install libz.so.1
Those libraries are required by adb (Android Debug Bridge version 1.0.31).
Then restart Eclipse and perform project clean Project->Clean check project you would like to clean.
Hope it helps :)
Project > Clean...
usually regenerates R.java file located in gen/com.mypackage
In my case, R.java wasn't getting generated because of a hierarchical parent error, which in turn was cured by updated one or more Eclipse plugins (Go Eclipse-->Help-->Check for Updates)
I got this error when I added a js file to the res folder.
An error indicator was set on the res folder icon. In all the classes where I used R I got this error.
I moved the js file to the assets folder and everything worked.
Problem was eclipse was not generating R.java.
To resolve this issue please go to project->clean... and select your project and select ok and then clean and build project and import your package name R file(Ex com.demo.R). It works.
This can happen when the android naming convention isn't followed. Check if you have placed a file/photo into one of the android folders and make sure that the file name contains only lower case letters
I know this is an old question but I just solved my own version of it and perhaps this might help someone.
After two days of tearing my hair out with this, I finally got around it by deleting the raw folder, then recreating it and dropping the file(s) back in.
After that, another Project > Clean and it at last compiled.
I got this when I renamed a project. Although the project is renamed, some references are not. Clearing lint, and then rerunning lint helped. (Right click project > Android Tools > Clear Lint Markers, then Run Lint)
My setup was broken after a recent update where the SDK build tools need to be installed separately after the SDK installation. So build tools update + Eclipse restart fixed this for me.
Credit goes to the Android reply here
When other solutions fail, select your project and delete it. MAKE SURE YOU DO NOT REMOVE FILES FROM DISK.
Then use file>import>existing android code into workspace, and select the location of your project.
I been having this and i did trace it back to the layout files.. It happend to me again however i could not find noting in the layout files. I looked in the string.xml and there was it.. one of the string names started with cap and that was causing the problem.
Fix any XML formatting errors in the XML Files in your /res/menu folder.
Might be a compile time error from the XML file being improperly formatted.

R cannot be resolved to a variable

other answers relating to this did not help me out. Hence, I am posting a new question. I am trying to test a sample app of android that comes with their SDK. I get the error "R cannot be resolved to a variable". Looks like my R.java is not being generated. I don't know if I checked in the right place. I checked in the 'gen' folder of where I had downloaded my SDK and could not find the R.java file in the app which I am trying to test.
Could you please provide me with some ideas?
Thank you so much.
It happens when resources are not compiled. If you don't use automatic builds then just build your project. Otherwise it may happen because of some errors in resources.
I had the same problem(there was nothing under gen folder) and tried other solutions such as "cleaning project, checking if not android.R package is imported instead of mypackage.R, moving gen folder over src in java build path => order export tab and checking permissions of SDK executables" but none of them solved it.
Finally when I was checking one of the layout xml files in the res=>layout whether it has a problem or not Eclipse warned me with "The project target (Android 2.3.3) was not properly loaded" text. So I wanted to double check Android SDK Manager from Eclipse and found out that related SDK had an update. I did not see it before because it has a confusing structure with new or installed check boxes in my opinion.
When the 2.3.3 SDK updated all the problems gone...
Just clean the project and build again.
This is the most common problem I've found while developing for android.
Also try this Link for a detailed description about this issue.
Try to remove the read only in the properties of the sample sdk folder. That fix my problem i guest. Then remove the project in the eclipse. Restart eclipse. Then import it again.

Categories

Resources