英文:
kaptGenerateStubsDebugKotlin FAILED e: Could not load module <Error module> - Android Studio Project
问题
我尝试构建项目时出现了这个错误。
编译器中没有任何错误。
源代码: https://github.com/KarolCieslar/WyjazdyOSP/tree/firebase
> 任务:app:kaptGenerateStubsDebugKotlin 失败
e: 无法加载模块 <错误模块>
失败: 构建失败,有异常。
* 出了什么问题:
执行任务时出现故障 ':app:kaptGenerateStubsDebugKotlin'。
> 在执行 org.jetbrains.kotlin.compilerRunner.GradleCompilerRunnerWithWorkers$GradleKotlinCompilerWorkAction 时发生故障
> 编译错误。请查看日志以了解更多详细信息
* 尝试:
> 使用 --stacktrace 选项运行以获取堆栈跟踪。
> 使用 --info 或 --debug 选项运行以获取更多日志输出。
> 使用 --scan 以获取完整的见解。
我尝试了
- 重启和清除缓存
- 重新打开项目
- 更新所有依赖项
- 重启Android Studio
- 重启电脑
英文:
i got this error when i try build project.
I do not have any errors in compilator.
Source code: https://github.com/KarolCieslar/WyjazdyOSP/tree/firebase
> Task :app:kaptGenerateStubsDebugKotlin FAILED
e: Could not load module <Error module>
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:kaptGenerateStubsDebugKotlin'.
> A failure occurred while executing org.jetbrains.kotlin.compilerRunner.GradleCompilerRunnerWithWorkers$GradleKotlinCompilerWorkAction
> Compilation error. See log for more details
* 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.
I try to
- Restart and Invalidate cache
- Reopen project
- Update all dependencies
- Restart Android Studio
- Restart Computer
答案1
得分: 28
我刚刚遇到了同样的错误,对我来说,有一个未使用的类,并且有一些错误的导入..出于某种原因,编译器从未显示这个错误..只有当我尝试提交文件到临时分支时,代码分析才显示了错误..我删除了那个类,重新构建,然后这个错误模块消息就消失了,构建成功..也尝试在你的项目中执行: 分析代码,你可能会找到问题所在。
我还在一些其他论坛上读到过,有个人也面临了同样的问题,对他来说,生成的代码缺少了导入..所以你也可以尝试浏览你的项目中生成的代码,检查是否缺少导入。
英文:
I just had same error, for me, there was an unused class and it had some wrong imports .. for some reason the compiler was never showing this error .. only when I tried to commit files into temp branch then code analysis showed me the error .. I removed that class, rebuilt, and then this Error module message was gone, build was successful .. try to perform: Analyze Code in your project as well, you might find out what the problem is.
I've also read on some other forums, some guy facing same issue, for him it was generated code missing imports .. so you might also try to go through generated code in your project and check for missing imports there.
答案2
得分: 6
Solution: Android Studio 无法找到错误的导入。问题出现在其中一个文件中。旧的导入项不包含在应用程序中,我不得不手动查找。
英文:
Solution: Android Studio can't found out bad import. The problem was in one of the files. Old imports which are not contains in the application
I had to find it manually
答案3
得分: 5
在我的情况下,我正在使用带有SafeArgs的导航组件,并且我正在将一个自定义的Parcelable传递给一个片段。但是,当我为该Parcelable更改了包名称时,它在导航图文件(例如:nav_graph.xml
)中没有自动更新,我不得不手动更改它。
英文:
In my case, I was using Navigation Component with SafeArgs, and I was passing a custom Parcelable to a fragment. However, when I changed the package name for that Parcelable, it did not update in the nav graph file (ex: nav_graph.xml
), I had to change it manually.
答案4
得分: 2
有可能最近更新了Compose、Kotlin或Accompanist的版本。可能需要进行一些迁移。例如,“accompanist-navigation-animation”库已被弃用。如果升级到Accompanist 0.32.0和Compose BOM版本2023.08.00,可能会遇到一些问题,比如某些导航代码变得不可读,可能会出现“找不到模块”的错误。这些问题需要手动解决。更多详情请参考迁移指南。
我还不得不更新了Google的protobuf依赖项id("com.google.protobuf"),从0.9.0到0.9.4。
英文:
There's a good chance that you might have recently updated the versions of Compose, Kotlin, or Accompanist. This could potentially lead to some migrations being required. For instance, the "accompanist-navigation-animation" library has been deprecated. If you upgrade to Accompanist 0.32.0 and Compose with BOM version 2023.08.00, you might encounter issues such as certain navigation code becoming unreadable and the possibility of a "module not found" error popping up. These issues would need to be resolved manually. For more details, refer to the migration guide.
I also had to update Google's protobuf dependency id("com.google.protobuf") from 0.9.0 to 0.9.4
答案5
得分: 0
我们刚刚遇到了这个问题 - 它与Moshi有关,它使用kapt。解决方案是调查定义了Moshi对象的我们的Kotlin文件,以找出错误。
英文:
We just hit this issue - it was related to Moshi, which uses kapt. The solution was to investigate our Kotlin files that defined Moshi objects to find the error.
答案6
得分: 0
问题很可能出在navigation.xml文件中。可能是argument标签中对某个类的引用不正确。因为Android Studio无法对此文件进行重构/重命名。
英文:
It is very likely that the problem is in the navigation.xml file. It may be that the reference to some class in the argument tag is wrong. Because Android Studio cannot Refactor/Rename this file.
答案7
得分: 0
以下是翻译好的部分:
刚刚发生了这个错误,我最近根据这个指南实施了一个AsyncResult
密封类:
https://blog.devgenius.io/kotlin-sealed-class-with-generic-covariance-7e33875e7002
问题在于我不小心将一个Any
泛型传递给了一个被定义为Nothing
的东西,比如AsyncResult.Error<Any>
,而不是只是AsyncResult.Error
。
英文:
Just had this error, I recently implemented an AsyncResult
sealed class following this guide:
https://blog.devgenius.io/kotlin-sealed-class-with-generic-covariance-7e33875e7002
The problem was I was accidentally passing an Any
generic to something that was typed as Nothing
, like AsyncResult.Error<Any>
instead of just AsyncResult.Error
.
答案8
得分: 0
我遇到了这个问题,后来发现我试图在我的导航图文件中声明一个参数为double,这是不允许的。我用float替换了double。
我将这个:
<argument
android:name=""
app:argType="double" />
替换为:
<argument
android:name=""
app:argType="float" />
英文:
I had this issue, turns out I was trying to declare an argument in my nav graph file as a double which is not allowed. I replaced the double with a float
I replaced this:
<argument
android:name=""
app:argType="double" />
With this:
<argument
android:name=""
app:argType="float" />
答案9
得分: 0
在我的情况下,应该是
<argument
android:name="quantity"
android:defaultValue="-1"
app:argType="int" />
而不是
<argument
android:name="quantity"
android:defaultValue="-1"
app:argType="integer" />
1.5小时消耗掉。
英文:
In my case it was
<argument
android:name="quantity"
android:defaultValue="-1"
app:argType="int" />
instead of
<argument
android:name="quantity"
android:defaultValue="-1"
app:argType="integer" />
1.5 hours gone
答案10
得分: 0
抱歉,这段文本已经是英文的,不需要翻译。如果您有其他需要翻译的文本,请随时提供。
英文:
Had the same problem. e: Could not load module <Error module>
In my case it was missing import in one of the refactored files. I was able to find it after crawling manually over each file. Idea finally showed red line error. Weird that you cant find it in analyze code or problems report in Intellij.
Here is my solution for future cases.
go to build gradle and disable kapt plugin and all kapt related imports like mapstruct etc.
When you now execute gradle build you will get place and error. Fix it and reenable kapt.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论