Android Databinding for Custom View: 'cannot find symbol' and 'duplicate class found'












0















I have previously changed some code in my project and now there is the following error thrown during compilation for the following auto-generated class:



DataBinderMapperImpl.java : cannot find symbol "AdvancedBoxBindingImpl" (in line 'import ...databinding.AdvancedBoxBindingImpl;')



The AdvancedBox is included in the the layout fragment_config.xml like this:



<layout xmlns:bind="http://schemas.android.com/tools">
<data>
<import type="android.view.View"/>
<variable name="viewModel" type ="...GlobalConfigViewModel"/>
</data>
...
<....AdvancedBox
android:id="@+id/advancedBox"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:viewModel = "@{viewModel}"
android:visibility="@{viewModel.advancedShown ? View.VISIBLE : View.GONE}"/>
...
</layout>


The advanced_box.xml looks like this:



<layout>
<data>
<import type="android.view.View"/>
<variable
name="viewModel"
type="...GlobalConfigViewModel" />
</data>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
....


The binding in the AdvancedBox-class is instantiated like this:



class AdvancedBox : LinearLayout{
private lateinit var mBinding: AdvancedBoxBinding
init{
mBinding = AdvancedBoxBinding.inflate(inflater, this, true)
}


All of this previously worked, but I have recently updated Android Studio and made changes in the Code.



Additional Information:




  • gradle.properties has the attribute 'android.databinding.enableV2=true'

  • I have tried File->Invalidate Caches and Restart


Any suggestions on what might be the problem?










share|improve this question























  • Would you please try to delete the build folder and then clean build?

    – Faysal Ahmed
    Nov 26 '18 at 12:15
















0















I have previously changed some code in my project and now there is the following error thrown during compilation for the following auto-generated class:



DataBinderMapperImpl.java : cannot find symbol "AdvancedBoxBindingImpl" (in line 'import ...databinding.AdvancedBoxBindingImpl;')



The AdvancedBox is included in the the layout fragment_config.xml like this:



<layout xmlns:bind="http://schemas.android.com/tools">
<data>
<import type="android.view.View"/>
<variable name="viewModel" type ="...GlobalConfigViewModel"/>
</data>
...
<....AdvancedBox
android:id="@+id/advancedBox"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:viewModel = "@{viewModel}"
android:visibility="@{viewModel.advancedShown ? View.VISIBLE : View.GONE}"/>
...
</layout>


The advanced_box.xml looks like this:



<layout>
<data>
<import type="android.view.View"/>
<variable
name="viewModel"
type="...GlobalConfigViewModel" />
</data>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
....


The binding in the AdvancedBox-class is instantiated like this:



class AdvancedBox : LinearLayout{
private lateinit var mBinding: AdvancedBoxBinding
init{
mBinding = AdvancedBoxBinding.inflate(inflater, this, true)
}


All of this previously worked, but I have recently updated Android Studio and made changes in the Code.



Additional Information:




  • gradle.properties has the attribute 'android.databinding.enableV2=true'

  • I have tried File->Invalidate Caches and Restart


Any suggestions on what might be the problem?










share|improve this question























  • Would you please try to delete the build folder and then clean build?

    – Faysal Ahmed
    Nov 26 '18 at 12:15














0












0








0








I have previously changed some code in my project and now there is the following error thrown during compilation for the following auto-generated class:



DataBinderMapperImpl.java : cannot find symbol "AdvancedBoxBindingImpl" (in line 'import ...databinding.AdvancedBoxBindingImpl;')



The AdvancedBox is included in the the layout fragment_config.xml like this:



<layout xmlns:bind="http://schemas.android.com/tools">
<data>
<import type="android.view.View"/>
<variable name="viewModel" type ="...GlobalConfigViewModel"/>
</data>
...
<....AdvancedBox
android:id="@+id/advancedBox"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:viewModel = "@{viewModel}"
android:visibility="@{viewModel.advancedShown ? View.VISIBLE : View.GONE}"/>
...
</layout>


The advanced_box.xml looks like this:



<layout>
<data>
<import type="android.view.View"/>
<variable
name="viewModel"
type="...GlobalConfigViewModel" />
</data>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
....


The binding in the AdvancedBox-class is instantiated like this:



class AdvancedBox : LinearLayout{
private lateinit var mBinding: AdvancedBoxBinding
init{
mBinding = AdvancedBoxBinding.inflate(inflater, this, true)
}


All of this previously worked, but I have recently updated Android Studio and made changes in the Code.



Additional Information:




  • gradle.properties has the attribute 'android.databinding.enableV2=true'

