How to emulate outdated SSL Provider on Android? - android

I'm implementing 'Update security provider' feature for an Android application.
I implemented as it said in 'Patch asynchronously' and need to test/emulate all outcomes: user prompt demonstration and the error is unrecoverable.
I tried to delete Play Store updates, use previous com.google.gms:google-services version or android 6.0 — it always silently goes to onProviderInstalled(), never shows prompt or goes to onProviderInstallFailed().
I did exactly as said at https://developer.android.com/training/articles/security-gms-provider#example_async
Also in android\build.gradle:
buildscript {
...
dependencies {
...
classpath("com.google.gms:google-services:4.3.3")
}
}

Related

com.google.android.gms.common.api.ApiException: 17: API: Games.API is not available on this device

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.

cannot send crash report after setting up react native crashlytics for android

I feel like I have tried every possible combination of ways to report a crash on the firebase crashlytics console for the android side of my react-native application.
I have followed the rnfirebase setup instructions and triple checked that everything is where it should be: https://rnfirebase.io/crashlytics/android-setup
I have read in several forums that the app needs to be run in 'release' mode for the crash to be reported and then the app must be closed and opened once again for the report to be sent, I have done this multiple times:
firstly i've tried:
./gradlew installRelease
secondly I tried a method recommended in a github issue forum:
./gradlew assembleRelease
adb install ./app/build/outputs/apk/release/app-release.apk
both methods ran on my emulator and I was able to use the crashlytics().crash() method to cause a crash, alas nothing appears in the console.
I have also added this into a firebase.json file in the root of my project like the docs explain:
{
"react-native": {
"crashlytics_debug_enabled": true
}
}
any help is greatly appreciated as I really don't know where the issue lies.
PS. I have registered my app with the FB console and enabled crashlytics
in firebase.json
{
"react-native": {
"crashlytics_disable_auto_disabler": true,
"crashlytics_debug_enabled": true
}
}
make sure that crashanalytics sdk is installed/initialised
follow: https://rnfirebase.io/crashlytics/android-setup

Full offline option using AWS DataStore and then allow an optional activation for the the cloud sync features in Android

I've started a project using AwsAppsync.
The app is going to be offline first. And we want to offer the option to sync in the cloud as an extra option later if the customer wants it. So, I configured my project like this:
In build.gradle added the following:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.6.2'
classpath 'com.amplifyframework:amplify-tools-gradle-plugin:0.2.1'
}
}
apply plugin: 'com.amplifyframework.amplifytools'
And added those dependencies:
implementation 'com.amplifyframework:core:0.10.0'
implementation 'com.amplifyframework:aws-api:0.10.0' // If using cloud sync
implementation 'com.amplifyframework:aws-datastore:0.10.0'
And then using the Amplify CLI:
copy
Generate models at any time by executing this Amplify CLI command:
amplify codegen models
After this in the onCreate of the activity:
ModelProvider modelProvider = AmplifyModelProvider.getInstance();
Amplify.addPlugin(AWSDataStorePlugin.forModels(modelProvider));
Amplify.configure(getApplicationContext());
With this i can Query, update and delete the data.
Is this enough for a full offline experience?
Now, based on the documentation, to add online sync feature, I have to do the following:
Using the Amplify CLI:
amplify push
This will create the amplifyconfiguration.json with the sync configuration.
Now, this information seems to be set in build time. So, how can I enable/disable this feature to be used just when I need it? The documentation mention the following:
ModelProvider modelProvider = AmplifyModelProvider.getInstance();
Amplify.addPlugin(AWSDataStorePlugin.forModels(modelProvider));
Amplify.addPlugin(new AWSApiPlugin()); // If using remote model synchronization
Amplify.configure(getApplicationContext());
So, would be adding that "new AWSApiPlugin()" the only thing I need to do to enable/disable this feature? Thanks!
Any tutorial/book good enough to explain this? I've read several documentation(including the official) and I wasn't able to find something about this particular case. It is always with online sync from the get go.
From a high level, yes this is fairly accurate. DataStore doesn't require a backend it will just work as a local DB of sorts that you can use for offline including queries. When you add in a backend with amplify push (this deploys an AppSync API backed by DynamoDB) and connect it with AWSApiPlugin it will begin syncing. The best tutorial is in the docs: https://docs.amplify.aws

Verify non-Google Play app installs using Play core library

