Android facebook SDK as JAR - android

Are there any cons of build the facebook SDK library project into a JAR file(as ADT 16 does with library projects) and adding it to your project? I am not changing anything in the facebook SDK so don't need to have it added as a library project. So far it has been working fine for me and I am wondering whether this is a common practice used by developers using the facebook SDK? It speeds up the build process quite a bit because Eclipse doesn't have to resolve all of the resources in the library projects.

Yes! I just figured it out myself.
You need two jar files:
facebooksdk.jar
android-support-v4.jar
Option 1
The first can be found in the bin folder, the latter in the Android Dependencies folder. (Of the FacebookSDK project)
After adding them both as libraries to my project (Project --> properties --> Java Build Path --> Libraries) it actually worked.
Option 2
Another way is to copy paste the facebooksdk.jar and get the android-support-v4.jar via Right-click on project --> Android Tools --> Add Support Library.
Good luck =)

Kasgoku,
The code is provided as a project for easy viewing of the classes. Adding it as an included jar or just moving the source into your project also works. When I created an FB connected android app, I moved the files I needed into a package in my app.

It looks like maven has them cached.
http://search.maven.org/remotecontent?filepath=com/facebook/android/facebook-android-sdk/4.4.0/facebook-android-sdk-4.4.0-sources.jar

You can create a jar file :
Download Facebook Android SDK from github.
Extract it. (at any location).
In Eclipse create new project using create project from existing source option
Enter the project name as "com_facebook_android".
Set Location to "facebook" folder in extracted location.
Click Finish.
Select the "com_facebook_android" project in project explorer and right click
select export option.
In the export wizard select JAR file in Java folder.
Click next then browse the location for jar file and give the name as yor wish like "facebook-android.jar"
Click finish........ JAR file will be created in that location

Well guys you dont need to manually make a .jar file out of facebook-android-sdk. You can use easyfacebook.jar. It currently supports:
Oauth 2.0 authentication support
Use the access token
Pictures upload support
Supports all the features of Graph API
It can run any query FQL
Contains BEAN of all facebook objects
It's free. LGPL GNU license
Progress dialog
Logout function
Server/Request Error Management
Key hash/Geo Tagging
Login without facebook app

Related

Create STANDALONE Android Studio (1.5) library project

