Unable to add facebook sdk to project - android

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.

Related

eclipse mainActivity.java and others lots of error on start

I am getting trouble with my eclipse.
I'm not yet starting to code. just started making a android app project and errors
are showing already.
problem tab
DZOGRAFI : i've tried what you answered , this is the result. T_T
[edit]
By having a look at the problem tab and the project explorer window I am guessing there is something wrong with the appcompat_v7 library. It cannot be built for some reason.
So, first of all make sure that you actually want to use the v7 support library (Eclipse automatically imports the library when you start a new project using some features). I can see inside your MainActivity.java file that you are extending MainActivity from ActionBarActivity (which automatically imports android.support.v7.app.ActionBarActivity into your project). Extend from Activity instead if you don't actually need the ActionBarActivity class.
If you actually need the support library, keep one copy of it into your workspace (Delete the others) and check if it is updated to the latest version. Inside Eclipse go to Window->Android SDK Manager and scroll down to the extras folder. Check for newer versions of the Android Support Library.
Additionally make sure you have downloaded the SDK platform for the latest APIs and the latest android SDK-Build Tools.
[edit]
Try removing the project (Right click ->Delete) and importing it again. Go to
File->Import then select Android->Existing Android Code into Workspace and click Next. In the window that appears click Browse and go to your Android SDK Folder and look for [Android SDK Folder]\extras\android\support\v7\appcompat. The project should be checked for import and then click "Finish". Clean the appcompat project and then the one you are working on. Please make sure that you are building the appcompat project using the latest API Level (Inside the appcompat Properties->Android check the Android 6.0 Build Target)
Also make sure that in your project's properties you have set the appcompat project as a Library for your project.
After you have done those. Clean and Build the entire workspace and restart Eclipse.
Hope this solves your problems

Facebook SDK v.4 for Android: errors on Eclipse