Some context: Most of us may have faced this ResourceNotFoundException when we migrated to Android app bundle release method. It is evident that the issue is because of Side-loading the app. Reference here.
Google recently announced solution to this problem. Using play core library we can identify whether the app is side-loaded or not (Identifies the missing split apks). If the app is side-loaded it shows "Installation failed" popup and redirects to play store, where user can properly install the app via the Google Play store.
Problem: Everything works fine until the installation of missing split apks from play store. Now when I relaunch the app, it immediately crashes with an error saying.
Default FirebaseApp is not initialised in this process
Note: Directly downloading the app from play store works perfectly fine without any crash. The crash happens only when the app re-downloads because of side loading issue.
Code:
Project's build.gradle:
buildscript {
dependencies {
classpath 'com.android.tools.build:bundletool:0.9.0'
}
}
App module's build.gradle:
implementation 'com.google.android.play:core:1.6.1'
Class that extends Application:
public void onCreate() {
if (MissingSplitsManagerFactory.create(this).disableAppIfMissingRequiredSplits()) {
// Skip app initialization.
return;
}
super.onCreate();
.....
}
Any help would be really great.
I have solved this issue with the latest version of Play core library:
App module's build.gradle:
implementation "com.google.android.play:core:1.7.2"
Other implementation remains same.
A class that extends Application:
public void onCreate() {
if (MissingSplitsManagerFactory.create(this).disableAppIfMissingRequiredSplits()) {
// Skip app initialization.
return;
}
super.onCreate();
.....
}
How to test:
A better way to test it properly is to release the app bundle with these above fixes in play store internal test channel (Add yourself as a tester).
Simulate installing invalid apks - Use bundletool to get .apks file out of bundle, extract it and install base_master.apk using adb command
adb install base_master.apk.
Launch the app, you should see "Installation failed" dialog and it redirects to Play store, clicking on Update, play store will install the missing apks.
Launching the app should work properly by now.
Hope this helps

Android App Users Get "App not installed" When Attempting to Update

