1

I am trying to implement google's in-app updates. When trying to run the app directly from AndroidStudio I got this exception:

com.google.android.play.core.install.InstallException: Install Error(-10): The app is not owned by any user on this device. An app is "owned" if it has been acquired from Play. (https://developer.android.com/reference/com/google/android/play/core/install/model/InstallErrorCode#ERROR_APP_NOT_OWNED)

I understand that google can't check for updates when the app wasn't installed from the play store. My goal is to disable this feature while the app is in a testing build that isn't installed from the play store because in these situations I don't care about app updates anyway.
How can I disable this check depending on the build flavor?

I have already read this guide but it doesn't mention anything that does what I want.

2 Answers2

2

just define in app/build.gradle some property for each build type

buildTypes {
    debug {
        buildConfigField 'boolean', 'UPDATE_ENABLED', 'false'
    }
    release {
        buildConfigField 'boolean', 'UPDATE_ENABLED', 'true'
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}

after synchronization you can request if(BuildConfig.UPDATE_ENABLED) and there check for update

anatoli
  • 1,663
  • 1
  • 17
  • 43
  • Because the stacktrace of the exception didn't contain any refrences to my code I thought this wouldn't work because the check was automatically called somewhere else. Turns out I was wrong. My bad. – AndroidKotlinNoob May 21 '21 at 07:23
  • What's the reason to create a new variable if we can simply use `if(!BuildConfig.DEBUG)` ? – Dmitriy Mitiai May 04 '22 at 08:46
1

Google Play checks update availability with your package name. If you use a different package name than the one in the store, the in-app-update update check result will be false.

buildTypes {
        getByName("debug") {
            applicationIdSuffix = ".debug"
            ...
        }
}

OR:

buildTypes {
        debug {
            applicationIdSuffix = ".debug"
            ...
        }
}
Asaf
  • 61
  • 2