Status Update
Comments
il...@google.com <il...@google.com> #2
Branch: androidx-main
commit 7b17505c2e3679330cf386efe69f1aa95b6ae9e9
Author: Jeremy Woods <jbwoods@google.com>
Date: Thu Jan 06 14:47:42 2022
Update safeArgs to AGP 7.0.4
Updating safeArgs to depend on AGP 7.0.4.
Removing the use of reflection from the plugin since we no longer
needed.
RelNote: "Safe Args now depends on Android Gradle Plugin version 7.0.4.
This means that Navigation Safe Args will no longer be compatible with
Android Studio versions prior to 7.0."
Test: ./gradlew --rerun-tasks navigation:navigation-safe-args-gradle-plugin:test
Bug: 213086135
Bug: 207670704
Change-Id: I41c88ee06ad827c61cb1bbdc5ba58b3d56155caf
M navigation/navigation-safe-args-gradle-plugin/build.gradle
M navigation/navigation-safe-args-gradle-plugin/src/main/kotlin/androidx/navigation/safeargs/gradle/SafeArgsPlugin.kt
du...@gmail.com <du...@gmail.com> #3
Do you know if I can try this out in a snapshot or has it been published under a version name? (sorry, things in gerrit still confuse me so maybe its already clear that this is fixed and shipped!)
il...@google.com <il...@google.com> #4
Yes, you can follow the
il...@google.com <il...@google.com>
il...@google.com <il...@google.com> #6
Yay. I can confirm that your fix worked. Thanks! And you were able to beat out the firebase perf plugin in getting a fix released. Thank you! This unblocks my team!
Heads up what I had to do. add the maven repo to buildscript repos
buildscript {
repositories {
google()
mavenCentral()
maven("https://androidx.dev/snapshots/builds/8054565/artifacts/repository")
}
}
then update the plugin to
classpath("androidx.navigation:navigation-safe-args-gradle-plugin:2.5.0-SNAPSHOT")
I don't know whether I should update the rest of my nav deps to 2.5.0 snapshot, but this'll do for now.
du...@gmail.com <du...@gmail.com> #7
Generally, if possible, you should keep your safe args and other nav dependencies in sync just in case there are dependent changes in either module.
But for that particular build ID, this is the only difference between 2.4.0-rc01
and 2.5.0
so if you wanted to keep it as is, there should not be any issues.
il...@google.com <il...@google.com> #9
Really? Releasing AGP without being sure home-made libraries are working? ... next this seems to break androidx.core dependency Compiler stops with
public class MyActivity extends AppCompatActivity {
^
class file for androidx.core.content.OnConfigurationChangedProvider not found
because of other changes in androidx.navigation:2.5.0-alpha01 ?!
#madeMyDay ;(
Description
Version used: android.arch.navigation:navigation-safe-args-gradle-plugin:1.0.0-alpha11
Devices/Android versions reproduced on: not related to device/api version, it is code generation problem
Bug description:
navigation file defined like this:
<?xml version="1.0" encoding="utf-8"?>
<navigation xmlns:android="
xmlns:app="
xmlns:tools="
android:id="@+id/nav_graph"
app:startDestination="@id/homeFragment">
<fragment
android:id="@+id/homeFragment"
android:name="no.amedia.newsapp.android.WebPageFragment"
android:label="fragment_home"
tools:layout="@layout/fragment_web_page" >
<argument
android:name="web_url"
app:argType="string"
android:defaultValue="@string/url" />
</fragment>
<action android:id="@+id/action_global_homeFragment"
app:destination="@id/homeFragment" />
....
</navigation>
where url (referenced as "@string/url") is defined as <string name="url" translatable="false">
generates code like this:
class NavGraphDirections private constructor() {
private data class ActionGlobalHomeFragment(val webUrl: String = "@string/url") :
NavDirections {
override fun getActionId(): Int = no.amedia.newsapp.android.R.id.action_global_homeFragment
override fun getArguments(): Bundle {
val result = Bundle()
result.putString("web_url", this.webUrl)
return result
}
}
companion object {
fun actionGlobalHomeFragment(webUrl: String = "@string/url"): NavDirections =
ActionGlobalHomeFragment(webUrl)
}
}
so the problem is webUrl: String = "@string/url" instead of webUrl: String = "
the same is with WebPageFragmentDirections generated class:
class WebPageFragmentDirections private constructor() {
companion object {
fun actionGlobalHomeFragment(webUrl: String = "@string/url"): NavDirections =
NavGraphDirections.actionGlobalHomeFragment(webUrl)
}
when I try to use code like this
navController.navigate(WebPageFragmentDirections.actionGlobalHomeFragment())
or
navController.navigate(NavGraphDirections.actionGlobalHomeFragment())
argument value in the fragment is "@string/url" instead of "
while if I navigate like this
navController.navigate(R.id.homeFragment)
default value from navigation xml is used correctly and I get "
I hope that I manage to describe the problem in a proper way, it is very simple to reproduce, but if you have any questions just ask