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