为不同的口味使用不同的清单文件

时间:2019-01-12 16:31:31

标签: android android-gradle android-manifest

我的应用将具有2种口味;一个带有<uses-feature android:name="android.hardware.camera.autofocus" />,另一个没有。在SO中经过这样的问题和解答之后,现在我尝试创建2种产品口味。这是我的module.gradle

flavorDimensions "version"
    productFlavors {
        noAutoFocus {
            // Assigns this product flavor to the "version" flavor dimension.
            // This property is optional if you are using only one dimension.
            manifest.srcFile "src/noAF/AndroidManifest.xml"
            dimension "version"
            applicationIdSuffix ".noAF"
            versionNameSuffix "-noAF"
        }
        full {
            manifest.srcFile "src/main/AndroidManifest.xml"
            dimension "version"
        }
    }

我已经在src下创建了一个noAF文件夹,并复制粘贴了相同的AndroidManifest.xml,但是删除了自动对焦权限。但是当我尝试同步gradle项目时,它将给我这个错误

Could not get unknown property 'manifest' for ProductFlavor_Decorated{name=noAutoFocus, dimension=null, minSdkVersion=null, targetSdkVersion=null, renderscriptTargetApi=null, renderscriptSupportModeEnabled=null, renderscriptSupportModeBlasEnabled=null, renderscriptNdkModeEnabled=null, versionCode=null, versionName=null, applicationId=null, testApplicationId=null, testInstrumentationRunner=null, testInstrumentationRunnerArguments={}, testHandleProfiling=null, testFunctionalTest=null, signingConfig=null, resConfig=null, mBuildConfigFields={}, mResValues={}, mProguardFiles=[], mConsumerProguardFiles=[], mManifestPlaceholders={}, mWearAppUnbundled=null} of type com.android.build.gradle.internal.dsl.ProductFlavor.

0 个答案:

没有答案