使用导航组件alpha09,并将apply plugin: "androidx.navigation.safeargs"
添加到基本模块build.gradle
的顶部,但是在进行gradle同步时出现以下错误。我正在使用Android Studio 3.4 Canary 9(但在使用3.3 RC3时也遇到了同样的问题)
alpha09-https://issuetracker.google.com/issues/119662045
中似乎包含一个相关的修补程序Caused by: kotlin.TypeCastException: null cannot be cast to non-null type org.gradle.api.resources.TextResource
at androidx.navigation.safeargs.gradle.SafeArgsPlugin.setApplicationId(SafeArgsPlugin.kt:87)
at androidx.navigation.safeargs.gradle.SafeArgsPlugin.access$setApplicationId(SafeArgsPlugin.kt:39)
at androidx.navigation.safeargs.gradle.SafeArgsPlugin$apply$1$task$1.execute(SafeArgsPlugin.kt:63)
at androidx.navigation.safeargs.gradle.SafeArgsPlugin$apply$1$task$1.execute(SafeArgsPlugin.kt:39)
at org.gradle.api.internal.tasks.DefaultTaskContainer.create(DefaultTaskContainer.java:360)
at androidx.navigation.safeargs.gradle.SafeArgsPlugin$apply$1.invoke(SafeArgsPlugin.kt:59)
at androidx.navigation.safeargs.gradle.SafeArgsPlugin$apply$1.invoke(SafeArgsPlugin.kt:39)
at androidx.navigation.safeargs.gradle.SafeArgsPluginKt$sam$org_gradle_api_Action$0.execute(SafeArgsPlugin.kt)
at org.gradle.internal.ImmutableActionSet$SingletonSet.execute(ImmutableActionSet.java:225)
at org.gradle.api.internal.DefaultDomainObjectCollection.doAdd(DefaultDomainObjectCollection.java:247)
at org.gradle.api.internal.DefaultDomainObjectCollection.add(DefaultDomainObjectCollection.java:236)
at com.android.build.gradle.LibraryExtension.addVariant(LibraryExtension.java:93)
at com.android.build.gradle.FeatureExtension.addVariant(FeatureExtension.java:121)
at com.android.build.gradle.internal.ApiObjectFactory.create(ApiObjectFactory.java:134)
答案 0 :(得分:0)
仅更新为alpha11,不再看到此问题。 (https://developer.android.com/jetpack/androidx/releases/navigation#1.0.0-alpha11)
更新 从下面的评论看来,alpha11不能解决某些人的问题,但beta1可以解决