Nic Capdevila Nic Capdevila - 12 days ago 5
Android Question

Android Play Store Error -505

When uploading an APK to the Android Developer Console, everything goes normal, but there are a certain subset of users on android 5.0 and up that are unable to install or upgrade the APK. These users see a Google Play Store error 505.

Answer

There are several different resources that tell you that the 505 error is a conflict of permission. Starting in Android Lollipop, you are no longer able to have duplicate custom permissions with the same name https://developer.android.com/about/versions/android-5.0-changes.html#custom_permissions. If you check stackoverflow for this error you'll find multiple reports of people offering this as a solution. While this can sometimes be the cause of this error there are several other reasons that this, and other conflicts can happen.

1. More than one app defines the same permission

If two completely different apps define the same permission e.g if you have a user and a manager app, and both of them have something along the lines of:

<permission
        android:name="same.package.name.permission.C2D_MESSAGE"
        android:protectionLevel="signature" />

2. Same app signed by different keys

You have the same app, but signed by different keys. For example if you had a release version and a debug version, you'll hit a conflict because the system sees this as two different apps requesting the same permission.

3. Conflicting authorities

But there is an entirely different situation that can occur, which is less obvious. The 505 error can also occur with conflicting authorities. If two different apps declare the same provider, such as

<provider
    android:name=".provider.YourProvider"
    android:authorities="com.roqbot.client.YourProvider"
    android:exported="false" />

This can also provide a conflict.

The last, and hardest conflict to spot, is one that can happen with Google Play Services 8.1 and up. If you do not define an application id in your build.gradle file like this:

defaultConfig {
    applicationId "com.example.my.app"
}

it is possible that it will auto-generate a provider that can conflict with other apps. To check this, go into your your build>intermediates>manifests>full>release>AndroidManifest.xml and look for

<provider
    android:name="com.google.android.gms.measurement.AppMeasurementContentProvider"
    android:authorities="com.google.android.gms.google_measurement_service"
    android:exported="false" />

Here the authority name will conflict with other apps. If you add the applicationId to the default config, it will change this authority to

<provider
    android:name="com.google.android.gms.measurement.AppMeasurementContentProvider"
    android:authorities="com.example.my.app.google_measurement_service"
    android:exported="false" />

This is very subtle and appears to be a bug starting in google play services 8.1. The issue can be seen discussed here. https://code.google.com/p/android/issues/detail?id=189079&can=1&q=error%20505&sort=-opened&colspec=ID%20Status%20Priority%20Owner%20Summary%20Stars%20Reporter%20Opened

The point to remember is that it may be several things, and the only thing you can verify for sure with a 505 error is that there is a conflict of some sort, and that it may or may not necessarily be a custom permission conflict.