Partha Biswas
Partha Biswas

Reputation: 21

error: cannot find symbol while trying to run an android studio project

I am getting following error in TextboxBinding.java

error: cannot find symbol import android.widget.shape; ^ symbol: class shape location: package android.widget

error: cannot find symbol private final shape rootView; ^ symbol: class shape location: class TextboxBinding

error: cannot find symbol private TextboxBinding(@NonNull shape rootView) { ^ symbol: class shape location: class TextboxBinding

error: cannot find symbol public shape getRoot() { ^ symbol: class shape location: class TextboxBinding

error: cannot find symbol return new TextboxBinding((shape) rootView); ^ symbol: class shape location: class TextboxBinding

TextboxBinding.java

// Generated by view binder compiler. Do not edit!
package com.example.verzeo_one.databinding;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.shape;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.viewbinding.ViewBinding;
import com.example.verzeo_one.R;
import java.lang.NullPointerException;
import java.lang.Override;

public final class TextboxBinding implements ViewBinding {
  @NonNull
  private final shape rootView;

  private TextboxBinding(@NonNull shape rootView) {
    this.rootView = rootView;
  }

  @Override
  @NonNull
  public shape getRoot() {
    return rootView;
  }

  @NonNull
  public static TextboxBinding inflate(@NonNull LayoutInflater inflater) {
    return inflate(inflater, null, false);
  }

  @NonNull
  public static TextboxBinding inflate(@NonNull LayoutInflater inflater, @Nullable ViewGroup parent,
      boolean attachToParent) {
    View root = inflater.inflate(R.layout.textbox, parent, false);
    if (attachToParent) {
      parent.addView(root);
    }
    return bind(root);
  }

  @NonNull
  public static TextboxBinding bind(@NonNull View rootView) {
    if (rootView == null) {
      throw new NullPointerException("rootView");
    }

    return new TextboxBinding((shape) rootView);
  }
}

textbox.xml

<?xml version="1.0" encoding="utf-8"?>

<shape android:shape="rectangle" xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent"
    android:layout_height="match_parent">
<solid  android:color = "@color/design_default_color_primary"/>
<corners android:radius="20dp"/>
<stroks android:color = "@color/white"/>


</shape>

Upvotes: 0

Views: 3860

Answers (1)

MarsAtomic
MarsAtomic

Reputation: 10696

Maybe you're getting that error because android.widget.shape isn't where the Shape class comes from.

Looking at the official documentation it seems that the correct namespace is android.graphics.drawable.shapes.Shape. The android.widget package doesn't list any class named Shape at all.

Upvotes: 1

Related Questions