diff --git a/app/build.gradle b/app/build.gradle index 10a26fc456..6e53b5b014 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -9,8 +9,8 @@ android { applicationId "org.ole.planet.myplanet" minSdkVersion 21 targetSdkVersion 34 - versionCode 1664 - versionName "0.16.64" + versionCode 1665 + versionName "0.16.65" ndkVersion '21.3.6528147' testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" vectorDrawables.useSupportLibrary = true diff --git a/app/src/main/java/org/ole/planet/myplanet/utilities/VersionUtils.kt b/app/src/main/java/org/ole/planet/myplanet/utilities/VersionUtils.kt index a4ae1ebbc2..3d987fd3ab 100644 --- a/app/src/main/java/org/ole/planet/myplanet/utilities/VersionUtils.kt +++ b/app/src/main/java/org/ole/planet/myplanet/utilities/VersionUtils.kt @@ -2,14 +2,21 @@ package org.ole.planet.myplanet.utilities import android.content.Context import android.content.pm.PackageManager +import android.os.Build import android.provider.Settings +import androidx.core.content.pm.PackageInfoCompat.getLongVersionCode object VersionUtils { @JvmStatic fun getVersionCode(context: Context): Int { try { val pInfo = context.packageManager.getPackageInfo(context.packageName, 0) - return pInfo.versionCode + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) { + return getLongVersionCode(pInfo).toInt() + } else { + @Suppress("DEPRECATION") + return pInfo.versionCode + } } catch (e: PackageManager.NameNotFoundException) { e.printStackTrace() }