我正在使用 Android Studio 来构建我的应用程序。我想用gradle
构建类型。我使用 applicationIdSuffix 在包名称中添加后缀,以修改测试构建类型的包名称。
buildTypes {
debug {
runProguard false
proguardFile 'proguard-rules.txt'
applicationIdSuffix '.dev'
versionNameSuffix '-dev'
}
}
是否可以在 xml 文件中使用此信息。我的计划是修改帐户类型:
<account-authenticator xmlns:android="http://schemas.android.com/apk/res/android"
android:accountType=<<PACKAGE NAME HERE ??>>
android:icon="@drawable/icon"
android:label="@string/app_name"/>
Thanks!
这是另一个临时解决方法,直到 Android Gradle 插件获得支持资源文件中的占位符 https://code.google.com/p/android/issues/detail?id=71365.
您可以通过 Gradle 动态创建 String 资源defaultConfig
and/or buildTypes
and/or productFlavors
关闭:
android {
defaultConfig {
applicationId 'com.foo.bar'
resValue 'string', 'package_name', applicationId
}
}
然后您可以在您的authenticator.xml
文件就像您对标签所做的那样:
<account-authenticator xmlns:android="http://schemas.android.com/apk/res/android"
android:accountType="@string/package_name"
android:icon="@drawable/icon"
android:label="@string/app_name"/>
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)