Import Google Play libraries into android project

I’m trying to implement Google Play Libraries (Set Up Google Play Services  |  Google APIs for Android) into a project generated by SDK.I simply add ‘google_play_services.jar’ as a library.

All classes from the jar work correctly in the main project.However i can’t import them in the android activity,even if all libraries should be imported by android sub-project too and google_play_services.jar is in the “libs” folder of the android project and this looks pretty strange :neutral_face:

Do you have the nbAndroid plugin? That way you can check the libraries for the android app

Yes,but i had to install it manually as i built SDK from github and i had to update download link to 8.1 (http://www.nbandroid.org/2015/11/support-for-netbeans-81-released.html).

Maybe that’s what makes plugin unable to implement those libraries?

Hi aegroto. Integrate google libraries into jmonkey is always a bit nightmare. Did you check this link??

https://hub.jmonkeyengine.org/t/android-project-cheat-sheet/

Following that steps I’ve integrated google libraries into my project (using the jMonkey SDK). There some steps that failed to me, first one:

Compile the jar file for use with your project:

  1. In the directory you copied, there is an android project file.
  2. In JME’s IDE, open this project
  3. In the General section of the project properties, there is a list of potential Android target platforms. Select the one you are using for your project (:rage:this is what it fails, compile it to at least 5.0 or higher) by clicking on the list (this is not intuitive at all, as the list looks like nothing more than info… not selectable items)
  4. Under the Library section, click the checkbox that is labeled: Is Library
  5. Click Ok and then Clean & Build this project.

Second one:
After following all steps related to the jar library, modify the manifest.xml, adding the integers.xml and clean and build, you will have an error saying expected integer xxxx, found 4323000. Modify your integers.xml and replace the 4323000 for the expected integer xxxx.

You will have (I supposse) and ok clean and run and you will be able to use google libraries into your android project.

1 Like

So do i have to necessarily deploy my game to 5.0 or above?

No. That’s only for the google libraries. You can compile the library for the 5.0 and your game for the 4.4 (that’s my case) and the 5.0 library works. I don’t know why :astonished:, but it works.

1 Like

Thanks for all :slight_smile: Now “main” library works correctly. However,i get some freak NoClassDefErrors on google’s code:

java.lang.NoClassDefFoundError: com.google.android.gms.R$string
java.lang.NoClassDefFoundError: android.support.v4.util.ArrayMap

I tried importing some jars from SDK files but i don’t think that’s a good solution and anyway i can’t find all complementary jars needed…Did you have the same problem?

No. It worked fine for me.

The first issue may be related to the lines that must be added to the manifest.xml file.
The second one may be related to a missing library. You must also add the android_support_v4 or something similar to your project.
_

What lines are you talking about?Because i followed instructions in thread you linked and i add:

<meta-data android:name="com.google.android.gms.games.APP_ID" android:value="@string/app_id" /> <meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version"/>

Seconds goes great but first string returns this error:

AndroidManifest.xml:5: error: Error: No resource found that matches the given name (at 'value' with value '@string/app_id').

You need to add the following line inside your strings.xml file:

<string name="app_id">you_app_id_number</string>

Your app_id_number is a number provided by google. You need to follow these steps:

As always goolge making things easy… At the end of this horrible process you can found your app_id inside the google play developer console, inside the game services tab.

Of course, you need a google developer account. :wink:

1 Like

So do i have to necessarily have to pay the fee for developer’s account to just have access to api? That sounds pretty unfair…

You don’t need to pay to use the API if you are only making tests, but if you are going to use production-like tests you do need to pay. The fee is small though

Compared to Apple’s 100$ per year is Google’s 25$ one time very, very cheap. Especially for people like me who publish one or two apps and then nothing for like 2 years.

Yeah,google is cheap but if they want money they could also make things easier :stuck_out_tongue: But thanks for all,i’ll just get a developer account as soon as possible and hope everything works.