我为我的Android应用程序定义了一些版本和buildTypes
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"
}
}
这可以创建不同的flavor / buildType组合。
现在为了确保ContentProviders
有效并且我没有收到Failure [INSTALL_FAILED_CONFLICTING_PROVIDER]
错误,我已将代码中的android:authorities="${applicationId}"
和AUTHORITY
引用更改为{{1} }。
这使得BuildConfig.APPLICATION_ID
工作正常,但是当我在同一部手机上安装两种不同类型时,它不会引发错误。它让我安装它们。
下一步是错误发生的地方。我使用ContentProvider
和SyncAdapter
来控制一些事情。我修改了AccountManager
以使用ACCOUNT_TYPE
。由于gradle无法在非清单xml资源文件中使用APPLICATION_ID
的问题,我为每种风格创建了不同的目录结构,并将${applicationId}
和syncadapter.xml
复制到相应的authenticator.xml
和authority
字符串。
我也尝试过本博客中描述的技术 - http://blog.jensdriller.com/android-gradle-workaround-for-missing-placeholder-support-in-resource-files/
而Using build types in Gradle to run same app that uses ContentProvider on one device的最高投票答案,但事情似乎不起作用。
最近有人能够让它上班吗?