
我不断收到错误,例如:INSTALL_FAILED_CONFLICTING_PROVIDER或INSTALL_FAILED_DUPLICATE_PERMISSION
解决方法 如果您只使用构建类型而不是风味,则在同一设备上安装调试apk和发行版apk很棘手( Why Build types and not flavors)大多数博客文章要么过时(谈论packagename),要么是force you to use flavors,因为他们提出的解决方案不支持applicationIDSuffix,而构建类型不能声明applicationID,因此你需要使用一种风格
我建议使用的解决方案
>每种构建类型的权限
>每种构建类型的帐户类型
>每种构建类型的GCM权限
为此,我在Gradle文件中使用applicationIDSuffix,manifest placeholders,BuildConfigFIEld和resValue.
剩下的唯一问题是当你想为app和每种语言设置一个不同的名字时,字符串不会被设置为可翻译(bug aosp tracker)
这会强制您将abortOnError设置为false,否则您将无法进行发布构建.
的build.gradle
project.ext { defaultApplicationID = "com.myapp.package"}androID { compileSdkVersion 23 buildToolsversion "23.0.1" defaultConfig { applicationID defaultApplicationID manifestPlaceholders = [ applicationIDWithSuffix: "${applicationID}" ] buildConfigFIEld "String","ACCOUNT_TYPE","\"${applicationID}\"" buildConfigFIEld "String","AUTHORITY","\"${applicationID}.provIDer\"" resValue "string","account_type","${applicationID}" resValue "string","authority","${applicationID}.provIDer" } buildTypes { deBUG { applicationIDSuffix ".deBUG" deBUGgable true manifestPlaceholders = [ applicationIDWithSuffix: defaultApplicationID + ".deBUG" ] buildConfigFIEld "String","\"${defaultApplicationID}.deBUG\"" buildConfigFIEld "String","\"${defaultApplicationID}.deBUG.provIDer\"" resValue "string","${defaultApplicationID}.deBUG" resValue "string","${defaultApplicationID}.deBUG.provIDer" } } lintoptions { abortOnError false }} AndroIDManifest.xml中
<manifest xmlns:androID="http://schemas.androID.com/apk/res/androID" package="com.mypackage" > <permission androID:name="${applicationIDWithSuffix}.permission.C2D_MESSAGE" androID:protectionLevel="signature" /> <uses-permission androID:name="${applicationIDWithSuffix}.permission.C2D_MESSAGE" /> <application androID:label="@string/app_name" > <provIDer androID:name=".MyContentProvIDer" androID:authoritIEs="${applicationIDWithSuffix}.provIDer" androID:exported="false" androID:multiprocess="true" /> </application></manifest> 同步适配器xml
<sync-adapter xmlns:androID="http://schemas.androID.com/apk/res/androID" androID:contentAuthority="@string/authority" androID:accountType="@string/account_type"/>
帐户验证者
<account-authenticator xmlns:androID="http://schemas.androID.com/apk/res/androID" androID:accountType="@string/account_type" .../>
内容提供商
我有一个常量,用于从BuildConfig获取它.
AUTHORITY = BuildConfig.AUTHORITY
帐户类型
要获取帐户类型,您也可以从BuildConfig中获取它.
BuildConfig.ACCOUNT_TYPE
多语言应用名称
如果你想要每个应用程序不同的名称和语言:
调试/值恩/ strings.xml中
<resources> <string name="app_name">MyApp deBUG EN</string></resources>
调试/值-FR / strings.xml中
<resources> <string name="app_name">MyApp deBUG FR</string></resources>
主/值恩/ strings.xml中
<resources> <string name="app_name">MyApp EN</string></resources>
主/值-FR / strings.xml中
<resources> <string name="app_name">MyApp FR</string></resources>总结
以上是内存溢出为你收集整理的Android Gradle:在一台设备上安装所有构建类型全部内容,希望文章能够帮你解决Android Gradle:在一台设备上安装所有构建类型所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)