我有一个带有基本品牌和多个白标品牌以及多个服务器目标的应用程序。在我的应用程序的 build.gradle 中,口味定义为:
flavorDimensions("server", "whitelabel")
在我src/main/res/drawable的基础品牌中,我有一个 logo.xml VectorDrawable,它在src/whitelabel1/res/drawable.
当我的应用程序的 build.config 包含vectorDrawables.useSupportLibrary = true正确的 logo.xml 时,将在我的 ImageView 中使用。如果我useSupportLibrary从 Whitelabel1main的 apk 中删除ImageView 渲染logo.xml
<ImageView
android:id="@+id/imageLogo"
android:layout_width="@dimen/viewXS"
android:layout_height="wrap_content"
android:layout_margin="@dimen/marginXS"
android:adjustViewBounds="true"
android:padding="@dimen/marginXS"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@drawable/ic_logo" />
Run Code Online (Sandbox Code Playgroud) android android-gradle-plugin android-vectordrawable build-variant
我刚刚更新到 Android Studio 3.6 稳定版。之后,每次打开我的项目。Android Studio 将我选择的构建变体更改为变体列表中的第一项。然后我必须更改选定的变体并再次同步 gradle。:(
有人对此有解决方案吗?
当我在 2019 年使用 android studio 3.5 更改项目中的变体时,我无法从 Active Build Variants 进行更改。我通过删除项目的 .idea 和 Build 文件夹并以新方式更改 Active Build Variants 中的 Varieties 解决了这个问题。
**2019 年:
项目构建 Gradle:3.5.3
安卓工作室:3.5**
通过保持相同的 Build Gradle 和相同的产品 Flavors 配置,我无法在项目中以任何方式更改 Active Build Variants 中的 Variants。这是之前配置和当前配置的唯一区别
**2020 年:
项目构建 Gradle:3.5.3
安卓工作室:4.0.1**
有没有人使用过最近的构建变体?这种问题的大概原因是什么?
android android-studio build.gradle android-productflavors build-variant
我有一个 Application 类,我希望在每个构建变体中都不同,例如调试和发布。
这是我的地图:
app/
|
|----debug/
|----java\
|----com.example.App.class
|----res\
|----mipmap-hdpi
|----main/
|----java\
|----com.example.App.class
|----res\
|----mipmap-hdpi
Run Code Online (Sandbox Code Playgroud)
但在 android studio 中给我这个错误消息“在...中找到重复的类”,
但它在我的资源中没有显示任何错误。
我的问题是为什么 gradle 无法弄清楚应该在不同的构建变体中使用哪个类,但它可以决定在不同的构建变体中必须使用哪些资源。
我使用产品风格来构建不同的应用程序。如果我在运行应用程序之前在构建变体中选择免费风格,则免费风格将运行,如果我选择付费风格,则将运行付费风格。
我想更改运行时间意味着在运行应用程序后,如果我们单击按钮,它必须更改付费应用程序。是否有机会通过编程更改构建变体选择运行时间。
class productFlavors {
free{
}
paid{
}
}
Run Code Online (Sandbox Code Playgroud)
我用这些作为调味品。
如果有人知道解决方案,请帮助我解决我的问题。
提前致谢。
android android-productflavors android-build-flavors build-variant