10

Using Navigation component alpha09 and have added apply plugin: "androidx.navigation.safeargs" to top of base module build.gradle but getting following error when doing gradle sync. I'm using Android Studio 3.4 Canary 9 (but also had same problem using 3.3 RC3)

It looks like a related fix was included in 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)
John O'Reilly
  • 10,000
  • 4
  • 41
  • 63
  • 1
    There's another issue in Google issue tracker, related to this stacktrace: https://issuetracker.google.com/issues/121304903 – Slav Jan 22 '19 at 11:03
  • Updating navigation to 1.0.0-beta01 fixed this issue for me. It was the same exception. – Alexandre Feb 05 '19 at 16:15

1 Answers1

0

Just updated to alpha11 and not seeing this issue any more. (https://developer.android.com/jetpack/androidx/releases/navigation#1.0.0-alpha11)

UPDATE From comments below it looks like alpha11 didn't resolve issue for some people but beta1 did

John O'Reilly
  • 10,000
  • 4
  • 41
  • 63
  • Unfortunately the bug is still there in `alpha11`. At the moment the safe args library can not be used in a feature module. – ulcica Jan 28 '19 at 13:34
  • hmm, not sure why it seems ok for me now....I'll double check in case anything else changed in project (I've marked answer as not accepted in meantime) – John O'Reilly Jan 28 '19 at 14:33
  • @ulcica what version of Android Studio and also gradle plugin are you using? – John O'Reilly Jan 28 '19 at 14:35
  • I am using `Android Studio 3.3`, `com.android.tools.build:gradle:3.3.0`, `org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.20`. I think the problem is related to `applicationId` that can not be defined in feature modules. Because it works fine in the app module that has the applicationId. – ulcica Jan 28 '19 at 17:20
  • 1
    For me updating to Alpha11 didn't solve the issue, but updating to Beta01 released this week did the trick. – Alexandre Feb 05 '19 at 16:14
  • anyone getting this problem with navigation 2.0.0 ? – Gak2 May 24 '19 at 14:31