Android開發中一套代碼發布多個產品問題,需要添加配置,目錄文件位置android => app => build.gradle
//不同APP的配置 productFlavors { jingdong { applicationId "com.sun.jingdong" resValue "string", "app_name", "jingdong" manifestPlaceholders = [CHANNEL_VALUE: "jingdong" ,app_icon : "@mipmap/ic_launcher"] } tengxun { applicationId "com.sun.tengxun" resValue "string", "app_name", "tengxun" manifestPlaceholders = [CHANNEL_VALUE: "tengxun" ,app_icon : "@mipmap/ic_launcher"] } xiaomi { applicationId "com.sun.xiaomi" resValue "string", "app_name", "xiaomi" manifestPlaceholders = [CHANNEL_VALUE: "xiaomi", app_icon : "@mipmap/ic_launcher", JPUSH_PKGNAME : applicationId, JPUSH_APPKEY : "appkey", // NOTE: JPush 上注冊的包名對應的 Appkey. JPUSH_CHANNEL : "developer-default", //暫時填寫默認值即可. ] } }
然后flutter中Android運行的時候,就會報錯
The Gradle project does not define a task suitable for the requested build.
The android/app/build.gradle file defines product flavors: jingdong, tengxun, xiaomi
You must specify a --flavor option to select one of them.
Finished with error: Gradle build aborted.
解決上面方法步驟如下:
1、添加配置參數Edit Configuations...
如下圖所示
2、假如運行xiaomi這個產品,添加參數
--flavor=xiaomi 或者--flavor xiaomi
xiaomi