今天项目中遇到一个问题,在网上找了一些解决方式,但是都没法解决,后来在日志中找到解决方法,查看日志的方式:gradlew compileDebug --stacktrace -info,通过日志中的> Task :app:compileDebugJavaWithJavac FAILED
Putting task artifact state for task ':app:compileDebugJavaWithJavac' into context took 0.0 secs.
file or directory 'D:\FrameDemo\app\src\debug\java', not found
Up-to-date check for task ':app:compileDebugJavaWithJavac' took 0.038 secs. It is not up-to-date because:
Task has failed previously.
All input files are considered out-of-date for incremental task ':app:compileDebugJavaWithJavac'.
Compiling with source level 1.8 and target level 1.7.
file or directory 'D:\FrameDemo\app\src\debug\java', not found
Compiling with JDK Java compiler API.
Putting task artifact state for task ':app:compileDebugJavaWithJavac' into context took 0.0 secs.
file or directory 'D:\FrameDemo\app\src\debug\java', not found
Up-to-date check for task ':app:compileDebugJavaWithJavac' took 0.038 secs. It is not up-to-date because:
Task has failed previously.
All input files are considered out-of-date for incremental task ':app:compileDebugJavaWithJavac'.
Compiling with source level 1.8 and target level 1.7.
file or directory 'D:\FrameDemo\app\src\debug\java', not found
Compiling with JDK Java compiler API.
javacTask: 源发行版 1.8 需要目标发行版 1.8
找到原因,然后File-->Project Structure-->Source Compatibility和Target Compatibility改成相同的版本,问题就解决了
本文介绍了如何解决Gradle在编译过程中出现的错误,特别是当源代码版本与目标代码版本不一致导致的问题。通过调整项目的源兼容性和目标兼容性设置,成功解决了编译失败的情况。
374

被折叠的 条评论
为什么被折叠?