I need to create an Android Library and deliver the final .jar file to the clients.
I am new to Android development (three days). I've been developing iOS for the last 4 years. I went through Google's official documentation and tutorials to get a feel for the platform (I don't want it to be obvious that an iOS guy was writing the library).
I don't have any problems with Java, but I do with Android. I decided to go with Android Studio since it is the official IDE. I am using version 1.5.
PROBLEM:
So as I said, I need to create an Android Library and deliver the .jar file to the clients. I would like this Android Studio project to be a standalone library project with its own unit tests. I don't want to create an unnecessary App project, and then add an Android Library module to it. I want to create a separate App project which will include this .jar file, so I can test it in the way it will reach our clients.
I've seen a lot of options online for how to accomplish this, but all of them seem a bit "hacky" (e.g. rename this folder, change that app-project-setting and make it a library project). Is there no way to create a Library project from a new project wizard in Android Studio?
What are your suggestions on how I should proceed with this? Is there some elegant solution to this without these tricks to re-configure the App project?
EDIT
Here is what the new project wizard looks like:
I select "Add no activity" here
This may not feel comfortable for a person from other platform/IDE/world, but this is The Way. Personally i'm getting annoyed with Xcode every time i use it in the exact same way you're annoyed with AndroidStudio now. But lets get down to business:
Create an empty project and select "Create no activity".
When everything is set, go to "File\New\New Module" and select "Android Library"
Give a name for created library and click "Finish".
(Optional) go to "Run\Edit Configurations" and set everything like below:
Now open the librarie's 'build.gradle' file. Make sure to open the file from exact same folder which is named with your library name, because there are a couple of 'build.gradle' files all over the place. Remove support-library entry from the file:
Write some code and when you're ready to deploy the library set everything like this:
Go to "Build" menu at the top and select "Build APK".
And about unit tests:
**Edit 1: **
If you really want to remove the 'app' folder, than follow instructions on a picture below:
You can create Library Project instead of Normal Project,then your output product will be a jar or aar as you configured.If your library has resources then build it as aar,or it will be jar.
When you created a project as yo are doing,click File->new Module,then will like this:
If your library project have resources or will use API of Android,then choose Android Library,else choose Java Library,Android Library will build aar as product whild Java Library build jar product.

Facebook Android SDK and IntelliJ IDEA

Has anyone figured out how to use the Facebook SDK with an IntelliJ project successfully? I have tried to create a module, mess with project structure etc, but it does not seem to work on compilation.
Does anyone have an answer to this? All other sources seem to be outdated.
This is what actually worked for me.
However, instead of selecting "Library Module" just hit "Empty Module." This was a pain to figure out, but Intellij will change a bunch of files including the AndroidManifest.xml & Strings.xml if you hit "Library Module." Also, be sure to add the dependencies to the libs folder in the recursed directory to your Facebook module so you include android-support-v4 & bolts support. Should work then.
I am currently using the Facebook Android SDK with IntelliJ.
What you need to do is add the SDK as a library for your project.
First, build Facebook Android SDK using Gradle
Open project settings, under Libraries, select Java
Navigate to the Facebook Android SDK directory, select the facebook sub-directory and click OK
The next screen will show a check-list of items, mostly directories - each of them will be classified as source, class etc.
Uncheck everything, and then check the following items:
facebook-android-sdk/facebook/build/classes/release
facebook-android-sdk/facebook/gen
facebook-android-sdk/facebook/src
Then, click Next/OK/Finish
This might be sufficient, but in my case I had to go the Module settings, Dependencies tab and move the facebook item above the project sources item to get the module to compile.

how to import zxing library project for android app in eclipse

check out zxing from Svn reository
then in zxing folder i found several folders ,i don't know which one is used to integrate zxing library in android app,here i am placing the zxing folder after checkout.
Checkout Integrating the ZXing library directly into my Android application question and answers on Embed Zxing library without using Barcode Scanner app question.
I'm quoting the answer of Sean Owen, one of the author's of Zxing library from this answer:
" The complete source code is available from the ZXing project. You want to build
core.jar from core/ and put it in your Android lib/ folder to include the core
decoder in your app. You do not want to include javase. You can look to the code in
android/ as it is the source to Barcode Scanner, but as the authors we'd suggest you
not just copy and paste it."
Hope this helps.
I've just figure out how to do it by surfing on the web and testing all the tutorials that are pretty similar but few works when integrating on eclipse without the need of building with Maven or even Ant.
Downloads: Downloads the zip folder TDBarcodeQRScanner: here.
Unzip the folder, inside the folder, you will find two projects. Copy-paste the project LibraryBarQRCodeScanner into your workspace.
Add a new Android project from existing source code. Navigate to the root folder of the project --> Select --> finish. The project appears in the workspace. With errors.
Right click on the newly added project and --> Properties --> Android. Under Android uncheck Google API and check the targetted API of your choice. Check the IsLibrary checkbox if it's not checked.
Clean and build the project. Errors disappears.
Go to your project. Right click --> Properties --> Android --> Library --> Add --> add the project newly added. The project is added as library to your project.
Modify the activity from which you are launching the App in order to fire the scan. As the MainActivity.java from the other project included in the unzipped folder.
After hours of search, it's the only method that works for me. As I wanted to scan code bars and not QRCode, and it's the case for you, just replace the SCAN_MODE extra value "QR_CODE" to "SCAN_MODE"
Happy integration !!
I have rewrite
https://github.com/journeyapps/zxing-android-embedded
for adt and eclipse.You can get source for github here
https://github.com/hiteshsahu/XZing-Barcode-Scanner-Minified-Eclipse
I have also merged packages so that you can just copy paste them in your project without making your project look huge.
Just drop 3 source code packages and 2 layout files in your project and you are good to go.
For more detail read my answer here Integrating the ZXing library directly into my Android application

How to add external libraries to my application in android

I have an application that I have to look at as a training exercise. It has used few external libraries such as SlidingMenu, ImageViewZoom and ActionbarSherlock.
I have downloaded and extracted those libraries but I have no idea how to add them to my existing project.
For those that are distributed as a simple JAR, do what Emil Adz indicates, and copy that JAR into your project's libs/ directory.
For those, like ActionBarSherlock, that are distribute as Android library projects, you will need to do a bit more work. In the case of Eclipse, you will need to import the library project into your workspace, then go into Project > Properties > Android for your application project and click the [Add] button to add the library project to the application project. For a command-line build, use android update lib-project to link the application and library project together.
You can read more about referencing an Android library project from Eclipse or the command line in the documentation.
You need to import those libraries as Android Project from existing source and mark them as "Is Library" by going into their properties.
Once you marked it as "Is Library" add it to your
project by going into Properties->Android->Library->Add (it will show the list of library you imported).
The Right Way:
What you need to do is to copy the external library (JAR file) to the /libs folder of your project.
That way those libraries will compile with your project and could be use on real device when you deploy your application.
Some times you will need to add a project to your workspace ( For example the Google Map library)
and then add the library reference using the properites -> Android window at the bottom.
You can get an idea of how it's done by reading the first 3 step of this Google Map API V2 guide I wrote. there I reference the android library project:
Google Map API V2 Guide
The Wrong Way:
any other way, like for example adding the files using the properties - > Java build path screen may result in a missing library when you run the project on a real device.
if they are jars the make a libs folder then paste the jar in it and then go to your project buildpath->configure build path->Add Jars-> ok and if it is a library project then go to your project Property->Android->Add(Your Lib Project)->Ok->Apply

Android app with eclipse project dependency

I have an Android app which uses a jar library generated from another Eclipse project.
But is it possible to directly reference this project instead of using an intermediate jar ?
When I do that, the build succeeds but I get VerifyErrors at runtime saying the classes of my external project can't be found...
Yes, you can directly reference this project by setting it as library. To do so:
Right click on your desired library project, choose properties and mark checkbox 'isLibrary'
Then just simply right click on you project, go to properties and add those library project
Yes, ADT supports libraries in form of shareable source code and resources, not just .jar. Please see Android Developer website, especially Managing Projects -> Library Projects article.

Categories

Resources