I have a paid app on the Google Play Store and have been using the LVL library for the past two years. In the past, I tested my app on multiple devices including Android V2.3.5 (Gingerbread), V4.4 (KitKat) and V5.1 (Lollipop), everything worked fine connecting to the google license server.
Recently, I retested on all my Android devices and found the license verification library runs perfectly on Android V4.4 and V5.1 but I can't make a successful connection from the V2.3.5 (Gingerbread) device (Motorola Electrify).
I get a responseCode = 0x101 (ERROR_CONTACTING_SERVER) in the verify() callback on the older v2.3.5 device - appears to time out connecting. I tried several accounts and both fail in the same way on the older Gingerbread platforms.
I also tested earlier APK files that used to work and they fail now also.
Did support for older Android OS versions get dropped over the past year?
Is there something I need to change to support the older devices?
Thanks in advance,
Phil
SDK LVL code
class LicenseValidator {
...
public void verify(PublicKey publicKey, int responseCode, String signedData, String signature) {
String userId = null;
// Skip signature check for unsuccessful requests
ResponseData data = null;
if (responseCode == LICENSED || responseCode == NOT_LICENSED ||
responseCode == LICENSED_OLD_KEY) {
// Verify signature.
...
switch (responseCode) {
case LICENSED:
case LICENSED_OLD_KEY:
int limiterResponse = mDeviceLimiter.isDeviceAllowed(userId);
handleResponse(limiterResponse, data);
break;
case NOT_LICENSED:
handleResponse(Policy.NOT_LICENSED, data);
break;
case ERROR_CONTACTING_SERVER:
Log.w(TAG, "Error contacting licensing server.");
handleResponse(Policy.RETRY, data);
break;
case ERROR_SERVER_FAILURE:
Log.w(TAG, "An error has occurred on the licensing server.");
handleResponse(Policy.RETRY, data);
break;
Okay, I figured it out tonight. Post Google Play Services 10.0.1, support for Gingerbread V2.3 is depreciated.
https://9to5google.com/2016/11/21/google-play-services-gingerbread-support-end/
https://developers.google.com/android/guides/releases
"Highlights from the Google Play services 10.0 release.
Google Play services updated to 10.0.1
This release fixes a missing minSdkVersion value in play-services-location.aar that caused unintended WRITE_EXTERNAL_STORAGE, READ_EXTERNAL_STORAGE, and READ_PHONE_STATE permissions to be merged into app manifests.
Android version 2.3.x (Gingerbread) Deprecation
Google Play services 10.0.x is the final release that includes full support for Android version 2.3.x (Gingerbread). Apps developed using future SDK releases after 10.0.x will not be able to connect to Google Play services on Android Gingerbread devices. To learn more about your options, including building multiple APKs to extend your app's support for Android Gingerbread, see the Android Developers Blog."
Phil
Related
recently I ported my old Android game developed in Eclipse from 2011-2016, to Android Studio because I was forced to a much higher MinSdk by Google. To the following according to build.gradle:
compileSdk 30
minSdk 26
targetSdk 31
Everything worked fine after the porting, but I am not able to get the GooglePlayServices (Leaderboards, Achievements) working again.
I am able to trigger that the user signs in with it GooglePlay account. This works and I get the account and can log its name. That is working.
mGoogleSignedInAccount = completedTask.getResult(ApiException.class);
Log.e(TAG, "account: " + mGoogleSignedInAccount.getDisplayName());
But when I try open the leaderboard, so that the user can see their highscore compared to other players
LeaderboardsClient lbc = Games.getLeaderboardsClient(v.getContext(),
ApplSettings.getInstance()._mainActivity).mGoogleSignedInAccount);
Task<Intent> lbt = lbc.getAllLeaderboardsIntent();
lbt.addOnSuccessListener(new OnSuccessListener<Intent>() {
public void onSuccess(Intent intent) {
Log.d(TAG," ..onSuccess");
((Activity) (v.getContext())).startActivityForResult( intent, 9004 );
}
});
lbt.addOnFailureListener(new OnFailureListener() {
#Override
public void onFailure(#NonNull Exception e) {
Log.d(TAG,".. onFailure: "+e.toString());
}
});
I get the following error:
.. onFailure: com.google.android.gms.common.api.ApiException:
17: API: Games.API is not available on this device.
Connection failed with: ConnectionResult{statusCode=DEVELOPER_ERROR, resolution=null, message=null}
I really don't understand this error. What does it mean? It is independent of the phones I use (OnePlus6T, Samsung Galaxy S9). And of course other game apps on those phones, including my other older games app, can show Leaderboards!
What is also strange, is the following message in the GooglePlayConsole of my app in Play-GamesSevice->Configuration.
It says the 5 tasks have to be done to enable the Play-GameServices, and its states that 4 have been done, and 1 task is remaing:
Play-GameService enabling:
Create a Play GamesService project -> done
Create OAuth ConfirmationScreen in the Google Cloud Platform -> done
Create Credentials -> done
Add the SDK for Google Play-GamesServices to your production APK -> OPEN !!!
Publish Project -> done
What does point 4 mean? How to add an SDK to my games app?
Is it not enough to mention those play-service 'libraries' in the build.gradle of my app?
buildscript {
repositories {
google()
mavenCentral()
}
}
dependencies {
. . .
implementation 'com.google.android.gms:play-services-games:23.1.0'
implementation 'com.google.android.gms:play-services-measurement-api:20.0.0'
implementation 'com.google.android.gms:play-services-auth:20.4.1'
}
So I am not sure if this task (number 4) mentioned by Google as outstanding, is related to the error "Games.API is not available on this device", but it would make sense.
But still I don't understand "not available on this device"? Does not the app is build with libraries that communicate with the Google services in the cloud? What shall be missing on the device? All games app (my other very old game, and also very new apps) can without problem show leaderboards on my devices I use for testing.
I am implementing Map Kit on my Android app. After following the official documentation on installing the HMS Core SDK, I have:
Enabled Map Kit, Location Kit and Site Kit on AppGallery Connect.
Added agconnect-services.json
Encoded my API key using URLEncoder and utf-8.
Copied my SHA-256 certificate fingerprints for my release version AND debug version (using different keystore entries).
Asked for location permission.
Setting my API key on MapsInitializer before it's loaded.
In summary, my code looks like this:
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
try {
API_KEY = URLEncoder.encode(
getString(R.string.api_key),
"utf-8"
)
MapsInitializer.setApiKey(API_KEY)
} catch (ignored: UnsupportedEncodingException) {
}
binding = ActivityMapBinding.inflate(layoutInflater)
setContentView(binding.root)
viewModel = ViewModelProvider(
this,
MapViewModel.MyViewModelFactory(application)
)[MapViewModel::class.java]
var mapViewBundle: Bundle? = null
if (savedInstanceState != null) {
mapViewBundle = savedInstanceState.getBundle(MAPVIEW_BUNDLE_KEY)
}
mMapView = binding.mapView
mMapView.onCreate(mapViewBundle)
mMapView.getMapAsync(this)
siteInfo = binding.siteInfo
siteInfo.visibility = View.GONE
// ...
}
But all I get when entering the activity is the blue point of my location over a blank map and a Toast saying REQUEST_DENIED.
Checking the logs, there seems not to be an API authentication or signing error, but most likely Petal Maps API being down:
E/HmsMapKit_ErrorTraceLogPusher_4: cache error trace log : ErrorTraceLogDTO{ scenario = ACCESS_SERVICE_ERROR', message='060001 : NETWORK_ERROR'}
com.huawei.hms.maps.foundation.client.mac: *e*v*r*A*d*e*s*f*o* *R* *s*e*p*y*
at com.huawei.hms.maps.foundation.client.mac$maa.b(Unknown Source:25)
This is disturbing, because there's no sign of this error code in the official Map Kit error codes documentation. Does anyone know what's going on? Thanks in advance!
Solved it! Here's my config:
HMS Core: latest version as of 14/03/2022 (6.4.0.306)
Map Kit: latest version as of 14/03/2022 (implementation 'com.huawei.hms:maps:6.3.1.300')
Main cause: my app signing configuration was missing in my build.gradle file.
Steps to solve it:
Deleted my existing keystore (.jks). DISCLAIMER: you will lose the capacity to update your app if it's released in AppGallery. Please do it as a last resort.
Created a new keystore INSIDE my Android Studio project, under the app directory.
Generated a signed APK for release and obtained the SHA-256 fingerprint.
Replaced my former fingerprint with the new one in AppGallery Connect.
In my map activity, DIDN'T encode my API key (thanks shirley!)
Rebuilt my project.
Complete instructions are here.
Update
This problem has been fixed in the latest version of the HMS Core. Try to upgrade the HMS Core apk to the latest version which may solve this issue.
Currently, the latest version of the HMS Core is 6.5.0.312.
Thank you for providing the information regarding this issue. We have reported this issue to the R&D team for handling, may i confirm is the HMS Core 6.4.0 installed on your device? You are advised to roll back to HMS Core 6.3 version apk. And we will release a patch package as soon as possible to fix this issue.
Testing on android 4.2.2, API 17 (simulated). This works with API 21+ (hard and simulated devices).
Caused by: com.amazonaws.AmazonServiceException: 1 validation error
detected: Value null at 'token' failed to satisfy constraint: Member
must not be null (Service: AmazonSNS; Status Code: 400; Error Code:
ValidationError; Request ID:
Using firebase token to register a device endpoint (to AWS SNS) with method below and getting error above. It fails on line
CreatePlatformEndpointResult cpeRes = client.createPlatformEndpoint(cpeReq);
Method:
private String createEndpoint() {
String endpointArn = null;
try {
System.out.println("Creating platform endpoint with token " + token);
CreatePlatformEndpointRequest cpeReq =
new CreatePlatformEndpointRequest()
.withPlatformApplicationArn(applicationArn)
.withToken(token);
CreatePlatformEndpointResult cpeRes = client.createPlatformEndpoint(cpeReq);
endpointArn = cpeRes.getEndpointArn();
} catch (Exception ipe) {
String message = ipe.toString();
System.out.println("Exception message: " + message);
Pattern p = Pattern
.compile(".*Endpoint (arn:aws:sns[^ ]+) already exists " +
"with the same token.*");
Matcher m = p.matcher(message);
if (m.matches()) {
// The platform endpoint already exists for this token, but with
endpointArn = m.group(1);
} else {
// Rethrow the exception, the input is actually bad.
throw ipe;
}
}
storeEndpointArn(endpointArn);
return endpointArn;
}
So after hours of playing with the code, the problem is not with the code, but with the emulator.
Google Play Services
To develop an app using the Google Play services APIs, you need to set
up your project with the Google Play services SDK.
If you haven't installed the Google Play services SDK yet, go get it
now by following the guide to Adding SDK Packages.
To test your app when using the Google Play services SDK, you must use
either:
A compatible Android device that runs Android 2.3 or higher and
includes Google Play Store. The Android emulator with an AVD that runs
the Google APIs platform based on Android 4.2.2 or higher.
So on API 17...
API 17 (Android 4.2-4.2.2) – Jelly Bean, released November 2012. Build
version code Android.OS.BuildVersionCodes.JellyBeanMr1
So, to emulate this on API 17 and up, open the SDK installer, and show package details. In the API version to be emulated, install all packages relating to Google APIs. This gives you an idea.
I'm trying to use Google cloud messaging for an android app (Target name: Google APIs, platform: 4.3, API level: 18. I implemented my GCM client by following the isntructions here: http://developer.android.com/google/gcm/client.html, and setup play services by following the steps here:
http://developer.android.com/google/play-services/setup.html#Setup, but still get the above error Most of the solutions I've found on stack overflow redirect to the above two links, or suggest that we change the dependencies {} in the gradle settings, but I'm using eclipse and don't have gradle setup.
Update: Sorry yes I'm using the emulator and not a device
Any ideas?Thanks!
If you need to provide an option for the user to update the google services you can do this:
switch (isGooglePlayServicesAvailable(this)) {
case 2: //out date
try {
GooglePlayServicesUtil.getErrorDialog(2, this, 0).show();
} catch (Exception e) {
e.printStackTrace();
}
break;
}
This will prompt an update dialog for the user to update play services
The final solution was creating a new emulator under Android 4.4.2, with the build target of the project set to Google APIs (x86 System Image). Thanks to Pedro Oliveira!
I crated android applciation uses gmaps, so play lib version is:
dependencies {
compile 'com.google.android.gms:play-services:4.0.30'
}
And following code works perfect on most of my devices:
markerOptions.position(latLng)
.anchor(0.5f, 0.5f)
.rotation(90)
But on one I have exception (Andrid 4.0.3) saing:
java.lang.NoSuchMethodError: com.google.android.gms.maps.model.MarkerOptions.rotation
And when I check Goolge Play Services lib accroding to this http://developer.android.com/google/play-services/setup.html
int resultCode = GooglePlayServicesUtil.isGooglePlayServicesAvailable(this);
if (ConnectionResult.SUCCESS == resultCode) {
Log.i("GSR", "GOOGLE PLAY SERVICES VERSION IS AVAILABLE");
return true;
}
I do see SUCCESS message in logs.
So what we have: the lib version is obviusly not up to date, but it could not identify this.
Solved, I don't know how, but old version of google play services lib was packing in apk, what I did is start SDK manager, removed play services lib and goolge repository packages, and install them again. After that apk begin to work.