简体   繁体   English

如何在多模块体系结构(Java)中使用Safeargs?

[英]How to use Safeargs in multi-module architecture (Java)?

How can I use Java and Safeargs in any or all modules of my app?? 如何在我的应用程序的任何或所有模块中使用Java和Safeargs?

I have a multi-module setup for my app. 我的应用程序有一个多模块设置。 If I use Kotlin for the modules Safeargs works fine in all modules. 如果我对模块使用Kotlin,则Safeargs在所有模块中都可以正常工作。 But if I switch the language to Java. 但是,如果我将语言切换为Java。 If I remove Safeargs plugin from modules other than app the error disappears!! 如果我从应用程序以外的模块中删除了Safeargs插件,错误将消失!! I am using version: 1.0.0-alpha11. 我正在使用版本:1.0.0-alpha11。 Why is that?? 这是为什么?? Is there any way to use Safeargs and Java in any or all modules?? 有什么方法可以在任何或所有模块中使用Safeargs和Java?

build.gradle (project) build.gradle(项目)

dependencies {
        classpath 'com.android.tools.build:gradle:3.3.0'
        classpath "android.arch.navigation:navigation-safe-args-gradle-plugin:1.0.0-alpha11"
    }

build.gradle (app) does not have Safeargs build.gradle(应用程序)没有Safeargs

build.gradle (ui) build.gradle(ui)

apply plugin: 'com.android.library'
apply plugin: 'androidx.navigation.safeargs'
ERROR: null cannot be cast to non-null type org.gradle.api.resources.TextResource
Possible causes for this unexpected error include:
Gradle's dependency cache may be corrupt (this sometimes occurs after a network connection timeout.)
Re-download dependencies and sync project (requires network)

The state of a Gradle build process (daemon) may be corrupt. Stopping all Gradle daemons may solve this problem.
Stop Gradle build processes (requires restart)

Your project may be using a third-party plugin which is not compatible with the other plugins in the project or the version of Gradle requested by the project.

In the case of corrupt Gradle processes, you can also try closing the IDE and then killing all Java processes.

Probably the version 1.0.0-alpha11 is causing that. 可能是1.0.0-alpha11版本引起了该问题。 Try change to 1.0.0-beta01, that did the trick for me! 尝试将其更改为1.0.0-beta01,这对我有用!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM