Eclipse not Recognizing any imports - android

I seem to have botched up something in Eclipse. It isn't recognizing any of the libraries that I am trying to import.
Here are some of the things not being recognized:
import java.util.ArrayList;
import android.content.Intent;
import com.google.android.maps.MapView;
This is a open source project that I downloaded and then imported into Eclipse. I think I also downloaded the google apis the wrong way because things like MapView don't work in my other projects as well. Can someone please help me out?
Best,
Aneem
EDIT:
Fixed, most of the issues. Did it by hovering mouse to import line and clicking "Fix project setup..."
Now the only thing I have to do is get the google map related API to work.

To check if you have properly installed ADT
goto -> Window -> Preferences.
If you see Android (in the preferences), it means you have ADT installed.
To point to the valid SDK directory, click on Android. Specify the location in the SDK location.
Even if you have correctly installed ADT and SDK, there is a chance that eclipse may not recognize as the Android project if you import it(depends on the project & files).
Best thing is, to create a new Android project and copy the files from the imported project to the newly created Android project. This will definitely work.

Two things to consider:
Open project properties -> Android section, see if Android SDK is selected or not. if no SDK is selected just check it.
In project properties -> Java Compiler section, change "Compiler compliance level" to "1.6". This is because you have installed JDK 1.7 that has some problems with some packages!

Most likely your ADT plugin is not pointing to the Android SDK. Follow the instructions for installing and configuring the plugin:
http://developer.android.com/sdk/eclipse-adt.html

I right clicked on the project and selected properties and added Google APIs 2.3.3 as the target and did a project->clean and was able to launch the application. Many thanks.

Related

Facebook SDK 4.8.2 import in ECLIPSE

