Skip to content Skip to sidebar Skip to footer

Google Playstore App Version Check Not Working Any More

For force update I used to call the app url and check the for the html tag value but suddenly it stopped working there is no softwar

Solution 1:

I come up with a solution. When ever I am pushing a new version in the playstore I will add the version in the what's new, like this -

WHAT'S NEW

Version - 2.11.0
- New changes 1- New changes 2

And I look for this Version -

So Full code looks like this -

classVersionCheckTaskextendsAsyncTask<String, Void, String> {
    protectedString doInBackground(String... urls) {
        String mVer = "";
        String mData = "";

        try {
            URL mUrl = new URL(urls[0]);
            BufferedReader in = new BufferedReader(new InputStreamReader(mUrl.openStream()));
            String inputLine;
            while ((inputLine = in.readLine()) != null){
                if (inputLine == null)
                    break;
                mData += inputLine;
            }
            in.close();
        } catch (Exception ex) {
            ex.printStackTrace();
            returnnull;
        }

        /*
        * we are looking for this tag <div itemprop="description"><content>Version - 2.11.0<br>
        * We need to make sure every time we release a new version we should add the line in what's new -
        *
        * Version - 2.11.1
        *
        * - New changes 1
        * - New changes 2
        */String startToken = "Version - ";
        String endToken = "<";
        int index = mData.indexOf(startToken);

        if (index == -1) {
            mVer = null;

        } else {
            mVer = mData.substring(index + startToken.length(), index
                    + startToken.length() + 100);
            mVer = mVer.substring(0, mVer.indexOf(endToken)).trim();
        }
        return mVer;
    }

    protectedvoid onPostExecute(String store_version) {
        String currentVersion = "";
        try {
            PackageInfo pInfo = getPackageManager().getPackageInfo(getPackageName(), 0);
            currentVersion = pInfo.versionName;
        } catch (PackageManager.NameNotFoundException e) {
            Log.v(TAG, "Recv NameNotFoundException. Msg:" + e.getMessage());
        }

        Log.d(TAG, "store_version: " + store_version);
        Log.d(TAG, "device_version: " + currentVersion);

        if (store_version != null) {
            if (versionCompare(store_version, currentVersion) > 0) {
                dialog.setMessage(String.format(getResources().getString(R.string.update_message), getResources().getString(R.string.app_name), store_version));
                dialog.show();
            } else {
                showDisclaimer();
            }
        }
    }
}

publicint versionCompare(String storeVersion, String currentVersion) {
    String[] vals1 = storeVersion.split("\\.");
    String[] vals2 = currentVersion.split("\\.");
    int i = 0;
    // set index to first non-equal ordinal or length of shortest version stringwhile (i < vals1.length && i < vals2.length && vals1[i].equals(vals2[i])) {
        i++;
    }
    // compare first non-equal ordinal numberif (i < vals1.length && i < vals2.length) {
        int diff = Integer.valueOf(vals1[i]).compareTo(Integer.valueOf(vals2[i]));
        returnInteger.signum(diff);
    }
    // the strings are equal or one string is a substring of the other// e.g. "1.2.3" = "1.2.3" or "1.2.3" < "1.2.3.4"returnInteger.signum(vals1.length - vals2.length);
}

Solution 2:

Maybe, at the end of march, Google changed Play store's HTML Code.

The structure of additional information has also changed.

Some developers, including me, use Jsoup to check for the latest version in the Play Store.

Perhaps you were using code like this:

    Document doc = Jsoup.connect
("https://play.google.com/store/apps/details?id=name.package.your").get();
    Elements Version = doc.select(".content");
    for (Element v : Version) {
        if (v.attr("itemprop").equals("softwareVersion")) {
            VersionMarket = v.text();
        }
    }

but, after play store's change, your code return null.

because, "itemprop" and "sofrwareVersion" is gone, like that.

enter image description here

So, you need a new way to parse the version of your app in Google Play store's ADDITION INFORMATION with Jsoup.

try {
    Document doc = Jsoup
            .connect(
                    "https://play.google.com/store/apps/details?id=name.package.your")
            .get();

    Elements Version = doc.select(".htlgb ");

    for (int i = 0; i < 5 ; i++) {
        VersionMarket = Version.get(i).text();
        if (Pattern.matches("^[0-9]{1}.[0-9]{1}.[0-9]{1}$", VersionMarket)) {
            break;    
        }
    }

The above code works as follows.

  1. Parsing play store's your app page.
  2. Selecting all "htlgb" contents.

    • like in image, "3 March 2018", "1,000+" "2.0.4", "4.4 and up, etc."
  3. In [for Loop], [Regex] finds a value matching your version pattern (like 2.0.4) and stops.

  4. VersionMarket is your "app version" and you can use it.

//2018-08-04 Add Comment

For some reason, the code above returns information about "Installs" instead of "version information".

Therefore, if you modify the code as shown below, you can return "version information" again.

try {
    Document doc = Jsoup
            .connect(
                    "https://play.google.com/store/apps/details?id=name.package.your")
            .get();

    Elements Version = doc.select(".htlgb ");

    for (int i = 0; i < 10 ; i++) {
        VersionMarket = Version.get(i).text();
        if (Pattern.matches("^[0-9]{1}.[0-9]{1}.[0-9]{1}$", VersionMarket)) {
            break;    
        }
    }

The above code changed the number in "for break" from 5 to 10.

Because the number of "htlgb" codes has changed in Google Play Store's HTML Code.

Solution 3:

No, no API exists for checking your app version on Play. Instead, you could implement a solution using Firebase Remote Config, then you have much more control over the minimum version your users see.

Post a Comment for "Google Playstore App Version Check Not Working Any More"