Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Google Play Online Subsystem not working

I'm trying to set up achievements in my android game. I have enabled the google play services through the project settings. I have also uncommented the section in the build.cs for the online subsystems. I know how to get the app into the google play store, and have everything set up on the google play store end. However, every time I try to connect to the google play services, I receive the errors:

"ConnectToService - Invalid or uninitialized OnlineSubsystem"

"ConnectToService - Cannot map local player to unique net ID"

As far as I can tell, by browsing through the source code, the first error occurs when the IOnlineSubsystem* OnlineSub == nullptr when I try to connect. I'm out of things to try. What am I missing, or what am I doing wrong?

Product Version: Not Selected
more ▼

asked Nov 05 '14 at 02:52 AM in Using UE4

avatar image

181 5 11 19

avatar image Nanoxin Nov 21 '14 at 02:35 PM

Did you manage to solve this problem? I've got a similar issue :(

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

Hi Nefusadi,

There are a couple things you can look at, first of all, make sure "OnlineSubsystemGooglePlay" is one of the uncommented dependencies the Build.cs.

Also, check for DefaultPlatformService in your DefaultEngine.ini file. On Android, this should default to "GooglePlay", but it might be getting overridden. You can try making sure this is in your DefaultEngine.ini:

more ▼

answered Nov 21 '14 at 06:03 PM

avatar image

Ryan Gerleve STAFF
1.1k 25 12 49

avatar image Nefusadi Nov 21 '14 at 11:39 PM

I had already added the DefaultPlatformService=GooglePlay to the ini file, but I went ahead and added: PrivateDependencyModuleNames.Add("OnlineSubsystemGooglePlay"); right after the dependency for "OnlineSubsystem" to interesting effect. It now gives compile errors for UE4Editor-OnlineSubsystemGooglePlay.dll stating:

Cannot open include file: 'jni.h': no such file or directory

Cannot open include file: 'gpg/achievement_manager.h': no such file or directory

I tried re-downloading the required dependencies, and then re-creating the project files, but the errors persist.

avatar image Ryan Gerleve STAFF Nov 22 '14 at 12:03 AM

Based on those errors, it looks like it's trying to compile the Google Play subsystem for Windows, which is not supported. Try moving the PrivateDependencyModuleNames.Add("OnlineSubsystemGooglePlay") into an if (Target.Platform == UnrealTargetPlatform.Android) block.

avatar image Nefusadi Nov 22 '14 at 04:15 AM

Ok, wrapping in the conditional allowed me to compile everything, but now the packaged game gives me a black screen for a second before immediately shutting down. I tried recompiling the .so and doing a full rebuild of my game as well.

Edit: I launched a development build of the game to see if I could get an error message from it, but it ended up running as expected (including asking to sign in, which failed due to the fact that it's an unsigned build) but if I go back to a shipping release, it continues to close out immediately after starting up.

Edit2: I should have looked at it earlier, but LogCat is showing that when I try to launch the app I get a whole list of errors of the format:

Exception in java/lang/ClassLoader.loadClass: java.lang.ClassNotFoundException: Didn't find class"com.google.android.gms.games.[everything from achievements to leaderboards to multiplayer to snapshot, etc.]" on path: /data/app/com.epicgames.HarbingerOfTruth-1.apk.

Additionally, there's a whole bunch of permission denied warnings for getCurrentUser() from android.permission.INTERACT_ACROSS_USERS, though it's difficult to tell if they're all related to my game.

avatar image Nefusadi Dec 02 '14 at 07:07 AM

Any idea why the classes aren't ending up in the .apk on the shipping build? I'd really like to get the achievements working.

avatar image Ryan Gerleve STAFF Dec 03 '14 at 06:30 PM

The missing classes are probably a result of running Proguard, which we do for shipping builds. Proguard will strip classes that it doesn't think are required from the final APK. We have exceptions for the Google Play SDK in the engine's proguard-project.txt, so all the required classes should be there. If you're using a custom proguard-project.txt file for your game, make sure it has the same exceptions for Google Play that are in Engine\Build\Android\Java\proguard-project.txt.

As far as I know none of the engine code requires the INTERACT_ACROSS_USERS permission, so I suspect this is just log spam from other apps, but you can experiment with adding it to AndroidManifest.xml if you like.

avatar image Nefusadi Dec 03 '14 at 11:36 PM

Yup! Turns out a proguard-project.txt file had been generated for my project, and was missing two sections in the google play services part. It's all working now, thanks for your help!

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question