Skip to content

Snappy1

  • Home
  • Android
  • What
  • How
  • Is
  • Can
  • Does
  • Do
  • Why
  • Are
  • Who
  • Toggle search form

[FIXED] java – Access Binding Adapters in multi module project

Posted on November 11, 2022 By

Solution 1 :

I had the same problem because I was trying to access the class in the other module. It fixed when I put the class I was trying to access into the module containing xml. You can access only the classes in that module from within the XML.

Problem :

I’ve got a multi module project where the app module contains my binding adapters and my feature module depends on my app module since it is a dynamic feature module.

App (contains binding adapters) —-> Dynamic feature module (where the layout is present)

I have databinding and kapt enabled in all the modules.

I’m unable to build the app successfully. Android Studio gives me the following error,

error: cannot find symbol
import com.app.module1.databinding.FeatureItemBindingImpl;

Layout file in dynamic feature module:

<?xml version="1.0" encoding="utf-8"?>
<layout xmlns_app="http://schemas.android.com/apk/res-auto"
    xmlns_tools="http://schemas.android.com/tools">

    <data>

        <variable
            name="item"
            type="com.app.module1.views.FeatureItem" />

        <variable
            name="clickListener"
            type="com.app.module1.views.FeatureRecyclerViewAdapter.FeatureItemClickListener" />
    </data>

    <com.google.android.material.card.MaterialCardView xmlns_android="http://schemas.android.com/apk/res/android"
        android_layout_width="match_parent"
        android_layout_height="100dp"
        android_layout_margin="10dp"
        app_cardElevation="3dp"
        android_id="@+id/card"
        android_onClick="@{(view) -> clickListener.onClickFeature(view, item)}">

        <LinearLayout
            android_layout_width="match_parent"
            android_layout_height="match_parent"
            android_orientation="vertical">

            <androidx.appcompat.widget.AppCompatImageView
                android_id="@+id/feature_image"
                android_layout_width="match_parent"
                android_layout_height="0dp"
                android_layout_weight="7"
                android_scaleType="fitXY"
                app_set_image="@{item.featureImage}"
                tools_src="@color/green_200" />

            <com.google.android.material.textview.MaterialTextView
                android_id="@+id/feature_name"
                style="@style/TextAppearance.MyTheme.Body2"
                android_layout_width="match_parent"
                android_layout_height="wrap_content"
                android_layout_gravity="center_vertical"
                android_layout_weight="1"
                android_gravity="center"
                android_text="@{item.featureName.featureTitle}"
                tools_text="Order Pills" />
        </LinearLayout>

    </com.google.android.material.card.MaterialCardView>
</layout>

Binding Adapter in the App module:

@BindingAdapter("set_image")
fun AppCompatImageView.setImageToImageView(@DrawableRes drawable: Int) {
    this.setImageResource(drawable)
}

Comments

Comment posted by chrisdottel

What does your layout and data header look like in the xml file? Also, when I was getting these errors and couldn’t find any problems with the xml syntax I had to clean the project. Usually this fixed the issues.

Comment posted by Jitendra Reddy

@AnonAnonym updated the post

Comment posted by Jitendra Reddy

@AnonAnonym I tired cleaning build and caches but it didn’t work

READ  [FIXED] android - How to restore purchases on a second device (INAPP and SUBS)
Powered by Inline Related Posts

Comment posted by stackoverflow.com/questions/63176547/…

Hi, this is possible duplicate to

Android Tags:android, android-databinding, dynamic-feature-module, java, kotlin

Post navigation

Previous Post: [FIXED] java – android studio 4.0 cannot load jdk class
Next Post: [FIXED] java – How can ViewParent be cast into View?

Related Posts

[FIXED] java – How to get value from Firebase to recycleView Android
[FIXED] Android Studio: Adding Kotlin to existing Java app ends up in “Internal error: unexpected lint return value -1” when building Android
[FIXED] android – Ads overlapping bottom navigation in flutter Android
[FIXED] Error: Unresolved Reference: url (Okhttp3, Kotlin, android studio) Android
[FIXED] java – Room Database – AsyncTask Not Executing Android
[FIXED] xml – How to change DIalog window size Android studio Android

Archives

  • April 2023
  • March 2023
  • February 2023
  • January 2023
  • December 2022
  • November 2022
  • October 2022
  • September 2022

Categories

  • ¿Cómo
  • ¿Cuál
  • ¿Cuándo
  • ¿Cuántas
  • ¿Cuánto
  • ¿Qué
  • Android
  • Are
  • At
  • C'est
  • Can
  • Comment
  • Did
  • Do
  • Does
  • Est-ce
  • Est-il
  • For
  • Has
  • Hat
  • How
  • In
  • Is
  • Ist
  • Kann
  • Où
  • Pourquoi
  • Quand
  • Quel
  • Quelle
  • Quelles
  • Quels
  • Qui
  • Should
  • Sind
  • Sollte
  • Uncategorized
  • Wann
  • Warum
  • Was
  • Welche
  • Welchen
  • Welcher
  • Welches
  • Were
  • What
  • What's
  • When
  • Where
  • Which
  • Who
  • Who's
  • Why
  • Wie
  • Will
  • Wird
  • Wo
  • Woher
  • you can create a selvedge edge: You can make the edges of garter stitch more smooth by slipping the first stitch of every row.2022-02-04
  • you really only need to know two patterns: garter stitch

Recent Posts

  • Can Vicks humidifier be used without filter?
  • What color is Spanish green?
  • How old is Jamie in The War That Saved My Life?
  • When should I use scalp massager for hair growth?
  • Can I put polyurethane over liming wax?

Recent Comments

No comments to show.

Copyright © 2023 Snappy1.

Powered by PressBook Grid Dark theme