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;

2. 修改.idea下的gradle.xml

标签节点下添加一行

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


gradle.xml



错误:  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

找到标签节点并在之下添加一行

然后保存即可。


workspace.xml

正常运行 main()

main()

你可能感兴趣的:(Android Studio run main()方法报错)