  • I have tried File->Invalidate Caches and Restart


Any suggestions on what might be the problem?










share|improve this question














I have previously changed some code in my project and now there is the following error thrown during compilation for the following auto-generated class:



DataBinderMapperImpl.java : cannot find symbol "AdvancedBoxBindingImpl" (in line 'import ...databinding.AdvancedBoxBindingImpl;')



The AdvancedBox is included in the the layout fragment_config.xml like this:



<layout xmlns:bind="http://schemas.android.com/tools">
<data>
<import type="android.view.View"/>
<variable name="viewModel" type ="...GlobalConfigViewModel"/>
</data>
...
<....AdvancedBox
android:id="@+id/advancedBox"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:viewModel = "@{viewModel}"
android:visibility="@{viewModel.advancedShown ? View.VISIBLE : View.GONE}"/>
...
</layout>


The advanced_box.xml looks like this:



<layout>
<data>
<import type="android.view.View"/>
<variable
name="viewModel"
type="...GlobalConfigViewModel" />
</data>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
....


The binding in the AdvancedBox-class is instantiated like this:



class AdvancedBox : LinearLayout{
private lateinit var mBinding: AdvancedBoxBinding
init{
mBinding = AdvancedBoxBinding.inflate(inflater, this, true)
}


All of this previously worked, but I have recently updated Android Studio and made changes in the Code.



Additional Information:




  • gradle.properties has the attribute 'android.databinding.enableV2=true'

  • I have tried File->Invalidate Caches and Restart


Any suggestions on what might be the problem?







android android-databinding






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 24 '18 at 17:44









DoflaminhgoDoflaminhgo

1229




1229













  • Would you please try to delete the build folder and then clean build?

    – Faysal Ahmed
    Nov 26 '18 at 12:15



















  • Would you please try to delete the build folder and then clean build?

    – Faysal Ahmed
    Nov 26 '18 at 12:15

















Would you please try to delete the build folder and then clean build?

– Faysal Ahmed
Nov 26 '18 at 12:15





Would you please try to delete the build folder and then clean build?

– Faysal Ahmed
Nov 26 '18 at 12:15












2 Answers
2






active

oldest

votes


















0














where have you specified the binding class inside xml? I think that's the issue



<layout>
<data class="AdvancedBoxBinding">
<import type="android.view.View"/>
<variable
name="viewModel"
type="...GlobalConfigViewModel" />
</data>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"





share|improve this answer































    0














    Possible problem with the way data has been bound to the view.
    In my case, I had a model :



    <data>
    <variable name="user" type="zw.org.coop.models.User"/>
    </data>


    but because of copy pasting, I had a typo like :



    <TextView
    android:id="@+id/fullName"
    style="@style/styleEditText"
    android:layout_width="match_parent"
    android:layout_height="35dp"
    android:padding="5dp"
    android:text="@{user.user.firstName}"
    android:textSize="12sp"
    tools:text="Dean Kaila" />


    where user.user.firstName was not intend but user.firstName



    Would've been better if Jetbrains had some intellisense going on to help with such issues, but yeah, that was a good 2 days for me.
    Hope this helps someone.






    share|improve this answer























      Your Answer






      StackExchange.ifUsing("editor", function () {
      StackExchange.using("externalEditor", function () {
      StackExchange.using("snippets", function () {
      StackExchange.snippets.init();
      });
      });
      }, "code-snippets");

      StackExchange.ready(function() {
      var channelOptions = {
      tags: "".split(" "),
      id: "1"
      };
      initTagRenderer("".split(" "), "".split(" "), channelOptions);

      StackExchange.using("externalEditor", function() {
      // Have to fire editor after snippets, if snippets enabled
      if (StackExchange.settings.snippets.snippetsEnabled) {
      StackExchange.using("snippets", function() {
      createEditor();
      });
      }
      else {
      createEditor();
      }
      });

      function createEditor() {
      StackExchange.prepareEditor({
      heartbeatType: 'answer',
      autoActivateHeartbeat: false,
      convertImagesToLinks: true,
      noModals: true,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: 10,
      bindNavPrevention: true,
      postfix: "",
      imageUploader: {
      brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
      contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
      allowUrls: true
      },
      onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      });


      }
      });














      draft saved

      draft discarded


















      StackExchange.ready(
      function () {
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53460833%2fandroid-databinding-for-custom-view-cannot-find-symbol-and-duplicate-class-f%23new-answer', 'question_page');
      }
      );

      Post as a guest















      Required, but never shown

























      2 Answers
      2






      active

      oldest

      votes








      2 Answers
      2






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes









      0














      where have you specified the binding class inside xml? I think that's the issue



      <layout>
      <data class="AdvancedBoxBinding">
      <import type="android.view.View"/>
      <variable
      name="viewModel"
      type="...GlobalConfigViewModel" />
      </data>
      <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"





      share|improve this answer




























        0














        where have you specified the binding class inside xml? I think that's the issue