UPDATE: To those who asked about which error codes the users are receiving: there are no error codes. It just opens a blank, post-installation page that says "The app was not installed" with a big 'X' next to it. It's possible different versions of Android could have different messages. There is no indication for what went wrong during the installation.
UPDATE 2: Some users reported that they receive error code "-504" when they try to install/update from the Play Store, and the "app not installed" message when manually trying to install the .apk. I don't know what correlation this error has with users being unable to install, but the solutions from the only 2 questions on SO on this topic did not fix anything for me. I've included the updated manifests and build files.
UPDATE 3: It appears as users report this issue in versions after IAB has been successfully installed, which further de-legitimatizes the concept that this issue is caused by introducing IAB.
UPDATE 4: It looks like the problem is with old users trying to update to a new version, and not with new users. With that in mind, there is a high likelihood that this issue is result of INSTALL_FAILED_UID_CHANGED. Looking through the version history, the significant change I made in the problematic version that users cannot update from is removing drawables that I no longer intended of using.
Asking users to go through the procedure to fix this isn't plausible. If there is a solution that I can enforce which would fix it for faulty users, wonderful... if not, the least I can do at this point is damage control and ensure this doesn't happen in the future.
NOTE: Below is the original post speculating that the problem is the result of introducing IAB into the app. Since then, it has become more and more unlikely for that to be the cause. Regardless, the post still has relevant information.
------------------------------------------------------------------------------------------
Original Title: Android App Users Get "App not installed" After Introducing IAB
I recently introduced IAB in my app that was published on Google Play. After a while, I've started to get reports from some users that they get an "installation unsuccessful" error when they try to install or update it.
What makes me think it's caused by introducing IAB is that one particular long-time user e-mailed me that when he's attempting to update to the version with IAB, the installer mentions that new permissions were introduced and requires the user's permission. Once granted, it says that the app failed to install.
I've done some Googling and it appears to be a problem from their end, one user even tried to manually install an .apk with said permissions removed without any success. I wan't to make sure that it's not something I've done wrong, but an inevitability that I have to accept with some users.
Note that the vast majority has no problem of installing the app, and I haven't received any reports of this until after IAB was introduced. It wouldn't bother me so much were it a small amount of lost users, but the problem is, those users hurt my app's rating. Users have also mentioned that they can install apps, excluding my own, perfectly well.
I don't rule out the possibility that users may have been getting these errors even before IAB was introduced, and the linkage could be a mistaken one.
Here is my manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest package = "com.jjsoftware.fullscientificcalculator"
xmlns:android = "http://schemas.android.com/apk/res/android">
<uses-permission android:name = "android.permission.VIBRATE"/>
<uses-permission android:name = "com.android.vending.BILLING"/>
<application
android:allowBackup = "true"
android:fullBackupContent = "true"
android:icon = "#drawable/logo"
android:label = "#string/app_name">
<activity
android:name = ".MainActivity"
android:hardwareAccelerated = "false"
android:label = "#string/app_name"
android:screenOrientation = "portrait"
android:theme="#style/AppTheme">
<intent-filter>
<action android:name = "android.intent.action.MAIN"/>
<category android:name = "android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<activity
android:name = ".SettingsActivity"
android:theme = "#style/PreferencesTheme">
<intent-filter>
<action android:name = ".SettingsActivity"/>
<category android:name = "android.intent.category.PREFERENCE"/>
</intent-filter>
</activity>
</application>
Here is the Gradle file:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
applicationId "com.jjsoftware.fullscientificcalculator"
minSdkVersion 14
targetSdkVersion 23
versionCode 102
versionName "1.679"
}
sourceSets { main { assets.srcDirs = ['src/main/assets', 'src/main/assets/'] } }
}
dependencies {
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.google.android.gms:play-services-ads:8.4.0'
compile 'com.android.support:gridlayout-v7:23.2.1'
compile files('libs/exp4j-0.4.5.jar')
compile files('libs/EJML-core-0.28.jar')
compile files('libs/EJML-dense64-0.28.jar')
compile files('libs/Jama-1.0.3.jar')
compile files('libs/EJML-simple-0.28.jar')
}
And, if need be, the top-level build:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.5.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
There is a typo in the manifest file on line android:largeHeap="true">>. xml line ends with >>. This may be causing the error.
it could be the phones have a lower version of the Google play services than the minimum you defined in the APK.
There is nothing much you can do if that is the case, other than for the users to upgrade their google services (https://play.google.com/store/apps/details?id=com.google.android.gms&hl=en) or you reduce your version.
also you may need to add the following to your manifest. (i think this is used to compare the versions installed in the phones with the versions required by the apk)
<application ...>
<!-- This meta-data tag is required to use Google Play Services. -->
<meta-data
android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version" />
</application>
I got this error while installing on my Android device a new APK for the app I am developing.
I checked the debug log on the device (using "adb -d logcat > log.txt") and found an entry saying "PackageManager: Downgrade detected: Update version code 2 is older than current 10000". Obviously something went wrong with the versioning somehow.
I uninstalled the package and then was able to install the APK with no problems.
Remember that the latest installment of Android (Marshmallow version) has changed the permissions to give more access to permissions to the user. Hence it is not enough to define the permissions in the manifest anymore.
Through code you need to make sure that the billing permission is enabled by the users when they use the app. The simplest way to go around this is to set the target SDK to v-22. This should temporarily solve your issue.
The real solution however is to handle the new permissions introduced in Marshmallow. Here is how to do it:
#Override
public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
switch(requestCode) {
case BILLING_REQUEST:
if (canAccessBilling()) {
callBillingPerms();
}
break;
}
}
private void callBillingPerms() {
Toast.makeText(this, "We need your permission to access Billing", Toast.LENGTH_SHORT).show();
}
private boolean canAccessSMS() {
return(hasPermission(Manifest.vending.BILLING));
}
#TargetApi(Build.VERSION_CODES.M)
private boolean hasPermission(String perm) {
return(PackageManager.PERMISSION_GRANTED==this.checkSelfPermission(perm));
}
Hope this helps :)
Perhaps the error is on the user's side.
This article states the following:
Google Play - Error 504
Problem
App could not be downloaded due to an error.
First solution
The usual, please: go to Settings > Apps > All > Google Play Store and Clear cache and Clear data. Also Clear cache and Clear data for Google Services Framework.
Second solution
Try removing your GMail account
This Stack Exchange answer discussed similar ideas.
According to the list of status codes at Wikipedia, a 504 error means the following:
504 Gateway Timeout
The server was acting as a gateway or proxy and did not receive a timely response from the upstream server.
Ask your users if doing the above solves their issue.

Categories

Resources