ActivityMainBindingImpl cannot be found

Dr4ke the b4dass

This is from the google site: A binding class is generated for each layout file. By default, the name of the class is based on the name of the layout file, converting it to Pascal case and adding the Binding suffix to it. The above layout filename is activity_main.xml so the corresponding generated class is ActivityMainBinding. This class holds all the bindings from the layout properties (for example, the user variable) to the layout's views and knows how to assign values for the binding expressions.

In my case ActivityMainBinding is generated, but not ActivityMainBindingImpl. What is that class? How does it get generated? My project is written in Kotlin.

import android.util.SparseArray;
import android.util.SparseIntArray;
import android.view.View;
import androidx.databinding.DataBinderMapper;
import androidx.databinding.DataBindingComponent;
import androidx.databinding.ViewDataBinding;
import com.example.drake.kunuk.databinding.ActivityMainBindingImpl;
import java.lang.IllegalArgumentException;
import java.lang.Integer;
import java.lang.Object;
import java.lang.Override;
import java.lang.RuntimeException;
import java.lang.String;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

public class DataBinderMapperImpl extends DataBinderMapper {
  private static final int LAYOUT_ACTIVITYMAIN = 1;

  private static final SparseIntArray INTERNAL_LAYOUT_ID_LOOKUP = new SparseIntArray(1);

  static {
    INTERNAL_LAYOUT_ID_LOOKUP.put(com.example.drake.kunuk.R.layout.activity_main, LAYOUT_ACTIVITYMAIN);
  }

  @Override
  public ViewDataBinding getDataBinder(DataBindingComponent component, View view, int layoutId) {
    int localizedLayoutId = INTERNAL_LAYOUT_ID_LOOKUP.get(layoutId);
    if(localizedLayoutId > 0) {
      final Object tag = view.getTag();
      if(tag == null) {
        throw new RuntimeException("view must have a tag");
      }
      switch(localizedLayoutId) {
        case  LAYOUT_ACTIVITYMAIN: {
          if ("layout/activity_main_0".equals(tag)) {
            return new ActivityMainBindingImpl(component, view);
          }
      throw new IllegalArgumentException("The tag for activity_main is invalid. Received: " + tag);
    }
  }
}
return null;
  }

my xml:

<layout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto">

<data>
    <import type="android.view.View" />
    <variable
            name="handler"
            type="com.example.drake.kunuk.ui.main.MainActivity" />
    <variable
            name="manager"
            type="androidx.fragment.app.FragmentManager" />
</data>

<LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical">

    <androidx.appcompat.widget.Toolbar
            android:id="@+id/toolbar"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:animateLayoutChanges="true"
            app:title="@string/app_name"
            app:titleMarginStart="8dp" />

    <com.google.android.material.tabs.TabLayout
            android:id="@+id/tab_layout"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            app:pager="@{(pager)}">
    </com.google.android.material.tabs.TabLayout>

    <androidx.viewpager.widget.ViewPager
            android:id="@+id/pager"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            app:handler="@{handler}" />

</LinearLayout>

MainActivity.kt:

import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import androidx.databinding.DataBindingUtil
import com.example.drake.kunuk.R
import com.example.drake.kunuk.databinding.ActivityMainBinding

class MainActivity : AppCompatActivity() {

override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)
    val binding: ActivityMainBinding = DataBindingUtil
        .setContentView(this, R.layout.activity_main)
    binding.handler = this
    binding.manager = supportFragmentManager



}

}

outis

The likely cause is an error in the data binding stage.

The data binding compiler takes layout files and generates classes to support data binding (as you note: ActivityMainBinding, ActivityMainBindingImpl; the general pattern, dear readers, is {layout}Binding and {layout}BindingImpl, where {layout} is the camel-cased name of the layout file). Errors that arise during data binding compilation prevent these support classes from being generated. This then causes the missing class error you see from the Kotlin or Java compiler.

Currently, data binding errors aren't shown in the cooked build log; to see them, switch the view to the raw compiler output. Starting around AS 3.5, data binding errors should be shown in the cooked log.

Once you locate the error message from the data binding compiler, you can fix it, or look for an answer here on how to fix it if you're not sure.

この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。

侵害の場合は、連絡してください[email protected]

編集
0

コメントを追加

0

関連記事

分類Dev

BeautifulSoup: Table cannot be found

分類Dev