        <layout>
        <data class="AdvancedBoxBinding">
        <import type="android.view.View"/>
        <variable
        name="viewModel"
        type="...GlobalConfigViewModel" />
        </data>
        <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"





        share|improve this answer


























          0












          0








          0







          where have you specified the binding class inside xml? I think that's the issue



          <layout>
          <data class="AdvancedBoxBinding">
          <import type="android.view.View"/>
          <variable
          name="viewModel"
          type="...GlobalConfigViewModel" />
          </data>
          <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"





          share|improve this answer













          where have you specified the binding class inside xml? I think that's the issue



          <layout>
          <data class="AdvancedBoxBinding">
          <import type="android.view.View"/>
          <variable
          name="viewModel"
          type="...GlobalConfigViewModel" />
          </data>
          <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 26 '18 at 11:58









          ABrABr

          19017




          19017

























              0














              Possible problem with the way data has been bound to the view.
              In my case, I had a model :



              <data>
              <variable name="user" type="zw.org.coop.models.User"/>
              </data>


              but because of copy pasting, I had a typo like :



              <TextView
              android:id="@+id/fullName"
              style="@style/styleEditText"
              android:layout_width="match_parent"
              android:layout_height="35dp"
              android:padding="5dp"
              android:text="@{user.user.firstName}"
              android:textSize="12sp"
              tools:text="Dean Kaila" />


              where user.user.firstName was not intend but user.firstName



              Would've been better if Jetbrains had some intellisense going on to help with such issues, but yeah, that was a good 2 days for me.
              Hope this helps someone.






              share|improve this answer




























                0














                Possible problem with the way data has been bound to the view.
                In my case, I had a model :



                <data>
                <variable name="user" type="zw.org.coop.models.User"/>
                </data>


                but because of copy pasting, I had a typo like :



                <TextView
                android:id="@+id/fullName"
                style="@style/styleEditText"
                android:layout_width="match_parent"
                android:layout_height="35dp"
                android:padding="5dp"
                android:text="@{user.user.firstName}"
                android:textSize="12sp"
                tools:text="Dean Kaila" />


                where user.user.firstName was not intend but user.firstName



                Would've been better if Jetbrains had some intellisense going on to help with such issues, but yeah, that was a good 2 days for me.
                Hope this helps someone.






                share|improve this answer


























                  0












                  0








                  0







                  Possible problem with the way data has been bound to the view.
                  In my case, I had a model :



                  <data>
                  <variable name="user" type="zw.org.coop.models.User"/>
                  </data>


                  but because of copy pasting, I had a typo like :



                  <TextView
                  android:id="@+id/fullName"
                  style="@style/styleEditText"
                  android:layout_width="match_parent"
                  android:layout_height="35dp"
                  android:padding="5dp"
                  android:text="@{user.user.firstName}"
                  android:textSize="12sp"
                  tools:text="Dean Kaila" />


                  where user.user.firstName was not intend but user.firstName



                  Would've been better if Jetbrains had some intellisense going on to help with such issues, but yeah, that was a good 2 days for me.
                  Hope this helps someone.






                  share|improve this answer













                  Possible problem with the way data has been bound to the view.
                  In my case, I had a model :



                  <data>
                  <variable name="user" type="zw.org.coop.models.User"/>
                  </data>


                  but because of copy pasting, I had a typo like :



                  <TextView
                  android:id="@+id/fullName"
                  style="@style/styleEditText"
                  android:layout_width="match_parent"
                  android:layout_height="35dp"
                  android:padding="5dp"
                  android:text="@{user.user.firstName}"
                  android:textSize="12sp"
                  tools:text="Dean Kaila" />


                  where user.user.firstName was not intend but user.firstName



                  Would've been better if Jetbrains had some intellisense going on to help with such issues, but yeah, that was a good 2 days for me.
                  Hope this helps someone.







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Dec 31 '18 at 23:12









                  geekInMegeekInMe

                  10518




                  10518






























                      draft saved

                      draft discarded




















































                      Thanks for contributing an answer to Stack Overflow!


                      • Please be sure to answer the question. Provide details and share your research!

                      But avoid



                      • Asking for help, clarification, or responding to other answers.

                      • Making statements based on opinion; back them up with references or personal experience.


                      To learn more, see our tips on writing great answers.




                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function () {
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53460833%2fandroid-databinding-for-custom-view-cannot-find-symbol-and-duplicate-class-f%23new-answer', 'question_page');
                      }
                      );

                      Post as a guest















                      Required, but never shown





















































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown

































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown







                      Popular posts from this blog

                      Contact image not getting when fetch all contact list from iPhone by CNContact

                      count number of partitions of a set with n elements into k subsets

                      A CLEAN and SIMPLE way to add appendices to Table of Contents and bookmarks