1
votes

I follow https://developers.google.com/games/services/android/init to setup leaderboards. So in my game project I have setup google_play_services lib as it already uses AdMob. Now I need to all Also BaseGameUtils. But the steps in section "Setting up your game project" in the link above don't work. Let me tell what I have done:

  1. Opened https://github.com/playgameservices/android-basic-samples and pressed "Download ZIP".
  2. Extracted the zip and imported the folder into my project. Disselected all and selected only BasicSamples/libraries/BaseGameUtils/src/main which was added in my project as main and not as BaseGameUtils.
  3. Right clicked on main project, in Properties->Android section selected Is Library and in my game project in Properties->Android section added Reference to main library. (Note that if you don't select Is Library you cannot do 6. In the Library panel, click the Add button. 7.Select BaseGameUtils.step as it is pointed out in the tutorial )
  4. In my package src directory create a new class like this:
import gms.common.api.*;

import com.google.example.games.basegameutils.BaseGameActivity;

public class MyGameActivity extends BaseGameActivity {

but neither of the imports is recognized. How to setup this? This should have been to be so easy but is it so creapy?

2

2 Answers

7
votes

The steps are incomplete in the tutorial. Here are the actual steps:

  1. Opened https://github.com/playgameservices/android-basic-samples and pressed "Download ZIP" or you can clone the git repo too.

  2. Then there is a Scripts/make_eclipse_compat (.cmd for Windows) script. cd android-basic-samples; and run the script. It generates eclipse_compat next to Scripts dir.

  3. Import into eclipse android-basic-samples/eclipse_compat/libraries/BaseGameUtils and not the original BaseGameUtils downloaded. Note that in this case in Eclipse you are not getting add there main project but a project called BaseGameUtils.

  4. Right click on BaseGameUtils project go to Properties->Android and make sure Is Library is checked and add google_play_services as Reference library.

  5. If you use for example Facebook SDK or other SDKs then you may have such a conflict:

Found 2 versions of android-support-v4.jar in the dependency list, but not all the versions are identical (check is based on SHA-1........

Here is the resolution: Facebook SDK for Android duplicate support library on dependencies

  1. Also

    import gms.common.api.*;

is wrong you should do this:

import com.google.android.gms.common.api.*;
import com.google.example.games.basegameutils.BaseGameActivity;


public class MyGameActivity extends BaseGameActivity {
0
votes

For MAC users.

Open Terminal.

cd android-basic-samples

then type bash Scripts/make_eclipse_compat

It will generate eclipse_compat folder next to the Scripts folder. Import to Eclipse the generated folder.