Eclipse: Tons of Errors in Android Application - java

I imported my current Android Project to Eclipse on my (Mac OS) device via SVN.
The code shows up alright, but Ecipse shows tons of errors (see screenshot) which do not appear on the device I first used - I am not very experienced with Eclipse but I guess some libraries were not imported?
I installed the current JRE(1.7), Eclipse, the Android plugin which also installed the current Android SDK (4.1).
Any clues?!

Place the sdk path in Window->Preference->android.
And then Click apply.
If you already do it. Then right click the project and goto Properties->android->select android version

Right click on Project -> Android Tools -> Fix Project Properties
Go to menu -> Project -> Clean
For that go to each java file import all required packages or try CTRL + SHIFT + O
then resolve all errors in RES folder.
Then it will generate R.java for you
then import yourpakagename.R; where ever required.
remove import android.R;
hope this will help you

Related

IntelliJ IDEA - "Imported project refers to unknown jdks JavaSE-1.8" while import Eclipse projects

I tried to import Eclipse project to IntelliJ IDEA, but I got this error:
The eclipse project description contains a reference to a "manually" defined JDK (named JavaSE-1.8).
Just go forward and define an SDK for your project within IntelliJ yourself. See here for the necessary steps:
To define a JDK and a mobile SDK in IntelliJ IDEA
Open the Project Structure dialog (e.g. Ctrl+Shift+Alt+S).
In the leftmost pane, under Platform Settings, click SDKs.
Above the pane to the right, click  and select JDK.
In the dialog that opens, select the installation directory of the JDK to be used and click OK.
... (obviously you don't need the Java ME mobile specific things listed in the original link)
Here they had a similar problem, but with android sdk
You must edit Project SDK in Project Structures > Dependencies to existing Java JDK

R.java not being generated

I know this is very widespread problem , but I didn't find solution to my particular case after searching the web for almost one day. I am using Ubuntu 14.04. I have just installed eclipse , ADT and SDK. So I have tried followings but still I get the same error.
Install all possible SDK build tools
Delete gen folder and clean/build the project
Fix all the errors in layout files
Make sure that the path to sdk is correct
Check if appcompat_v7 is added as a library or not
So what can you advise me to do besides these?
I had a similar problem and I fixed by adding
import your.package.name.R
to my activity.
Eclipse by default adds import android.R
You should try with NEXT
rigth click in your projects -> Android Tools -> Fixed project libraries or support library project -> clean or restart. If the above does not work, import the projects said JCODER
What you can also try is to change the android api
Hope that helps
First, You have to make sure all of your XML files are absolutely fine and have no errors.
If no errors found, try changing your Build Target and apply, then change it back. In eclipse do the following:
-> Project -> Properties -> Android -> Project Build Target -> Change the target and click Apply

In-App Billing Android and bug

Good evening, everybody.
I'm trying to debug the In-App Billing project. The sourse which I use, is
https://github.com/blundell/SimpleInAppPurchaseV3
I'm facing the problem from time to time:
Suddenly the project in file Log.java gives two errors:
1. The type java.lang.Object cannot be resolved. It is indirectly referenced from required .class files
The error shows near the first symbol of the file.
R.java cannit be resolved! And gen-folder doesn't recreate! No errors in xml-files.
IabHelper.java shows the error: The import com.android.vending.billing.IMarketBillingService cannot be resolved
So if delete com.android.vending.billing/IInAppBillingService.aidl file and recreate it (by copy-paste) nothing happens.
What am I doing wrong?
I think your problem is just the latest update of the SDK.
Test the following operations on two projects :
In the project properties (eclipse) -> java build path -> order and export make sure that all your jars in the libs folder are checked.
And "Android Tools -> Fix Project Properties"
And "Project -> Clean"
If your problem persists try this:
Remove your project
Close eclipse
Import your project again
I hope you have helped!
Try this one.
1) project properties-> java build path-> order and export
make sure you have checked true all files that I have listed below:
Android Private Libraries,
Android Dependencies,
your all jar and libraries you have added.
2) check your SDK manager you have updated all required versions for
--> Tools: SDK Tools, SDK platform tools, SDK build tools.
--> Android 4.2 or what ever you are using, Google Map and SDK Platform should be updated latest.
--> Extras: Google Play Services,Google play billing libraries
also make sure you have not imported wrong variables or any class.
Hope it will help you.
Simple solution.
Rename your package name from com.android.vending.billing to com.android.vending.billing2.
Refresh project.
And after that again rename to com.android.vending.billing. And it will work.
In Android Studio click "Make Project" after adding "IInAppBillingService.aidl" file to your project. Then Android Studio can import "IInAppBillingService" class after press Alt+Enter on IInAppBillingService class.

