java - Java 类文件未在 Android Studio 上编译或运行
问题描述
在我尝试在 Android Studio 中运行代码的地方,它不起作用并显示下面附加的错误。例子:
package com.example.jerry;
public class Test {
public static void main(String[] args) {
System.out.println("Hello World");
}
}
运行 Java 类 Test.class 时出错。这是显示的错误:
5:06:58 PM: Executing task 'Test.main()'...
Executing tasks: [Test.main()] in project G:\JavaProject\Jerry
FAILURE: Build failed with an exception.
* Where:
Initialization script 'C:\Users\Shakil\AppData\Local\Temp\Test_main__1.gradle' line: 21
* What went wrong:
A problem occurred configuring project ':app'.
> Could not create task ':app:Test.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.
* Get more help at https://help.gradle.org
BUILD FAILED in 271ms
Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/7.0.2/userguide/command_line_interface.html#sec:command_line_warnings
5:06:58 PM: Task execution finished 'Test.main()'.
解决方案
推荐阅读
- python - 一维卷积神经网络输入形状`ValueError`
- css - Ionic 3 在页面顶部修复了一个 div,即使用户上下滚动不使用 sass 脚本,它也会继续显示
- c++ - 使用 pybind11,如何为 array_t 对象设置底层内存的所有权?
- tensorflow - 在 tf.contrib.layers 中分配权重时是否有替代 constant_initializer 的方法
- listview - 多个彼此不同的 Tablix,每个 Tablix 有多行数据,在一个报表中使用相同的数据集
- c# - Azure DevOps Build 缺少程序集参考
- javascript - jquery 两次调用控制器进行实时搜索
- sql-server - VS 中的 SSDT 和 SQL Server 中的集成服务之间的区别
- graphql - 可以在不同的屏幕中调用相同的 GraphQL 订阅吗?
- elasticsearch - Elasticsearch 使用自定义聚合逻辑按查询分组