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

标签节点下添加一行

<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

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

<property name="dynamic.classpath" value="true" />

然后保存即可。

你可能感兴趣的:(android,studio,android,ide)