Error when add facebook sdk to Android project - android

I want to creat an app login and upload photo to facebook..
I downloaded facebook android sdk at : https://github.com/facebook/facebook-android-sdk
I also done as that tutorial: https://developers.facebook.com/docs/mobile/android/sso/
But in step 1: when i create a facebook sdk project,it display error at Facebook class in part:
#Override
public void onServiceConnected(ComponentName className, IBinder service) {
messageSender = new Messenger(service);
refreshToken();
}
#Override
public void onServiceDisconnected(ComponentName arg) {
serviceListener.onError(new Error("Service disconnected"));
// We returned an error so there's no point in
// keeping the binding open.
applicationsContext.unbindService(TokenRefreshServiceConnection.this);
}
Image error:
http://nn7.upanh.com/b1.s28.d1/249400dcc8b86b740a9fab6679a809e3_45509157.project2.png
I don't resolve this problem so I can't do next step.:(
Can you help me.

You will need to do two things:
link the facebook sdk to your project.
link the com_facebook_android library to your project.
You might also need to clean your project, and perhaps use the "fix project properties automatically" tool. Perhaps even restart eclipse if you still have errors.

Related

Debugging Android in custom libraries

I have just created a react-native library using react-native-create-library and imported it into my master react-native project.
There are some issues I'm having because (honestly) I lack the knowledge.
The problem is that there are no errors (using logcat) and I don't know how I can debug the android part of my imported library.
Example
public class RNZappsCameraModule extends ReactContextBaseJavaModule
implements ActivityEventListener {
#ReactMethod
public void myJavascriptMethod() {
// I want a breakpoint here
// cameraIntent initialization happens here
try
{
currentActivity.startActivityForResult(cameraIntent, requestCode);
}
catch (ActivityNotFoundException e)
{
e.printStackTrace();
}
}
#Override
public void onActivityResult(Activity activity, int requestCode, int resultCode, Intent data)
{
// I want a breakpoint here
}
}
The camera intent starts fine, but I believe onActivityResult is never hit.
I know I could log everything and read it, but that won't explain why the result is never returned to my app since there are no errors in the first place.
Google and the official RN documentation are not being my friend at the moment, so please put me on the right track.
Found it.
No rocket science here. I don't know how I managed to do it in the end...
Anyheeew, to give this question a reasonable answer for passers-by...
First off, you need a react-native (master) project in order to actually run your library in a react-native context.
So create it and import your library. The easiest way to do this is by pushing your library into a git repository and adding your library in the package.json of you master project like this:
"react-native-your-package": "git+https://your-git-url-here",
Now install it: npm install react-native-your-package
In order to debug your library:
Open the android project of your react-native project in Android Studio
In menu => view => Tool window, click Build Variants
The new window displays the build types for you project and loaded modules
Click the Build Variant dropdown next to the module you want to debug and select 'debug'
Debug the master Android project
In the projects view, you can expand your module and place breakpoints where ever you like
Click the debug button and fix errors you never head of

Adding BaseGameUtils as library (Google Play Game Services)

I am trying to add the BaseGameUtils lib to my poject and following the instructions on https://developers.google.com/games/services/android/init
and downloaded the BaseGameUtils on here https://github.com/playgameservices/android-basic-samples
When I am trying to import the BaseGameUtils lib -Using Eclipse- (File -> Import -> Android -> Existing Android Code Into Workspace)
Tried both "android-basic-sample-master" and "BaseGameUtils" folders selecting as root folder selection.
After finishing the import, project name is appears as "main". Not BaseGameUtils.
I tried that "main" project marked as "is library" and right click on my app folder then from the android selection on the left, added "main" project as a library and then applied it.
But I get the error when I tried to use GameHelper class; "GameHelper cannot be resolved to a type"
for example when trying this;
.
.
.
.
GameHelper mHelper;
#Override
protected void onCreate(Bundle savedInstanceState) {
.
.
.
.
mHelper = new GameHelper(this, GameHelper.CLIENT_ALL);
GameHelperListener listener = new GameHelper.GameHelperListener() {
#Override
public void onSignInSucceeded() {
// handle sign-in succeess
}
#Override
public void onSignInFailed() {
// handle sign-in failure (e.g. show Sign In button)
}
};
mHelper.setup(listener);
}
I can't find any solution. Followed the instructions carefully, but still got the problem. What could be the reason for this?

How to setup alljoyn sdk in android?

I am trying to setup two android devices to communicate with each other through wifi. Some of the links I have gone through suggest alljoyn sdk in order to accomplish this.
There is an sdk download but there is no documentation for how to setup environment.
Here is how to set up an AllJoyn SDK development environment with android studio:
Download the SDK from this page. Go for Android Core SDK - release (or debug).
Create a new blank android project.
Create directory <project>/app/src/main/jniLibs and <project>/app/src/main/jniLibs/armeabi.
From alljoyn-15.09.00-rel/java/jar copy alljoyn.jar and from alljoyn-15.09.00-rel/java/lib copy liballjoyn_java.so. The directory to copy from might differ depending on the current version and your release/debug choice.
Put alljoyn.jar in /jniLibs and put liballjoyn_java.so in /jniLibs/armeabi. Should look like this
Right click project -> Open Module Settings -> app -> Dependencies.
With the green [+] button, add a file dependency.
Navigate to <project>/app/src/main/jniLibs/alljoyn.jar and select that jar.
This will add a line in your gradle (compile files('src/main/jniLibs/alljoyn.jar')) that will allow for code completion etc.
In the file where you want to use alljoyn code, include this snippet
/* Load the native alljoyn_java library. */
static {
System.loadLibrary("alljoyn_java");
}
for example:
public class MainActivity extends AppCompatActivity {
/* Load the native alljoyn_java library. */
static {
System.loadLibrary("alljoyn_java");
}
#Override
public void onCreate(Bundle savedInstanceState) {
...
}
}
You can now use the alljoyn SDK. Import classes with
import org.alljoyn.bus.BusAttachment;
import org.alljoyn.bus.BusException;
import org.alljoyn.bus.BusListener;
etc.
If you're more of an eclipse guy, check this official documentation page on how to setup an eclipse environment.

Facebook Android SDK source will not compile with Eclipse Indigo

After finally getting the Android Facebook SDK to properly import thanks to this, I found that eclipse does not recognize the override of onclick in FbDialog.java:
mCrossImage.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
mListener.onCancel();
FbDialog.this.dismiss();
}
});
Nor does it recognize the overrides of onServiceConnected and onServiceDisconnected in the TokenRefreshServiceConnection implementation of ServiceConnection
#Override
public void onServiceConnected(ComponentName className, IBinder service) {
messageSender = new Messenger(service);
refreshToken();
}
#Override
public void onServiceDisconnected(ComponentName arg) {
serviceListener.onError(new Error("Service disconnected"));
// We returned an error so there's no point in
// keeping the binding open.
mAuthActivity.unbindService(TokenRefreshServiceConnection.this);
}
All three methods say, in the warning, that the method must override a superclass method. I have not modified the code at all yet. I checked that Eclipse recognizes the types as the same ones in the respective superclasses, and I have tried pressing control-shift-o to organize the imports, which was a fix suggested in this answer for a similar problem.
These overrides are part of the SDK, not any separate project. I set up the project to use Android SDK 2.2 as was shown on Facebook's instructions, and 4.0.3, which should be, theoretically, compatible with all previous versions. I have yet to get Facebook's own code to work. As a side note, is there a jar I can use instead? It would make this much easier.
Guessing your Project Properties -> Java Compiler Compiler compliance level is set to 1.5, not 1.6 (or higher).
Change this.
Why is javac failing on #Override annotation
The lazy, fast and easy fix is to remove the #Override annotations. The correct fix is to check that the project compiles to Java 1.5 or above, to use "fix project properties" from Eclipse, and possibly to check that the Facebook library project uses the same Android SDK for compiling against, as your project.

