Android Studio run main()方法报错

在studio中想要测试某个功能直接执行main()方法报错如下:

复制代码
* What went wrong:
A problem occurred configuring project ':app'.
> Could not create task ':app: **** .main()'.
  > SourceSet with name 'main' not found.

解决方案:

    1. 执行run ** main() with Coverage;
    1. 修改.idea下的gradle.xml

<GradleProjectSettings>标签节点下添加一行

xml 复制代码
<option name="delegatedBuild" value="false" />

保存,即可使用run ** with main() 和 debug ** with main()

错误: Command line is too long. Shorten command line for **

有人在上面盖了gradle.xml之后运行main方法又报如下错误:

复制代码
Error running ' ** ': Command line is too long. Shorten command line for  **  or also for Application default configuration.

解决方案:

修改.idea下的workspace.xml

找到<component name="PropertiesComponent">标签节点并在之下添加一行

xml 复制代码
<property name="dynamic.classpath" value="true" />

然后保存即可。

相关推荐
tongyiixiaohuang15 小时前
WMS已发货状态反写金蝶云星空:单策略实战教程
android
好的佩奇16 小时前
Dart 之类修饰符
android·flutter·dart
alexhilton17 小时前
用Konsist与Lint强制执行设计系统契约
android·kotlin·android jetpack
北京自在科技21 小时前
谷歌安卓 Gemini 迎来界面改版,Find Hub 接入 Gemini 支持物品记忆查找
android·安卓
1024奇点1 天前
【仓颉语言入门 · 第二篇 第 12 课】
开发语言·数据库·ide·mysql·开源
YB13751 天前
Jetpack Compose 动画Modifier.animateItem()
android
2401_885885041 天前
巴林语音通知接口如何对接?系统告警语音API接入教程
android·前端·网络·python·语音识别
收纳过往1 天前
数据库加索引的时机:慢查询日志说话
android·开发语言·数据库·python·低代码·rxjava
狂热开发者1 天前
车载中控要给鸿蒙用户,能不能和 Android 共用一个二维码?
android·华为·harmonyos
weixin_399380691 天前
TongWeb7.0.4.9M11如何接入到idea(by lqw)
java·ide·intellij-idea