简体   繁体   中英

Adding achievements and Google Play Games services

It was supposed to be easy, but it's so hard...
I'm working with eclipse. I'm trying to go by this site .
In here it says (Setting up your game project) that I need to make my main Activity extend BaseGameUtils .

I go into the download link, and for some reason I see many projects. I download one that contains what I need, and from everything being downloaded (many projects), I pick the right one and import it (for some reason it contains it's sources not in src directory but in java , so I needed to add it to the build path... And it's being called main so it's already exists...)
In addition, I also install google-play-service-lib and import it too. Then I make it a project that BaseGameUtils depends on.
Now I make my MainActivity (Main class) exdends BaseGameActivity and get an error:

The hierarchy of the type Main is inconsistent. 

If I go into BaseGameActivity I see an error there -

The import com.google.android.gms.common.api cannot be resolved 

Which makes

The hierarchy of the type BaseGameActivity is inconsistent. 

So it doesn't know which package to reference, and so do I... Using eclipse_compat not helped - it did the same thing - at first not knowing com.google.android and after using google-play-services-lib makes com.google.android.gms.common.api unknown.
Then I removed the project dependency of google-play-services and replaced it with a jar dependency. That solved the unknown problem of com.google.android.gms.common.api , but made com.google.android.gms.games.request unknown. Trying to use android studio didn't help - throws

Android Dex: [] com.android.dex.DexException: Multiple dex files define 
Lcom/facebook/AccessToken$SerializationProxyV1;

on compile. I think it means google-play-services-lib because removing it solves this problem, only now it can't find com.google.example ...
It was supposed to be really easy (just add a project and extend it) - Why is it this hard (don't get me started on adding a record table to the project...)?!

So to sum up:
I want to add achievements into my app, and I don't know how... I tried many things (written) and came across many errors. I just want to be able to extend BaseGameActivity / add BaseGameUtils without compile errors (where are the required classes?). In case Android Studio could help, I want to be able to solve my compile problem.

Edit: Now google changed their guide, so I don't have this problem anymore.

You got it wrong. The files in the java folder (in which BaseGameActivity.java is) were suppose to be placed in your project and not as part of library project. Place it in your project and then reference the google-play-services-lib project as a library project in your project. All should work fine.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM