ctacke
ctacke

Reputation: 67198

APK not compatible with newest Android build

I am working onan app that is currently published on the Play Store. When using an Android device with version 5.1.1 on it, the play store says "Your device isn't compatible with this versions" and I'm trying to determine the specific reason why and how to work around it.

The existing app's Android.Manifest file has the following in it:

  <uses-sdk minSdkVersion="13" targetSdkVersion="21"/>

I thought that maybe it was the "targetSDKVersion" causing the problem. I don't have the APK that was originally published, but I figured I could test my hypothesis by generating a new app with the same uses-sdk manifest items.

I created a new app with the latest Android Studio and the same uses-sdk values and published it, and strangely it is available on my 5.1.1 device.

I decided to investigate further and I pulled both APKs down to my desktop and then used apktool to extract the contents of each to see if anything stood out.

What I did find is that the non-working APK has this in the extracted manifest:

<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.redphx.deviceid" platformBuildVersionCode="21" platformBuildVersionName="5.0.1-1624448">

And the working APK has the following

<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.opennetcf.ctacke.androidsample" platformBuildVersionCode="23" platformBuildVersionName="6.0-2166767">

Right now my assumption is that the platformBuildVersionCode must be the culprit.

So my questions are:

  1. Is my assumption correct, that this is why one APK is not working for 5.1.1?
  2. I assume the APK compiler sets the platformBuildVersionCode attribute. I specifically set the targetSdkVersion to 21 in the working application, and I see that value in the extracted yml, but the platformBuildVersionCode still says 23. Where does that information come from, if not the uses-sdk information?
  3. Is there a fix, short of rebuilding a new APK and re-publishing?

I assume that re-publishing is the likely route, but I'm hoping to head off having this problem recur in the future, so I'd really like to understand the answers to #1 and #2.

update

The merged manifest for the working APK is the same as what is in the application itself, so no reference to 23 at all.

<uses-sdk 
    minSdkVersion="13" 
    targetSdkVersion="21"/>

On the working system, build.gradle contains the following:

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.1"

    defaultConfig {
        applicationId "com.opennetcf.ctacke.androidsample"
        minSdkVersion 13
        targetSdkVersion 21
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnable false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro
        }
    }
}

dependencies {
    compile filetree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:23.0.1'
}

So I assume that this is where that info comes from, but how it gets to the APK still isn't all that clear.

I don't have either for the non-working APK since it was built by the app release team before I came on the project and I have no idea if they keep any of these intermediate outputs. I'm investigating that.

edit 2

The extracted yml from both APKs (which shows the uses-sdk info) is below. It looks like the non-working minimum version is significatly lower (5) than the working (13).

working:

version: 2.0.1
apkFileName: oncf.apk
isFrameworkApk: false
usesFramework:
  ids:
  - 1
sdkInfo:
  minSdkVersion: '13'
  targetSdkVersion: '21'
packageInfo:
  forced-package-id: '127'
versionInfo:
  versionCode: '1'
  versionName: '1.0'
compressionType: false
sharedLibrary: false

non-working:

version: 2.0.1
apkFileName: ytb.apk
isFrameworkApk: false
usesFramework:
  ids:
  - 1
sdkInfo:
  minSdkVersion: '5'
  targetSdkVersion: '21'
packageInfo:
  forced-package-id: '127'
versionInfo:
  versionCode: '4'
  versionName: 1.1.2
compressionType: false
sharedLibrary: false

Upvotes: 2

Views: 2459

Answers (1)

Stephan Branczyk
Stephan Branczyk

Reputation: 9375

Unless you have a very specific reason for doing it, your targetSdkVersion needs to match your compileSdkVersion

Also, you'll need to increment the versionCode (I can see this was done in the published apk, but this wasn't done in the rest of the build.gradle file you just gave us)

If your original manifest file still contains the minSdkVersion and the targetSdkVersion attributes, you can delete those. Those two attributes will now be coming from your build.gradle file to create the intermediary manifest. This is the new way Android is doing it.

Also, your proguard-rules.pro reference is missing a single quote on its right. I assume this must be some kind of cutting and pasting error.

Upvotes: 1

Related Questions