Adding BaseGameUtils as library (Google Play Game Services) - android

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?

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

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.

What is the minimum number of steps to get full javadoc support with the new default project options?

With the new SDK Tools and ADT versions 22.6.2, the default options for creating a new project with a blank activity produces a project which uses Fragments and refers to a library project (a new one for each project) named appcompat_v7_x.
The relevant parts of the stub code for the main activity are:
package com.myname.miniandroid;
import android.support.v7.app.ActionBarActivity;
import android.support.v7.app.ActionBar;
import android.support.v4.app.Fragment;
.....
.....
public class MainActivity extends ActionBarActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
....
}
public static class PlaceholderFragment extends Fragment {
......
......
}
}
.
We can see that it uses a Fragment and an ActionBarActivity. The automatically created library project has both the v4 and the v7 jars in its libs folder, the main project has just the v4 jar. As built by default, hovering over either of these classes gives no javadoc information.
To get such support I've had to :
1) insert a file android-support-v7-appcompat.jar.properties into the libs folder of my automatically created appcompat_v7_4 library project. It contains the lines:
doc=c:\\dev\\tools\\android-sdk-windows4.4\\docs\\reference
src=C:\\dev\\tools\\android-sdk-windows4.4\\extras\\android\\support\\v7\\appcompat\\src
(Both lines seem to be necessary)
2) insert a file anndroid-support-v4.jar.properties into the libs folder of the main project. It contains the line:
src=C:\\dev\\tools\\android-sdk-windows4.4\\extras\\android\\support\\v4\\src
3) Close and reopen both projects and clean all projects.
I've got a brand new installation of Eclipse Kepler and an up to date installation of the SDK.
I feel that there must be a quicker way of getting set up to start a new project with the recommended default options. If anyone can tell me what it is, I would be most grateful.
You have use the "New" button in the upper left corner, select Android Application Project, choose the name, icon...
When you have done, you should have a working "Hello world" app.
If you want to add external libraries this is the answer: https://stackoverflow.com/a/3643015/3203988

google play game service error -> 'Could not find class...GameHelper '

import com.google.example.games.basegameutils.GameHelper;
public class MyAppName extends Cocos2dxActivity implements GameHelper.GameHelperListener {
....
.....
public static GameHelper gameHelper;
#Override
protected void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
gameHelper = new GameHelper(this);
.....
error point: gameHelper = new GameHelper(this);
error Message : Could not find class 'com.google.example.games.basegameutils.GameHelper', referenced from method com.company.MyAppName.MyAppName.onCreate
How do I fix this?
On BaseGameUtils, go to Project Properties | Android. Verify that it's targeting a valid Android target that's present on your SDK (anything with API level >= 8 should work).
Also on the project properties screen for BaseGameUtils, check that the "Is Library" checkbox is checked.
Check that BaseGameUtil is referencing google-play-services_lib as a library. (Project Properties | Android | References).
Check that your project is referencing BaseGameUtil as a library (same).
Hope this helps!
Did you define Basegameutils as a library project and include it as a reference ?
The doc that accompanies the sample is fairly good.
In the latest BaseGameUtils project (I downloaded from google github on Aug 13, 2014), the source files are not under the src/ folder. so you will need to Properties->Java Build Path->Add folder and select the java folders.
If the project then compiles without error for the BaseGameUtils, great! I also encountered some other compilation errors and solved it by update the Google Play services to the latest version in SDK manager.
Hope it helps.

Error when add facebook sdk to Android project

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.

Categories

Resources