天天看點

android studio的run,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()

android studio的run,Android Studio run 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

找到标簽節點并在之下添加一行

然後儲存即可。

android studio的run,Android Studio run main()方法報錯

workspace.xml

正常運作 main()

android studio的run,Android Studio run main()方法報錯

main()