androidandroid-developer-apiin-app-update

Why In-App Upgrade is Not Working? Why its not going to onSuccss() method?


I am showing rating popup on a different interval in my App and after the upgrade, I want to show rating popup from starting interval. For that, I have to reset its config on upgrade.

I have implemented In-App Upgrade in my App but for some reason that I don't know why it's not working can someone help me with this? It's not going to onSuccess method. I checked the developer doc, but still wondering how its checking update available or not??

Checked-in Debug & Jenkins generated apk. Is there anything that I need to look out for?

private void checkUpdate(final boolean mustUpdate){
    appUpdateManager = AppUpdateManagerFactory.create(this);
    Task<AppUpdateInfo> appUpdateInfo = appUpdateManager.getAppUpdateInfo();
    appUpdateManager.registerListener(this);
    appUpdateInfo.addOnSuccessListener(new OnSuccessListener<AppUpdateInfo>() {
        @Override
        public void onSuccess(AppUpdateInfo appUpdateInfo) {
            if(appUpdateInfo.updateAvailability() == UpdateAvailability.UPDATE_AVAILABLE){
                if(mustupdate){
                    try {
                        appUpdateManager.startUpdateFlowForResult(
                                appUpdateInfo,
                                IMMEDIATE,
                                MainActivity.this,
                                APP_UPDATE_REQUEST_CODE);
                    } catch (IntentSender.SendIntentException e) {
                        e.printStackTrace();
                    }
                }else{
                    try {
                        appUpdateManager.startUpdateFlowForResult(
                                appUpdateInfo,
                                FLEXIBLE,
                                MainActivity.this,
                                APP_UPDATE_REQUEST_CODE);
                    } catch (IntentSender.SendIntentException e) {
                        e.printStackTrace();
                    }
                }
            }
        }
    });

}

Solution

  • Before working on In-App update there are few points you have to keep in mind:

    1. You will get the event only when for your applications is live which means a lower version of your app should be there in Playstore.

    2. If net was not there in the phone and new apk was uploaded then also your phone will not get the update.

    3. for above point you have to make sure that your phone's playstore is synced with server when internet is working fine.

    4. You may need to clear cache and data of the Google Play Store app on your device. Go to: Settings → Applications → Application manager (or find the Google Play Store in the list) → Google Play Store app → Clear Cache, Clear Data.

    5. for more information please check the link in official site of google developer.

    Hope it helps.

    Thank you!