在 Flutter 中为 Particular Flavor 构建 apk 时出错

Error when Building apk for Particular Flavor in Flutter

提问人:ASAD HAMEED 提问时间:5/22/2023 最后编辑:ASAD HAMEED 更新时间:5/23/2023 访问量:84

问:

我已经在我的 flutter 应用程序中实现了 flavors。当我尝试使用此命令构建 apk 时

 flutter build apk --release --flavor development -t lib/main_dev.dart

我收到以下错误,但是在第二次尝试上述命令时,apk已成功生成。

出了什么问题:


Execution failed for task ':app:mergeDevelopmentReleaseResources'.
> java.lang.IllegalArgumentException: Unable to locate resourceFile (/flutter_app/build/app/intermediates/merged-not-compiled-resources/development/release/drawable/abc_dialog_material_background.xml) in source-sets.

以下是口味的定义app/build.gradle

    sourceSets {
        customer {
            res.srcDirs = ['src/customer/res']
        }

        staging {
            res.srcDirs = ['src/staging/res']
        }

        development {
            res.srcDirs = ['src/development/res']
        }
    }

    flavorDimensions "app"
    
    productFlavors {

        customer {
            dimension "app"
            applicationId "com.example.app"
            versionCode 1
            versionName "1.0"

        }

        staging {
            dimension "app"
            applicationId "com.example.app"
            versionCode 1
            versionName "1.0"

        }

        development {
            dimension "app"
            applicationId "com.example.app"
            versionCode 1
            versionName "1.0"

        }
    }

默认配置

defaultConfig {
      
        applicationId "com.example.app"
  
        minSdkVersion 21
        targetSdkVersion 33
        versionCode 1
        versionName 1.0.0
    }
flutter gradle android-gradle-plugin android-productflavors

评论

0赞 jayesh gurudayalani 5/22/2023
你能分享你的targetSdk版本和minSdkVersion吗
0赞 ASAD HAMEED 5/23/2023
我添加了 .buildConfig
0赞 jayesh gurudayalani 5/23/2023
这可能会帮助您 stackoverflow.com/questions/72212885/...

答: 暂无答案