Skip to content
This repository has been archived by the owner on Mar 16, 2021. It is now read-only.

Custom Authority

Victor Tseng edited this page Jun 11, 2017 · 3 revisions

Change authority

Tray uses <applicationId>.tray as authority for the internal ContentProvider. If you don't want to use the "default" authority you can define your own with the following code inside your AndroidManifest:

<provider
    android:name="net.grandcentrix.tray.provider.TrayContentProvider"
    android:authorities="your.custom.authority"
    android:exported="false"
    tools:replace="android:authorities" />

Changing the authority from one app version to another app version is no problem! Tray always uses the same database.

Warning: Authority conflict

A ContentProvider requires a unique authority across all installed apps. When you use the same authority for multiple apps you will be unable to install the app due to a authority conflict with the error message:

Failure [INSTALL_FAILED_CONFLICTING_PROVIDER]

Make sure you set a different authority for debug and release builds as well as different build flavors.

Different applicationIds for different buildType of flavors

If you are using different applicationIds for different buildTypes of flavors, there are several methods to overcome this problem:

  1. If you only want to separate debug and release build or distinct between different flavors, read this article.
  2. If you want to have {applicationId}[.flavor][.buildType], you may use the buildVariant overlay by
    1. removing all resValue ... lines from build.gradle
    2. create strings.xml for each overlays (such as flavor1, flavor1Debug, flavor2, flavor2Debug)
    3. specifying <string name="tray__authority">your.application.id.flavor.buildType.tray</string> in each strings.xml
    4. NOTE for this method, you would have to create the appropriate strings.xml for every buildVariant, or it fall-back to defaultVariant.