Google Play Services (Suggested updates to Android Main Activity for plugin)

@t0neg0d

That I may be missing. Unfortunately I’m pretty lost at this moment.

I have downloaded the library needed and have copied the folder to the jmonkey directory in which all the other libraries are stored.

The next step you suggest is

Opening up the project properties and selecting the target version for the build

I am unable to complete this step without further explanation if you could elaborate that would be helpful.

Also, when it comes to actually being able to reference the classes within the google play .jar, I have tried to reference the .jar, the entire folder, and creating a new library with both these insides.

Both with no luck.

I’m essentially at the point in which I have the google play lib folder, and need to know how to make it able to reference it from within my project,

EDIT: I found something of note. Apparently the Android Main Activity is using a different set of libraries than the main game project. I suppose if I find where the MainActivity is getting its libraries I can move the google-play-services.jar there.

But if I make my own class, the library for the google play services is referenced properly, but I cannot reference any of the Android stuff such as the onCreate and the Android OS Bundle…

So I must either reference the rest of android to the main part of my project or properly reference the google play services library to the MainActivity

@BigBob said: @t0neg0d

That I may be missing. Unfortunately I’m pretty lost at this moment.

I have downloaded the library needed and have copied the folder to the jmonkey directory in which all the other libraries are stored.

The next step you suggest is

Opening up the project properties and selecting the target version for the build

I am unable to complete this step without further explanation if you could elaborate that would be helpful.

Also, when it comes to actually being able to reference the classes within the google play .jar, I have tried to reference the .jar, the entire folder, and creating a new library with both these insides.

Both with no luck.

I’m essentially at the point in which I have the google play lib folder, and need to know how to make it able to reference it from within my project,

EDIT: I found something of note. Apparently the Android Main Activity is using a different set of libraries than the main game project. I suppose if I find where the MainActivity is getting its libraries I can move the google-play-services.jar there.

But if I make my own class, the library for the google play services is referenced properly, but I cannot reference any of the Android stuff such as the onCreate and the Android OS Bundle…

So I must either reference the rest of android to the main part of my project or properly reference the google play services library to the MainActivity

When you open the project properties, there should be 4 tabs? I think.

One of them has a list of available target libraries (should be stuff like Android 2.2, Android 4.2.2, Google API, etc, etc)
Select one of these nad make sure the Is Library check box is selected, then click the ok button.
Once you’ve done this, Clean & Build this project.
After this, you should be able to find a dist or lib folder in the project directory that contains the play services .jar file.

Open your Android project and add this as a library jar

Once you Clean & Build your project, you should be able to see the library via code completion and you should be able to reference the playservices library from your Main Activity.

Don’t try and add the android library to your JME project… things will go funky and you won’t be able to compile it from that point forward.

Also remember, the Files view in the IDE. You’ll be able to add other java classes to the directory that contains your Main Activity file, as well as add other Android specific resource files (xml, images, etc). This is usually located in mobile/res

It’s frustrating as hell, isn’t it? =P

Probably the most frustrating experience so far.

I have managed to get the google play services jar to appear in the dist/lib folder of my mobile project. Unfortunately I am still unable to reference this from main activity, and can only reference it from within my main project package.

At this point the integration of these ads has been more troublesome than the writing of the application itself.

To elaborate.

I referenced the google-play-services.jar as a library to my android project, then did clean and build, the google-play-services then appeared in my dist/lib. But am still unable to import anything from the google play library.

Strangely enough I can import my own source package, and my source package can import the google services.jar but my java skills are not good enough to tell if I can bridge between these two things.

Or even what I’m doing wrong.

@BigBob said: Probably the most frustrating experience so far.

I have managed to get the google play services jar to appear in the dist/lib folder of my mobile project. Unfortunately I am still unable to reference this from main activity, and can only reference it from within my main project package.

At this point the integration of these ads has been more troublesome than the writing of the application itself.

To elaborate.

I referenced the google-play-services.jar as a library to my android project, then did clean and build, the google-play-services then appeared in my dist/lib. But am still unable to import anything from the google play library.

Strangely enough I can import my own source package, and my source package can import the google services.jar but my java skills are not good enough to tell if I can bridge between these two things.

Or even what I’m doing wrong.

Hmmm… I had this issue as well. I’m fairly sure the problem was in how I was building the play services library. But, there is bigger pisser after you get this working…

The added views for ads will not appear over the JME window unless you lose focus on the app and then return to it.