Android:Eclipse won't recognize AIDL file

I've looked and looked, but Eclipse (3.6, with the 2.2 Android SDK) just won't do anything with the AIDL file I created. The AIDL file is in the same place as the other source, following the Java style. I've read that Eclipse should just generate the stub for the interface declared in the AIDL file, but it doesn't appear in the gen folder, nor anywhere else i've seen, and the project doesn't build because the interface specified in the AIDL isn't found. I suspect i'm doing something silly or not understanding something, but as much as i've looked and tried, I still don't get it and Eclipse still fails.
My AIDL:
package com.example.helloandroid;
interface HOSPlayerInterface
{
public void playURL(String url);
public boolean pause();
public boolean resume();
public void stop();
}
... and said AIDL lives in the com/example/helloandroid directory. Eclipse isn't recognizing it, highlighting syntax, running AIDL, etc. I'm at a loss. The Android plugin is installed and working, as i'm able to build and run simple Android projects that don't require AIDL. Any help would be appreciated.
Just remove all "public" access modifier before method declaration. The following code works in my project.
package com.example.helloandroid;
interface HOSPlayerInterface {
void playURL(String url);
boolean pause();
boolean resume();
void stop();
}
If the aidl file can not get compiling in Eclipse, delete "gen" folder and rebuild the project.
Any build errors? The IDE might exit prior to compiling your .aidl-file due to parse errors in XML or similar.

Categories

Resources