Hadoop Java Class cannot be found

分類Dev

macOS notarization: altool cannot be found

分類Dev

Blazor InputFile IFileListEntry cannot be found

分類Dev

Bamboo maven plugin cannot be found

分類Dev

Module not found: Error: Cannot resolve module 'fs'

分類Dev

Environment Variable cannot be found in docker container

分類Dev

Resource cannot be found, No identifier for missing item

分類Dev

Spring Batch : Field or property 'stepExecutionContext' cannot be found

分類Dev

NUnit exe file cannot found in the system

分類Dev

PostgreSQL cannot connect: service definition not found

分類Dev

PostgreSQL cannot connect: service definition not found

分類Dev

Spring / Thymeleaf: Property or field cannot be found on null, but still rendering

分類Dev

Spring / Thymeleaf: Property or field cannot be found on null, but still rendering

分類Dev

Can't add script component because the script class cannot be found?

分類Dev

Spring / Thymeleaf: Property or field cannot be found on null, but still rendering

分類Dev

MesonBuild: How to define dependency to a library that cannot be found by `pkg-config`?

分類Dev

Symfony : These messages are not available for the given locale and cannot be found in the fallback locales

分類Dev

New-LocalUser : A positional parameter cannot be found that accepts argument 'True'

分類Dev

Register-PsRepository : The property 'Name' cannot be found on this object

分類Dev

Cannot install Gensim in Conda env - noarch directory not found

分類Dev

Symfony cmd error "The target-entity..cannot be found in.."

分類Dev

rendering a dynamic web page and my javascript files cannot be found

分類Dev

the resource cannot be found when trying to access forms authentication

分類Dev

Script-generated files cannot be found as a project resource

分類Dev

Powershell Module function: A positional parameter cannot be found that accepts argument

分類Dev

Visual Studio 2013, error MSB8020: The build tools for Visual Studio 2010 cannot be found

分類Dev

Android: Kotlin: custom webView - cannot be invoked as a function. The function 'invoke()' is not found

分類Dev

Calendar API (Google Apps Script) Project not found and cannot be used for API calls

Related 関連記事

  1. 1

    BeautifulSoup: Table cannot be found

  2. 2

    Hadoop Java Class cannot be found

  3. 3

    macOS notarization: altool cannot be found

  4. 4

    Blazor InputFile IFileListEntry cannot be found

  5. 5

    Bamboo maven plugin cannot be found

  6. 6

    Module not found: Error: Cannot resolve module 'fs'

  7. 7

    Environment Variable cannot be found in docker container

  8. 8

    Resource cannot be found, No identifier for missing item

  9. 9

    Spring Batch : Field or property 'stepExecutionContext' cannot be found

  10. 10

    NUnit exe file cannot found in the system

  11. 11

    PostgreSQL cannot connect: service definition not found

  12. 12

    PostgreSQL cannot connect: service definition not found

  13. 13

    Spring / Thymeleaf: Property or field cannot be found on null, but still rendering

  14. 14

    Spring / Thymeleaf: Property or field cannot be found on null, but still rendering

  15. 15

    Can't add script component because the script class cannot be found?

  16. 16

    Spring / Thymeleaf: Property or field cannot be found on null, but still rendering

  17. 17

    MesonBuild: How to define dependency to a library that cannot be found by `pkg-config`?

  18. 18

    Symfony : These messages are not available for the given locale and cannot be found in the fallback locales

  19. 19

    New-LocalUser : A positional parameter cannot be found that accepts argument 'True'

  20. 20

    Register-PsRepository : The property 'Name' cannot be found on this object

  21. 21

    Cannot install Gensim in Conda env - noarch directory not found

  22. 22

    Symfony cmd error "The target-entity..cannot be found in.."

  23. 23

    rendering a dynamic web page and my javascript files cannot be found

  24. 24

    the resource cannot be found when trying to access forms authentication

  25. 25

    Script-generated files cannot be found as a project resource

  26. 26

    Powershell Module function: A positional parameter cannot be found that accepts argument

  27. 27

    Visual Studio 2013, error MSB8020: The build tools for Visual Studio 2010 cannot be found

  28. 28

    Android: Kotlin: custom webView - cannot be invoked as a function. The function 'invoke()' is not found

  29. 29

    Calendar API (Google Apps Script) Project not found and cannot be used for API calls

ホットタグ

アーカイブ