How to import Facebook SDK into my android eclipse project - java

I'm a bit confused between 2 screen in eclipse:
I'm not sure how to import FB sd into my Android project properly.
What does "android" mean vs "Java build path" ?
As current configuration I get this error:

As the error says - there are 2 versions of a jar - android-support-v4.jar. Either make FB use your version of android-support-v4 or use FB's version of android-support-v4.jar in your project. The jar will be in project-name/libs folder.

First import it as a project into your eclipse and then give its reference to your project as you have shown in your first screen. If you have only jars file then add those jar to your libs folder and then follow steps of add to build path.

Delete the android-support-v4.jar from your project as there will be a jar mismatch.As you have added Facebook SDK as a library project, it is again not required to add that support jar file.Facebook SDK already contain that library.If android-support-v4.jar is a older one then you can update it.

You have 2 android support library with different keys.
Right click on your FacebokSDK and project ---> Android tools ---> Add support Library

I don't quite understand the problem, the picture is too small, also, Facebook has a great tutorial about how to do just that, also, make sure you're using Facebook's android support jar.

Related

How can I convert an android project originally coded in IDEA or Eclipse to Android Studio and add Gradle?

I want to take on a sound recorder project from github: https://github.com/avipars/Android-SoundRecorder
But, it came from IDEA or Eclipse. I tried importing it through github, which didn't work. Then, I downloaded the ZIP and put it in android studio without much luck.
Android Studio won't recognize the file system and I want to get gradle working too.
So, how can I get it in Android Studio with Gradle working?
To clarify, I can get the project in Android Studio. It just won't compile.
Download the project in .zip form, then extract to your preferred workspace.
It looks like the project relies on two external libraries:
android.library.reference.1=../../android-libs/ListViewAnimations/library
android.library.reference.2=../../android-libs/UndoBar/library
Obviously, Android Studio won't know about these libraries while importing this project alone. Remove the above lines from project.properties and add them later into your Android Studio project as dependencies or modules (if you can find them). Otherwise, you can work out the dependencies in the code after importing.
Once you have removed those lines, from Android Studio, you can select "Import project"
Follow the import wizard and you should be brought into Android Studio with a summary of the import result. From there you can muck with .git stuff and add back in any third party libraries that this source code may rely on.
Hope that helps!

Building project in eclipse?

I've looked for an answer, no luck. Looked a lot.
I've downloaded an android example project from a friend, it's all in the correct layout, and the source files are there. Only I wish to open the whole project in eclipse, so that I can run it using the emulator I have installed. However, I cannot seem to be able to do this. I have all versions of android installed, and I have been advised that the files/project are for 2.3 so should be good. Have tried:
File --> New Android Project --> Using the existing file and build path
It suggested to do file --> Import instead, so went there and imported an android project from existing workspace.
It gave this error:
"Project has no default.properties file! Edit the project properties to set one".
Any help is much appreciated!
New version of ADT plugin uses project.properties while older version use default.properties.
Please upgrade ADT plugin. It will work
I had this problem when trying to open one of my projects on a different computer, you need to update the ADT. In Eclipse go to Help > Install New Software. Type in https://dl-ssl.google.com/android/eclipse/ and install the latest versions of everything. Also make sure everything to do with the SDK is up to date!
Try creating a new project from existing source.

Error when building apk - "Multiple dex files define Lcom/google/ads/Ad"

I've been tearing my hair out over this one, for the past 3 hours I've been trying to fix it but have been unable to. I've created an android app and I'm ready to put it on the android market but I get this error when trying to export to an apk.
Unable to execute dex: Multiple dex files define Lcom/google/ads/Ad;
I've read a bunch on the problem and tried quite a few solutions but nothing has seemed to help. I've cleaned and rebuilt, I've delete the bin folder, I've made sure that the bin folder is excluded build path. Nothing's worked. If anyone could help me I would really appreciate it.
Untick the admob jar file in the "order and export" part of the "configure build path".
On another post with a problem similar to yours the only thing mentioned that you have not already considered was updating Eclipse. I don't know how or what order that you have done these "fixes" but another poster mentioned that all at once he deleted the bin directory for his project, cleaned and rebuilt the project and restarted Eclipse. After that the error disappeared.
Good Luck- Lijap
For me the error was due to 2 different versions of AdMob SDK being included accidentally.
Removing one of them fixed it.
As other have noted, this problem should be due to multiple versions of Goodle's ad SDK classes being included in the app build. What I haven't seen yet is a note that the most recent Google Play Service lib includes classes that (at least) share the same names as some in the admob sdk-- for example, I came upon this error because I was trying to build with both admob sdk v.4.0.4 and the google-play-services_lib project as a referenced project; the latter contains google-play-services.jar which contains the package com.google.ads and many of the same classes as the admob sdk. Thus it appears that the google play services lib and the admob sdk cannot both be used in a given app. My solution was to remove the admob sdk entirely from the build.
I had the same or a similar problem. My problem was that my application imported a library which used a different version of AdMob SDK.
Details of my problem:
Library used AdMob SDK 6.3.0
Application used AdMob SDK 6.1.0
Fixed it by including the same version.
For me, I just have to take out the libs folder which contains android-support-v4.jar from build path and it worked.

How to add a non-Android Java package to the Android development environment?

So far I have been using in tutorials, examples and sample code only packages that came pre-installed with the Android SDK.
Now, I want to add a non-Android package (e.g. Jsoup).
What's the proper way of doing that (so that it becomes available to all projects)?
You can add it to a project by right clicking on your project in Eclipse and choose Build Path and Add External Archive. Select the jar to add it to your build path and it will be included in any apk you create.
One caveat is that if the jar may use part of the JDK that doesn't exist in Android.

import cannot be resolved: import com.google.android.maps.*;

I was successfully using google maps in my application but then needed to change the Android SDK version from 1.5 to 2.0. Now the import for Google maps can't be resolved.
Make sure you have
<uses-library
android:name="com.google.android.maps" />
in your application manifest, and that you've downloaded not just the 2.0 SDK but the 2.0-with-google-APIs SDK. Then set your project's properties in Eclipse to check off the Google APIs version of the SDK you want. Then try to clean your build (Project-> Clean in eclipse; "ant clean" from the command line).
adding google-play-services.jar to my project's path solved my problem.
right click project->properties->java build path-> libraries tab -> add external jar
browse to android-sdk folder->extras\google\google-play-services\libproject\google-play-services_lib\libs\
If you don't have google-play-services folder then you need to close eclipse and open up the SDK manager separately and download google-play.
If you already downloaded google-play and still don't see your google-play-services folder, then you need to search for it....chances are that you have multiple android sdks installed....
1.Install all google API's using sdk manager.
2.In your manifest,under application element add
<uses-library android:name="com.google.android.maps" />
3.You have to include jar file for maps also..
Right click on your project and go to build path and then add external archives.
locate your sdk. android-sdk-windows\add-ons\addon_google_apis_google_inc_8\libs\maps
Doing right-click Properties->Android and selecting a Target Name Google APIs instead of Android x.x fixed the problem for me.
Add
compile 'com.google.maps.android:android-maps-utils:0.5+'
in dependency section of your build.gradle
You may also need to add google-play-services_lib to the project's list of libraries. Doing so resolved this issue for me.
Right-click project->properties->Android
Click the 'Add...' button found to the right of the Library Reference/Project table.
If you have downloaded the Google Play Services Library with the SDK Manager, you should see the library as a choice in the Project Selection box that pops up when you press the Add button.
If you have not downloaded Google Play Services follow the instructions here:
http://developer.android.com/google/play-services/setup.html

Categories

Resources