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" />

然后保存即可。

相关推荐
名剑走天下30 分钟前
在 VSCode 中:修改快捷键
ide·vscode·编辑器
名剑走天下31 分钟前
在 VSCode 中:如何主动生成c_cpp_properties.json文件
ide·vscode·编辑器
雨白37 分钟前
协程进阶:协作、互斥与共享状态管理
android·kotlin
用户41659673693551 小时前
深度剖析 Android Context:启动 Activity 与 View 创建的“内幕”
android
扣得君1 小时前
解决glibc版本低VSCode无法远程问题
ide·vscode·编辑器·glibc升级·vscode远程glibc版本
方白羽1 小时前
Android 唯一UUID方案
android·app
一个小狼娃1 小时前
Android集成Unity避坑指南
android·游戏·unity
川石课堂软件测试1 小时前
Python | 高阶函数基本应用及Decorator装饰器
android·开发语言·数据库·python·功能测试·mysql·单元测试
行走的陀螺仪2 小时前
Flutter 开发环境配置教程
android·前端·flutter·ios
EEG小佬2 小时前
Jupyter选择内核时如何找到虚拟环境
ide·python·jupyter