0
votes

I'm trying to implement Google Play Services into my application.

I understand that there is a sample project named BaseGameUtils and I need to import it into my workspace and mark it as a library, After importing google-play-services_lib into my workspace, I reference it as a library in the BaseGameUtils library. Lastly I reference both BaseGameUtils and google-play-services_lib in the project I actually want to publish to Google Play.

Somewhere in all those connections, I have a jar file in my class path by the same name. To solve this problem I need to delete one of the references of google-play-services_lib because when I try to export the project I receive this error:

Unable to execute dex: Multiple dex files define Lcom/google/ads/AdRequest$ErrorCode;

OK, so if i deselect "Android Private Libraries" the project will export but none of the Google Play Services are available. When I try to launch the class, upon startup of the app I get the error:

 super.onCreate(savedInstanceState);

I understand that I have to call

 setRequestedClients(BaseGameActivity.CLIENT_GAMES
            | BaseGameActivity.CLIENT_APPSTATE);

before

    // call BaseGameActivity's onCreate()
    super.onCreate(savedInstanceState);

but it's not working. Which means the GoogleApiClient won't start because the classes weren't exported.

    @Override
public void onCreate(Bundle savedInstanceState) {
    // set requested clients (games and cloud save)

setRequestedClients(BaseGameActivity.CLIENT_GAMES
            | BaseGameActivity.CLIENT_APPSTATE);

    // call BaseGameActivity's onCreate()
    super.onCreate(savedInstanceState);

    // game-specific logic:
    setContentView(R.layout.pillow);
    findViewById(R.id.sign_in_button).setOnClickListener(this);
    findViewById(R.id.sign_out_button).setOnClickListener(this);
}

So, if I deselect "Android Private Libraries" , the project will export nicely when I add the .jars I normally need to use externally and add them to the build path.. But Google Play Services.

I can remove the external jar from the build a path and add "Android Private Libraries" to the build path, but then I have multiple google-play-services_lib.

I'm so confused It's either there twice or not at all.

Does anyone have any idea what's going on?

hope this works..

1

1 Answers

0
votes

This looks to me like an admobs related issue. Admobs has now been integrated into the Google Play Services jar, but it looks like you are still including the separate admobs jar in you project. Both these jars contain the same class names, hence this causes your problem.

I suggest you remove GoogleAdMobAdsSdk.jar from your build path.

For more information on this problem, please look at

Multiple dex files define Lcom/google/ads/AdRequest$ErrorCode and Multiple dex files define Lcom/google/ads/AdRequest$ErrorCode