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

时间:2019-01-29 19:47:17

标签: java android navigation android-architecture-components android-safe-args

如何在应用程序的任何或所有模块中使用Java和Safeargs?

我为我的应用设置了多模块设置。如果我对模块使用Kotlin,则Safeargs在所有模块中都可以正常工作。但是,如果我将语言切换为Java。如果我从应用程序以外的模块中删除了Safeargs插件,错误将消失!!我正在使用版本:1.0.0-alpha11。这是为什么??有什么方法可以在任何或所有模块中使用Safeargs和Java?

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(应用程序) 没有Safeargs

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.

1 个答案:

答案 0 :(得分:0)

可能是1.0.0-alpha11版本引起了该问题。 尝试将其更改为1.0.0-beta01,对我来说就成功了!