I am trying to import the latest version (4.0.1) of the Facebook Android SDK into eclipse but I am facing issues in having the project being properly built and imported as a Library.
I followed the steps (for android studio, ported to Eclipse) provided in the official guide and looked through Google for other developers having the same problems as I am having but I am still not able to have it properly working.
Here are the steps I do:
Download the Facebook SDK for android from here: https://developers.facebook.com/resources/facebook-android-sdk-current.zip
Extract the projects
In Eclipse, import existing Android code into workspace
Select the folder "facebook" and choose the only project that is shown (the project is properly imported)
Right click on "facebook" project, properties, android and check "isLibrary"
clean project
At this point I still have issues for annotations and classes not found from "android.support" package.
Project's setting for Java compiler is "1.6", minSDK is 9 and target is 17.
I tried also to add the facebook library to my main project but it is still not working.
I tried to put java 1.7 in the compiler but it is not resolving the missing classes plus it is saying that to compile with java 1.7 I need to have min API set to kitkat (which I don't want because I will not be able to compile for 4.2 and 4.3).
I added manually the androd support jar from the SDK Manager folder of android and this resolved partially the missing classes but some did remain.
I am using Eclipse Version: Luna Service Release 1 (4.4.1) with JDK 1.7.0_51 and the latest ADT Plugin (all android components updated with SDK Manager).
Any help is appreciated.
I did some more tests and find out that by downloading the two libraries:
android-support-v4.jar
bolts-android-1.1.2.jar
from the github project (https://github.com/facebook/facebook-android-sdk) did the trick.
So the steps are the following:
Download, unpack and import as android existing code into workspace the latest v.4 version of the Facebook SDK for Android.
Download the two jars from GitHub
Set the Facebook Project as "isLibrary"
Add the two jars as "external jars" in the classpath
Set the java compiler to 1.7
clean and rebuild the project
Now errors are gone.
Download the facebook sdk from here.
Extract the zip file.
Import only facebook sdk project into eclipse as "Existing Android code into
workspace".
Now, this project will show many errors, do not open any java file or
resource file and do not try to do any imports or clean project until I
mention it to do so.
First add the v7 library to this project by doing right click on facebook
sdk project >> properties>>android>>Add Library.(If you don't have latest
v7 support library download it from sdk manager), also set the project build
target to the maximum android version available and select "is library".
Now, right click on facebook project and select >Build path>Configure build
path>Libraries tab>Add external jars> browse to place where you extracted
facebook sdk in step 2 and find two jar files in libs folder(android-
support-v4.jar and bolts-android-1.1.2.jar) and add both files. Switch to
"order and export" tab and select both the jar files and click on ok.
Now right click on facebook sdk >>properties>>Java Complier>>set the
"compiler compliance level to 1.7 or more and use default compliance settings.
Now select the project and click on Project > Clean.
This should remove all errors now. This is how it worked for me.
Android Facebook SDK import occurs with errors - Eclipse
Check this out. May be this will help you.
I faced same problem while working in Android Studio.
But you are facing in Eclipse.

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.

Could not find ****.apk + android

Whenever i am trying to run my project, i am getting this error in the console.
"Could not find **.apk"
Operating system: windows XP
IDE: Eclipse SDK
Version: 3.4.2
Build id: M20090211-1700
Android: 1.6
ADT: ADT 10.0.0
FYI: it is only happening with a single project, other projects are running fine..
I think this can happen when you rename the library project out from underneath the dependent project. Eclipse is reasonably good about about updating dependencies in most cases but this one seems fragile.
First try removing and then re-adding your library in Project > Properties > Android > Library.
If that doesn't work try cleaning your projects, exiting Eclipse, and opening the ".classpath" file in your project's root directory. If you see a line that references your library project under a previous name, just delete it, save the file, and relaunch Eclipse. Build the library project and then your dependent one. You may need to re-add the library like I mentioned above. This is what worked for me at least.
Edit note: I also found some stale references in my .project files. They didn't seem to be causing any problems but I removed them too. If you do that, be sure to search for the old name in that file as there was a whole "link" section near the bottom that also referenced it.
Make sure after updating your android sdk sdk build tools are updated properly.
You can check it by Open sdk manager -"Android Sdk Build Tools" status must be installed.
if the status is not installed then install Android Sdk Build Tools for the same.
restart your eclipse and try again
check this it might be helpful to you
Make sure your project imported the Android 1.6 library correctly. That is, under your project, you should see 'Android 1.6', which expands and displays 'android.jar'.
If it says Referenced Libraries > android.jar, you will need to fix this by manually altering the .classpath for the project.
Open .classpath for the project and type the following:
The important line is the 3rd classpathentry, which is the actual link to the Android SDK libraries.
source
clean your project and check . eclipse is not building apk file.
check this thread. It might help you.
http://groups.google.com/group/android-developers/browse_thread/thread/2c3e45540b915945/f06e10bcda3ad68b?lnk=raot&pli=1
Run eclipse as administrator and then import your project
Update Android SDK, is what did it for me.
I was building a game with the LibGdx Framework and got the same error. I tried several solutions from various posts at stackoverflow and others.
Found help in a post at the LibGdx Forum:
http://www.badlogicgames.com/wordpress/?p=3010 Posted by Mario, on May 18, 2013
Just updated to ADT 22, so should you. However, the process wasn’t all that smooth. What you need to do:
Update the ADT plugin in Eclipse (Help -> Check for Updates)
Open the Android SDK Manager, either from within Eclipse, or from
your Android SDK folder
Fetch all the updates
Fetch all the updates again
Fetch the updates one more time…
The end result should be an updated ADT plugin, as well as up to date SDK packages. Make sure you have all three of the ones in the following image, with the exact version numbers.
I needed to update them only once and from there on it worked.
Even if this post is outdated I figured I'll share this, because I lost a day finding nothing.
I experienced that problem, too, when I created an android project that was using an android library. Obviously I didn't know how to incorporate a library into an application the right way. I wrongly used project dependencies (Java Build Path/projects) or adding a library (Java Build Path/Libraries). While all I had to do was go to the Android tab and import my android library by means of the add button from the Library section.
I am using PhoneGap and I checked several solutions about configuration (properties, build path). However, my problem was that I tried to run everything with the default setup for Eclipse. Then, I solved it going to the SDK manager to install: Android SDK Build-tools, and it worked.
Mine was caused by this problem (incompatibility between ADT and SDK), and was fixed thus:
Eclipse > Help
Install New Software
Add 'https://dl-ssl.google.com/android/eclipse/' to 'Work With'
section and press enter
After developer tools appears on the list, check it and click Next
Restart eclipse once download is finished
Make sure put correct SDK Location (I have 2 instances of SDK and update wrong once).

Categories

Resources