I. Problems encountered

$layoutDependsOn (); $layoutDependsOn (); $layoutDependsOn (); $layoutDependsOn ()
override fun layoutDependsOn(
        parent: CoordinatorLayout,
        child: View,
        dependency: View
    ): Boolean {
        return dependency.id == R.id.ll_content
}
Copy the code

Error code: error code: error code: error code: error code: error code: error code: error code: error code: error code: error code: error code: error code: error code: error code: error code: error code: error code: error code: error code: error code: error code: error code: error code R.layout is the number starting with 1300), while **dependency. Id ** from ** view.getid ()** is an irregular number, resulting in a difference between the two ids

Find the R.Java file

Because of the above problem, I want to go to the ** r.java ** file to see what this Id is
**app\build\generated\source\r\debug\**
An R.file was found by searching under the **app\build\intermediates\runtime_symbol_list\debug** folder

Find that the id value of ll_content is a binary number starting with **0x7f**, which in decimal will be the same as the result of **dependency. Id **.
  • Where is the R.Java file

Android Gradle behavior change documentation for version 3.6.0

Simplifying the generation process of R class

The Android Gradle plug-in simplifies compiling the classpath by generating only one R class for each library module in your project and sharing these R classes with other module dependencies. This optimization should speed up builds, but you need to be aware of the following:

  • Because the compiler shares the R class with upstream module dependencies, each module in the project must use a unique package name.
  • The visibility of the library’s R class to other project dependencies depends on the configuration used to add the library as a dependency. For example, if library A adds library B as an “API” dependency, then library A and other libraries that depend on library A can access library B’s R class. However, if library A is configured with A Implementation dependency, other libraries may not have access to library B’s R class. If you need more information, please refer to the [dependencies configured] (https://developer.android.com/studio/build/dependencies#dependency_configurations).
**Android studio4.0.1**. By default, new projects rely on **Android Gradle 4.x**, which results in ** no R.java** files
  • Where does the r.i.D.l_content come from??
The answer is ** don’t know **🤦♂️🤦♂️ college. So far, no real reason has been found out
** The final solution can only be to find ** based on the location of the control
    override fun layoutDependsOn(
        parent: CoordinatorLayout,
        child: View,
        dependency: View
    ): Boolean {
        return dependency.id == parent.getChildAt(1).id
    }
Copy the code