Android Studio无法执行Java类的main方法问题及解决方法及找不到.idea的文件

错误提示:
Executing task ‘DimenUtils.main()’…

Executing tasks: [DimenUtils.main()] in project
/**/My Application

FAILURE: Build failed with an exception.

  • Where:
    Initialization script ‘/private/var/folders/qw/8_p1t59142d0xntgn799rt1c0000gn/T/DimenUtils_main__.gradle’ line: 26

  • What went wrong:
    A problem occurred configuring project ‘:app’.

Could not create task ‘:app:DimenUtils.main()’.
SourceSet with name ‘main’ not found.

  • Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

解决方案:

方案一:暂时的替代方案

Run “XXX.main()” with Coverage

方案二:修改.idea/gradle.xml文件

标签下增加了这行配置,然后给新项目添加这行配置,运行代码发现成功了。

在Android Studio 3.0及以上 无法运行Java代码main() 方法的解决方案

需要在gradle.properties的文件下,加上

android.enableAapt2=false

你可能感兴趣的:(Android,开发,android,studio,android,java,.idea,main)