我需要在项目中使用两个不同的维度。但是在这种用法之后,无论我做什么,Android Studio 都会告诉我“未找到默认活动”。实际上 src 文件夹中没有任何变化,因为我不需要修改风味中的任何类。
flavorDimensions "device", "backend"
productFlavors {
dev {
buildConfigField "String", "API_VERSION", "\"1.1\""
...extra configs
dimension "backend"
}
staging {
buildConfigField "String", "API_VERSION", "\"1.1\""
...extra configs
dimension "backend"
}
prod {
buildConfigField "String", "API_VERSION", "\"1.1\""
...extra configs
dimension "backend"
}
android {
buildConfigField "String", "DEVICE_TYPE", "\"ANDROID\""
dimension "device"
}
huawei {
buildConfigField "String", "DEVICE_TYPE", "\"ANDROID_HW\""
versionCode 10000 + defaultConfig.versionCode
dimension "device"
}
}
主/AndroidManifest.xml:
<application
android:name=".XApplication"
...
<activity
android:name=".ui.SplashActivity"
android:theme="@style/SplashTheme">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>