Running Android Support v4 Library Demo Programs

I'm interested in running the Android Support library demo projects for the v4 library.
Using the Android SDK manager I've installed the Eclipse plugins, and APIs from 2.2 to 4.0.1. There are several issues involved, and the sample project as provided is far from running on my configuration, as downloaded.
To reproduce this error:
Install SDK and Eclipse Juno
Import the sample v4 compatibility project using File --> New --> New Project and choose "from existing code", targeting, for example, the Support4Demos folder in <Android-sdk-path>/extras/android/support
Open the file AccessibilityManagerSupportActivity.java. The following errors appear.
Open res/values-v11/styles.xml. The following errors occur.
How do I get rid of these errors? I'd also like to understand why they are appearing so I can fix them in the future.
Thanks!
Clean solution is to:
Right-click your project.
Choose "Android Tools"
Choose "Add support library".
Install the appropriate support library (the newest)
I can't really answer you on the why this problem happens, but I'm guessing the Android team doesn't supply the Android support library, because it's changing all the time, so not to get stuck on some older version, they want us to supply it on our own.
If errors still persists or new errors come up, right-click the project again and choose "Android tool" -> "Fix project properties"
Update: In conjuction to my answer, the way to remove the rest of the errors is to import the project another way than you did.
Select File -> New -> Other
Click Next
Write Android Sample
Select Android sample Project and click Next
Now add the Android support librarys as described above.
You will get errors still however. To fix these, do the following:
Right-click your project and select "Properties"
Select Android
Select an SDK version equal to 3.0 or above
Select Ok and clean the project from the project menu.
All done ;-)
Now you won't be able to run the sample project on devices lower than Android 3.0.
The reason is because of some dependencies on some themes and settings, that wasn't added before Android 3.0 apparently.
It doesn't make sense why Google did this, but they did. You could try to remove the SDK +11 (Android 3.0) specific dependencies, but it will take some time - there are more errors than you actually see - especially in the XML files.
You have to add the v4 support library.
In order to do that , please follow these steps :
Select your project.
Click on Project from the menu.
Select Properties.
Click on Java Build Path.
Select the Libraries tab.
Click on Add External JARs.
Select the main directory of the Android SDK that you installed, then go to extras -> android -> support -> v4 , and then select android-support-v4.jar and click on Open.
Click OK.
This should remove the errors.
Please check your libs folder has android-support-v4.jar is present or not. if not add this jar file in libs folder.Just copy the android-support-v4.jar from any project and paste it to the libs folder of your project
I spent a whole night on this but can not solve this problem.
I finally solved the by accident: change some file in the demo and save, then change it back, this cleared all the errors. I think when you change some file and save, eclipse build the project and generate the R.java.

"could not find com_facebook_android.apk error" when running Android project

I've installed the Facebook API for Android in Eclipse, and imported the project into my Android project. My program builds perfectly fine, but when I try to run it I get
Could not find com_facebook_android.apk!
in the build window, and when the program actually tries to import any of the Facebook API classes it blows up with a java.lang.NoClassDefFoundError: com.facebook.android.Facebook
Probably you added the reference to the Java project in the "Java Build Path" but it's the wrong place.
From the Android guide:
To add a reference to a library project, follow these steps:
In the Package Explorer, right-click the dependent project and select Properties.
In the Properties window, select the "Android" properties group at left and locate the Library properties at right.
Click Add to open the Project Selection dialog.
From the list of available library projects, select a project and click OK.
When the dialog closes, click Apply in the Properties window.
Click OK to close the Properties window
This resolved my problem.
Check out referencing libraries instructions here:
http://developer.android.com/guide/developing/projects/projects-eclipse.html
Make sure you have the latest versions of ADT.
Try to clean your project in eclipse.
Hope this helps
In my case helped, not to have in the referenced projects checked Is Library
(Project Properties > Android)
I am also having issues with this error and have noted that if I run eclipse as root then the error disappears. This makes me think it is a permissions issue
So to help:
On the com Facebook android project right click > android tool > build and export
Then simply build the project into the bin folder of the Facebook project.
Problem solved
I had a similar problem. This was my resolution. I had to add android.jar as a reference.
Android samples error
If nothing works, try deleting the Facebook application for Android (if you have one installed on your phone). This worked for me.

Categories