Android Flavors, ContentProviders, SyncAdapters, and AccountManager

I have defined several options and buildTypes for my Android application.

productFlavors {
    X {
        applicationId = "com.x.xxxx"
    }
    Y {
        applicationId = "com.y.yyyy"
    }
}

buildTypes {
    release {
        minifyEnabled true
        proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard_rules.txt'                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     
    }

    debug {
        applicationIdSuffix ".debug"
    }
}

This does the job of creating various flavors / buildType combinations.

Now, to make sure that ContentProvidersis working, and I did not get an error Failure [INSTALL_FAILED_CONFLICTING_PROVIDER], I changed the link android:authorities="${applicationId}"and AUTHORITYcode to BuildConfig.APPLICATION_ID.

This makes the work ContentProviderworkable, i.e. it does not give an error when installing two different types on the same phone. This allows me to install them.

- . SyncAdapter AccountManager . ACCOUNT_TYPE, APPLICATION_ID. - gradle, ${applicationId} , syncadapter.xml authenticator.xml AUTHORITY account type.

, - http://blog.jensdriller.com/android-gradle-workaround-for-missing-placeholder-support-in-resource-files/

gradle , ContentProvider , .

- ?

+4

Source: https://habr.com/ru/post/1584123/


All Articles