首页 > 解决方案 > 如何在多模块架构(Java)中使用 Safeargs?

问题描述

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

我的应用程序有一个多模块设置。如果我将 Kotlin 用于模块,Safeargs 在所有模块中都可以正常工作。但是,如果我将语言切换到 Java。如果我从 app 以外的模块中删除 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 (app) 没有 Safeargs

构建.gradle(用户界面)

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.

标签: javaandroidnavigationandroid-architecture-componentsandroid-safe-args

解决方案


可能是版本 1.0.0-alpha11 导致了这种情况。尝试更改为 1.0.0-beta01,这对我有用!


推荐阅读