javiersantos / AppUpdater

A library that checks for your apps' updates on Google Play, GitHub, Amazon, F-Droid or your own server. API 9+ required.
Apache License 2.0
1.99k stars 413 forks source link

Never new version #97

Closed EnzChe closed 7 years ago

EnzChe commented 7 years ago
Details
Actual Code
// Auto Updater
        AppUpdaterUtils appUpdater = new AppUpdaterUtils(this)
                .setUpdateFrom(UpdateFrom.JSON)
                .setUpdateJSON(getResources().getString(R.string.config_update_link))
                .withListener(new AppUpdaterUtils.UpdateListener() {
                    @Override
                    public void onSuccess(Update update, Boolean isUpdateAvailable) {
                        if (isUpdateAvailable) {
                            Log.d("__________", "1 - It's working");
                        } else {
                            Log.d("__________", "2 - It's nearly working");
                        }
                    }

                    @Override
                    public void onFailed(AppUpdaterError error) {
                        Log.d("AppUpdater Error", "Something went wrong" + error);
                    }
                });
        appUpdater.start();
{
latestVersion: "0.0.3",
latestVersionCode: "1",
url: "http://***.***.com/api/download-apk",
releaseNotes: [
"Ajout du droit d'écriture dans dossier APK backoffice"
]
}
Expected Result

It's nearly working on Logs.

Actual Result

The application never detect new versions, when I call 'update.getLatestVersion()' the latest version is 0.0.3 (the real latest version on my server), and when I go in device, App properties the App version is 0.0.1. So why the 'isUpdateAvailable' is false ?

EnzChe commented 7 years ago

Ok I got it. I am actually using com.toptoche.searchablespinnerlibrary.

And this library got a BuildConfig class containing VERSION_NAME = "1.3.1"; My app was installed at 0.0.1 and for testing I tested with 0.0.2 & 0.0.3.

Seems like AppUpdater was taking the current version of app installed is "1.3.1" and not "0.0.1". Because when I upload the new version on server over than 1.3.1+, then the listener is correctly working.

javiersantos commented 7 years ago

I think your issue is related with this, as explained in the WIKI.

If latestVersionCode is included in the JSON, latestVersion will only be used to display the latest version in the dialog and the versionCode will be used to compare the installed and latest update.

Do increasing the versionCode solve your issue?