您的位置:首页 > 娱乐 > 明星 > 晋江是哪个省的城市_dw网页制作考试题目_合肥seo公司_百度搜索关键词排名查询

晋江是哪个省的城市_dw网页制作考试题目_合肥seo公司_百度搜索关键词排名查询

2025/4/18 16:14:11 来源:https://blog.csdn.net/qq_15050521/article/details/146268663  浏览:    关键词:晋江是哪个省的城市_dw网页制作考试题目_合肥seo公司_百度搜索关键词排名查询
晋江是哪个省的城市_dw网页制作考试题目_合肥seo公司_百度搜索关键词排名查询

步骤1、在项目根目录下build.gradle文件最后添加如下内容

//自定义任务名:assembleAndInstall
tasks.register('assembleAndInstall', Exec.class, new Action<Exec>() {@Overridevoid execute(Exec exec) {//设置自定义任务组名exec.setGroup('custom task')//当前编译是不是release版本boolean isBuildRelease = falseString buildType = 'Debug'if (isBuildRelease) {buildType = 'Release'}List<String> typeList = new ArrayList<>()for (final def aaa in project(':app').android.productFlavors) {String name = aaa['name']typeList.add(new String(name.charAt(0)).toUpperCase() + name.substring(1))}println 'typeList: ' + typeList.size()println 'typeList: ' + typeList//设置依赖的任务if (typeList.size() > 0) {//假设定义了两个 productFlavors,一个 phone,一个 tablet//默认选中第一个 tabletint index = 1exec.dependsOn('app:assemble' + typeList[index] + buildType, 'app:install' + typeList[index] + buildType)} else {//未定义productFlavorsexec.dependsOn('app:assemble' + buildType, 'app:install' + buildType)}//获取当前连接到电脑的设备//exec.setCommandLine('adb', 'devices')//强制停止apk进程//exec.setCommandLine('adb', 'shell', 'am', 'force-stop', 'com.example.myapplication3')//启动主Activityexec.setCommandLine('adb', 'shell', 'am', 'start', 'com.example.myapplication3/.MainActivity')}
})

步骤2、修改代码同时执行该任务,gradle将会自动执行编译,编译完成后会自动将编译出来的apk安装到设备中,如果要调试的话,使用Attach Debugger to Android Process的方式即可

缺点:依旧不可以以Debug的方式安装并调试

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com