Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 782 Vote(s) - 3.53 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Can't get Root View from Data Binding after enabling safe-args plugin

#1
I'm working on an Android app using dataBinding and am currently trying to add the safe-args plugin, but after enabling the plugin, I can no longer get the root view via binding.root - Android Studio gives the error:

Unresolved Reference
None of the following candidates is applicable because of a receiver type mismatch:
* internal val File.root: File defined in kotlin.io


How can I get databinding and safe-args to play nice together?

Note that while the code snippet is in Kotlin I will happily take Java answers. Not as comfortable in Java but I can easily read it and translate it.

I haven't been able to find anyone else with the same problem by Googling the error message and "safe args". I tried first with the classpath listed in the Android docs here:

[To see links please register here]


classpath "androidx.navigation:navigation-safe-args-gradle-plugin:2.1.0"
And then also found a tutorial suggesting I use:

classpath "android.arch.navigation:navigation-safe-args-gradle-plugin:1.0.0-alpha07"

Both had the same issue: binding.root gave an error with the plugin activated


Here is my onCreateView() for my fragment. That return line works properly when safe-args isn't enabled and doesn't work when it is enabled

override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
binding = DataBindingUtil.inflate(inflater, R.layout.fragment_encoder, container, false)

return binding.root
}

Any help solving or understanding this problem is most appreciated!
Reply

#2
I have the same issue,
it's so wired for me,
but just rename the layout will work again,
try to it :D
Reply

#3
I have the same issue and at last I tried

File -> Invalid Caches/Restart

It works for me.
Reply

#4
I have the similar issue but only in included layout, perform these operations work for me

Build -> Clean Project
Build -> Rebuild Project
Reply

#5
I've already tried 「Invalidate Caches」、「Clean & Build」、「Rebuild」、Restart PC. However,They all did not work.

Until I did these:
1. Clean
2. remove 「.gradle」 & 「.buildCacheDir」
3. build

then it worked. Oh My God! try it!
Reply

#6
After I spend hours and tried everything, I remove .gradle/.tmp and .gradle/caches files completely and the problem disappeared
Reply



Forum Jump:


Users browsing this thread:
2 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through