问题
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:
- Opened https://github.com/playgameservices/android-basic-samples and pressed "Download ZIP".
- 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 asmain
and not asBaseGameUtils
. - Right clicked on
main
project, inProperties->Android
section selectedIs Library
and in my game project inProperties->Android
section added Reference tomain
library. (Note that if you don't selectIs Library
you cannot do6. In the Library panel, click the Add button. 7.Select BaseGameUtils.
step as it is pointed out in the tutorial ) - 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?
回答1:
The steps are incomplete in the tutorial. Here are the actual steps:
Opened https://github.com/playgameservices/android-basic-samples and pressed "Download ZIP" or you can clone the git repo too.
Then there is a
Scripts/make_eclipse_compat
(.cmd for Windows) script.cd android-basic-samples;
and run the script. It generateseclipse_compat
next toScripts
dir.Import into eclipse
android-basic-samples/eclipse_compat/libraries/BaseGameUtils
and not the originalBaseGameUtils
downloaded. Note that in this case in Eclipse you are not getting add theremain
project but a project calledBaseGameUtils
.Right click on
BaseGameUtils
project go toProperties->Android
and make sureIs Library
is checked and addgoogle_play_services
as Reference library.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
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 {
回答2:
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.
来源:https://stackoverflow.com/questions/26442525/android-play-services-leaderboard-cannot-be-installed-basegameutils