So be prepared for a bit more frustration even after getting it properly added to your project =(

I’ll go back through what I have done thus far and see if I can repo the steps on a new project and try to detail them out a bit more.

Oh… have you tried shutting down the IDE and reopening it?

EDIT: And actually, getting the god damn play games services added to your project is about 10 times more frustrating than this one. Seriously… Google should be proud (this is sarcasm).

@t0neg0d

Yes, restarting the IDE has been a constant attempted solution for me… I’ve tried about a trillion different ways to get this done properly and for the life of me I cannot understand it…

I recall another ad company called air push who had said something about jmonkey integration, but I’m not sure how legitimate they are.

But as for google’s not for ass-forward way of doing things, I totally agree, this is way harder than it needs to be.

@BigBob said: @t0neg0d

Yes, restarting the IDE has been a constant attempted solution for me… I’ve tried about a trillion different ways to get this done properly and for the life of me I cannot understand it…

I recall another ad company called air push who had said something about jmonkey integration, but I’m not sure how legitimate they are.

But as for google’s not for ass-forward way of doing things, I totally agree, this is way harder than it needs to be.

Can you list he steps you followed for compiling the play services jar? As well as how you add it to the project you are working on?

As for AirPush, there shouldn’t be a problem with adding multiple ad services to your project. While searching for solutions to getting this integrated, I read post after post of people doing just this… all saying, I have no issues with X and Y, but I can’t seem to get Google’s PoS to work, etc, etc.

@t0neg0d

Well… I’m not necessarily compiling the .jar at all, as when I downloaded the google-play-services from the sdk. There was a jar inside the folder already.

I tried referencing the whole folder, google_play_services_libs, but saw no results there.

When referencing the google-play-services.jar within the folder as a regular library. The .jar ended up in my mobile folder, under the lib section.

Yet the ManActivity can’t reference it.

So this maybe where I’m getting this wrong.

  1. Download google-play-services under the “extras” section of the sdk
  2. Copied the google_play_services_lib, to my jmonkey library folder
  3. Reference the google_play_services.jar within my project, as a regular library (probably mistaken here)
  4. Clean and build the project, after which the google-play-services.jar appears inside the mobile/lib folder.

But after this, I still cannot reference the library from the MainActivity. But can from my main project.

Apparently the MainAcivity is using a different set of libraries than my project or something…

This is day four on the AdMob for me.

@BigBob said: @t0neg0d

Well… I’m not necessarily compiling the .jar at all, as when I downloaded the google-play-services from the sdk. There was a jar inside the folder already.

I tried referencing the whole folder, google_play_services_libs, but saw no results there.

When referencing the google-play-services.jar within the folder as a regular library. The .jar ended up in my mobile folder, under the lib section.

Yet the ManActivity can’t reference it.

So this maybe where I’m getting this wrong.

  1. Download google-play-services under the “extras” section of the sdk
  2. Copied the google_play_services_lib, to my jmonkey library folder
  3. Reference the google_play_services.jar within my project, as a regular library (probably mistaken here)
  4. Clean and build the project, after which the google-play-services.jar appears inside the mobile/lib folder.

But after this, I still cannot reference the library from the MainActivity. But can from my main project.

Apparently the MainAcivity is using a different set of libraries than my project or something…

This is day four on the AdMob for me.

Yep, that’s the problem.

You need to open the google play services project and compile it yourself with the target android version you select.
Make sure the “Is Library” checkbox is checked as well.
Open your project properties and add the jar you compiled, then clean & build it and all should work as expected.

There is a bit of good news about ads once you get this working. Ads seem to be showing up over the JME window now. Nothing has changed on my end, so it may have been an issue with Google ad server or something? /boogle Anyways, just wanted to let you know, once you get it working… even though the load time is sloooooow, the ads will eventually show up :wink:

@t0neg0d

Can I get a step by step on how to compile that services jar?

Can this be done within the JME SDK or would I use like eclipse or something?

I’m also a super dense individual, so if you feel that you’re over explaining. You most likely aren’t.

Most of my programming experience comes from within the JME SDK, so I’m not good with things that may seem quick or easy.

Thanks for helping me through this!

@BigBob said: @t0neg0d

Can I get a step by step on how to compile that services jar?

Can this be done within the JME SDK or would I use like eclipse or something?

I’m also a super dense individual, so if you feel that you’re over explaining. You most likely aren’t.

Most of my programming experience comes from within the JME SDK, so I’m not good with things that may seem quick or easy.

Thanks for helping me through this!

Np at all. I literally struggle with this for 2(ish) weeks before finally getting it to work properly (and I’m not completely convinced it is 100% proper)

  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 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.

This will compile the play services all proper like so you can add it to your project. Now, for that step:

  1. Open your project’s properties.
  2. In the Libraries section, click the “Add JAR/folder” button.
  3. Find and add the jar you compiled above
  4. Clean & Build your project

I believe this is all that needs to be done to get this working properly.

If you decide at some point to add Play Games Services, let me know… this took me WAAAAAY longer to figure out and it is NOTHING like the above as you need to add adroid v4 support jar and then add the java files + res files directly into your project.

1 Like

Also, if you have any questions about how to modify your Android Manifest, do let me know… it requires a few meta-data, activity and user-permission tags as well as some additions to resource files in the mobile/res directory(ies).

@t0neg0d

I built the project and here is the results.

Library project: do not package resources…
Library project: do not package apk…
Library project: do not create apk…
Creating new property file: C:\Users\Bob\AppData\Roaming.jmonkeyplatform\3.0\libs\google-play-services_lib\bin\build.prop
Updating property file: C:\Users\Bob\AppData\Roaming.jmonkeyplatform\3.0\libs\google-play-services_lib\bin\build.prop
Updating property file: C:\Users\Bob\AppData\Roaming.jmonkeyplatform\3.0\libs\google-play-services_lib\bin\build.prop
Updating property file: C:\Users\Bob\AppData\Roaming.jmonkeyplatform\3.0\libs\google-play-services_lib\bin\build.prop
debug:
BUILD SUCCESSFUL (total time: 25 seconds)

It created a “bin” folder, within it contains an assortment of stuff including a “classes” jar file an Android Manifest, a classes folder and a random assortment of things.

Was this supposed to create a .jar?

Do I reference the bin folder?

Or did I do something wrong off the start

@BigBob

In <INSTALL DIR>\libproject\google-play-services_lib\libs\ you will find the following jar:

google-play-services.jar

Point at this and let me know how it goes.

EDIT: Sorry… INSTALL DIR = The directory you copied the project to… not the original downloaded project.

@t0neg0d
I reference that .jar directly (which is what I had previously been doing) and clean and built the project.

No change in the ability for the MainActivity to reference anything in the google-play-services.jar but my main project package can.

Strangely enough, the MainActivity can reference my project’s package, but cannot reference any of it’s libraries.