How to import facebook sdk 4.8.2 in eclipse. I am unable to import as facebook folder contains aar file when we directly download developer site. And from git , unable to get src files of facebook
Here you have an answer from Android Facebook SDK 4 in Eclipse
I also have faced this problem, so I will write a short guide, how to
install it in Eclipse.
Step 1. Import to Eclipse First of all, download the latest
version of SDK (on current moment it is 4.0). Unzip it to a
folder.
Open Eclipse, click the right mouse button in "PackageExplorer" and
choose "Import". After that, go to "Android" -> "Existing Android
Code Into Workspace".
Now click "Browse" and choose unzipped SDK folder, and deselect all
other found projects, except from the "facebook" (it is an SDK).
Other included projects are just samples, and you don't need them now.
You may select "copy project to workspace" checkbox, if you need this.
Step 2. Fixing errors After importing, we will see, that the
whole facebook SDK package are in errors:
But if we look closer, and open one of marked as error classes, we
will find, that SDK tried to importsupport.v4 library:
It required for properly compilation. You can find instructions how to
download it using Android SDK Managerhere.
After it downloading, you can find it in your Android sdk folder:
<sdk>/extras/android/support/v4. Then add it to the facebook SDK
project: right mouse click on SDK project -> "Properties" -> "Java
Build Path" -> "Libraries" -> "Add External JARs", and choose
android-support-v4.jar from it's folder.
After that a lot of errors will be gone:
But, there are other errors. So we are going to another class, and
found it error code piece. Move mouse pointer on it, and Eclipse will
show you the hint, of what kind of error you are facing. It says that
your compliance Java must be version 1.7. Allow Eclipse do it by
clicking "Change project ...", or do it manually by going to
"Properties" -> "Java Complier" -> "Compiler compilance level"
-> "1.7".
OR
Moving ahead. Now we are facing only one kind of error, that says that
the FB SDK can't find required Bolts Android library.
We are going to google, found it compiled jar in a repository.
Choose the latest version (for current moment it's 1.2.0, but SDK
gradle file is using 1.1.4, so you may choose that), and download the
jar. Now add it to the facebook SDK as external lib, as we do it
before.
Voila! Ther are no errors anymore!
Also don't forget to set in the facebook SDK project "Properties" ->
"Android", that it is a Library.
Just for ensurance, close/re-open the SDK project and clean it
("Eclipse menu" -> "Project" -> "Clean"), so all files can build
properly.
Step 3. Add it to the Android project Now you can try to add
it to your Android app. Go to your Android app project "Properties"
-> "Android" -> "Library" -> "Add", and choose facebook SDK.
Follow official tutorial, and set up your Android application
project (don't forget to add all required elements to Manifest.xml).
Than you can use this tutorial to add LoginButton to your
Activity. Try to build it. It should run without problem.
This also might be helpful, if you find any issue: Facebook SDK v.4 for Android: errors on Eclipse
Check also: Android Facebook SDK configuration on Eclipse
Hope it help
EDIT: As you would see in the comments below, this answer is not already corrected. The best way to deal with this problem is export project from Eclipse to Android Studio, which doesn't have this issue and becoming the first Android Developer tool, where Eclipse seems to be as was said on Android Dev Summit 2015 truly deprecated.
Thank you so much! I'm still procrastinating migrating from Eclipse to Android Studio. And I found that the last version that works with Eclipse would be Facebook Android SDK 4.5.1. Download link here: https://origincache.facebook.com/developers/resources/?id=facebook-android-sdk-4.5.1.zip
Following this instructions make it work!

How do I import/build this project?

I am not a dev, but have some dev experience. I have never used Android Studio before but I wanted to look at an example app. I picked one I am very interested in, but it gives me nothing but grief just trying to import it.
https://github.com/AltBeacon/android-beacon-library-reference
Notes:
I am using the latest version of Android Studio. (1.0.2). I have added in all the SDK files needed I think.
I have downloaded and un-zipped Gradle 2.2.1.
I am running Ubuntu 14.04.
I have dealt with Eclipse for Android previously and was able to
hack someone else's code to suit my needs and actually deploy an unsigned apk.
The readme/install directions at the github don't really help a noob
like me.
Install:
I have extracted the project from the Download Zip link.
For the actual import into Android Studio I choose "Open an Existing
Android Studio Project" - because it looks like one.
I then choose the root directory created by unzipping the zip file,
in this case it is named "android-beacon-library-reference-master".
But it seems to select the project's Gradle subfolder (/gradle) for the project! Which I'm quite certain is invalid. I cannot seem to get it to use the root
folder.
What am I missing? Or is this not the correct way to "import" this particular app? Is this app not compatible with AS 1.0.2?.
TIA!
In Android Studio, close any projects currently open. You should see the Welcome to Android Studio window.
1.Click Import Non-Android Studio project.
2.Locate the project you exported from Github, expand it, select the build.gradle file and click OK.
3.In the following dialog, leave Use gradle wrapper selected and click OK. (You do not need to specify the Gradle home.)
Android Studio properly updates the project structure and creates the appropriate Gradle build file.
Can you try "Import Project" instead "Open Project". Thanks.

Unable to add facebook sdk to project

I imported the Facebook SDK as library project into eclipse. I did it by checking Copy projects into Workspace and by leaving it unchecked as well (for some reason the description says that I must uncheck it).
I tried importing Existing Projects into Workspace and Existing Android Code Into Workspace as well.
The library checkbox is checked in the properties.
A Facebook sdk has never been imported into this workspace yet.
I created a new project that runs smoothly without Facebook. In the properties, Android tab, I added the library project. It showed a green tick, but when I open that tab again, it shows a red x.
The target of the project is API level 19, the target of the facebook library is API level 8. I also tried it with API level 10
I am using Java compiler 1.6 in both the project and the library.
What I don't understand is that the sample projects that came with the SDK seem to have successfully imported the SDK (green tick), however they all point to the same problem "The import android.support cannot be resolved" on import android.support.v4.app.FragmentActivity; I had to hover over the line and click Fix Project setup to make them work. Then I went to Properties -> Java Build Path -> Order and Export -> clicked v4 support library checkbox. So at least they work. Why do they successfully load the Facebook SDK and why is my app unable to do it?
The Facebook SDK has no libs folder so I guess an interference between different v4 support libraries is out of the question.
I have tried this on two different computers as well.
I decided to install Android from step to step instead of the ADT Bundle. I downloaded Eclipse Juno for Java Developers, installed the newest Java version (1.8) and installed the Android packages. Created a new project and imported the facebook sdk 3.5 (tried 3.0.2 and 3.8 as well). I still get the red X.
I appreciate any help.
I ran into this issue half a year later and my earlier answer was of no help. The trick is that you need to have the library on the same drive as your project, which is usually the C: drive. That's all. Thank you Facebook for not notifying us about this..
Solved. Here is what I did to solve this strange error.
Copy the contents of project.properties file.
Delete project.properties file.
Create a new file and name it project.properties
Paste the contents of the previous file into this new file.

Eclipse changes project's Android SDK when importing from existing source

Eclipse, or Android is changing my project.properties file when I import a project from existing source.
When I "export" an existing project from SVN, the project.properties file is referencing the correct SDK for that project:
# Project target.
target=Google Inc.:Google APIs:7
I can see this by opening the file in a text editor. I have not yet imported this as a project into Eclipse.
Then I choose to import it into Eclipse using File...New...Android Project from Existing Source.
Eclipse imports the project, and immediately shows the correct SDK in the project explorer window. Perfect so far.
After a second or so, I can see the SDK change to Android 2.1. Eclipse automatically made the change!
My project.properties file has been updated:
# Project target.
target=android-8
To summarise:
export project from SVN - project.properties points to Google API 7.
import this into Eclipse - project.properties automatically changes to Android API 8.
I have checked this on a different developer's machine - same behaviour. (i.e. Android SDK Tools 21.0.0 and 21.0.1)
Any ideas?
This is the Bug of Eclipse, currently nobody can do anything for it until eclipse developer resolve this bug.
See Bug Reported Here - Issue 40153: ADT import of project renames project, changes compatibility level
(Also this bug is very well written and mentioned there as compaired to asked here...LOL..BTW sorry for your unsolvable problem right now)
Thanks,
Happy to help.

Android showing "Unable to get system library for project"

I was working on an android tutorial and it wanted me to import the library from another project. All well and good. The import worked and the project works correctly. But I noticed that doing that messed up several of my other projects (the ones that use Android 2.2) by apparently messing with the build path. Now instead of seeing "Google APIs [Android 2.2]" under the gen folder I see "Unable to get system library for project". When I right-click the project and go to Properties I see that the correct Project Build Target is checked(Google APIs [Android 2.2]), but "Unable to get system library for project" is still shown above the assets folder and below gen and Android Dependencies. Cleaning all projects doesn't help. How can I fix this problem, and is there a way to fix this issue globally or do I have to do it one by one?
In the project root folder you should have file named project.properties
---- file content -----
target=android-16 ## <--- make sure that it is there and that you have proper sdk installed
For me, the problem was that in the Project settings - Android tab, I had no Android version selected.
For me I had SDK version 8 selcted, but if I selected the next highest version, applied, then selected version 8 again and apply, fixed the problem.
For me, what worked was to restart Eclipse. Hope this helps.

Categories

Resources