Issue
I try to build my app and I got stack-off errors.
Example AppBarMainBinding.java
error:
C:\My_App\app\build\generated\data_binding_base_class_source_out\debug\out\com\example\My_App\databinding\AppBarMainBinding.java:4:
error: package android.support.design.widget does not exist
import android.support.design.widget.^CoordinatorLayout;
(^displays an error item)
AppBarMainBinding.java
files under the 'build' folder are generated and should not be edited
// Generated by view binder compiler. Do not edit!
package com.example.gym_app.databinding;
import android.support.design.widget.CoordinatorLayout;
import android.support.design.widget.FloatingActionButton;
import android.support.v7.widget.Toolbar;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.viewbinding.ViewBinding;
import androidx.viewbinding.ViewBindings;
import com.example.gym_app.R;
import java.lang.NullPointerException;
import java.lang.Override;
import java.lang.String;
public final class AppBarMainBinding implements ViewBinding {
@NonNull
private final CoordinatorLayout rootView;
@NonNull
public final FloatingActionButton fab;
@NonNull
public final Toolbar toolbar;
private AppBarMainBinding(@NonNull CoordinatorLayout rootView, @NonNull FloatingActionButton fab,
@NonNull Toolbar toolbar) {
this.rootView = rootView;
this.fab = fab;
this.toolbar = toolbar;
}
@Override
@NonNull
public CoordinatorLayout getRoot() {
return rootView;
}
@NonNull
public static AppBarMainBinding inflate(@NonNull LayoutInflater inflater) {
return inflate(inflater, null, false);
}
@NonNull
public static AppBarMainBinding inflate(@NonNull LayoutInflater inflater,
@Nullable ViewGroup parent, boolean attachToParent) {
View root = inflater.inflate(R.layout.app_bar_main, parent, false);
if (attachToParent) {
parent.addView(root);
}
return bind(root);
}
@NonNull
public static AppBarMainBinding bind(@NonNull View rootView) {
// The body of this method is generated in a way you would not otherwise write.
// This is done to optimize the compiled bytecode for size and performance.
int id;
missingId: {
id = R.id.fab;
FloatingActionButton fab = ViewBindings.findChildViewById(rootView, id);
if (fab == null) {
break missingId;
}
id = R.id.toolbar;
Toolbar toolbar = ViewBindings.findChildViewById(rootView, id);
if (toolbar == null) {
break missingId;
}
return new AppBarMainBinding((CoordinatorLayout) rootView, fab, toolbar);
}
String missingId = rootView.getResources().getResourceName(id);
throw new NullPointerException("Missing required view with ID: ".concat(missingId));
}
}
Example ContentMainBindind.java
error:
(Same C:)
error: package android.support.constraint does not exist
private final ^ConstraintLayout rootView;
(^displays an error item)
symbol: class ConstraintLayout
location: class ContentMainBinding
ContentMainBinging.java
"files under the 'build' folder are generated and should not be edited"
// Generated by view binder compiler. Do not edit!
package com.example.gym_app.databinding;
import android.support.constraint.ConstraintLayout;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.viewbinding.ViewBinding;
import com.example.gym_app.R;
import java.lang.NullPointerException;
import java.lang.Override;
public final class ContentMainBinding implements ViewBinding {
@NonNull
private final ConstraintLayout rootView;
private ContentMainBinding(@NonNull ConstraintLayout rootView) {
this.rootView = rootView;
}
@Override
@NonNull
public ConstraintLayout getRoot() {
return rootView;
}
@NonNull
public static ContentMainBinding inflate(@NonNull LayoutInflater inflater) {
return inflate(inflater, null, false);
}
@NonNull
public static ContentMainBinding inflate(@NonNull LayoutInflater inflater,
@Nullable ViewGroup parent, boolean attachToParent) {
View root = inflater.inflate(R.layout.content_main, parent, false);
if (attachToParent) {
parent.addView(root);
}
return bind(root);
}
@NonNull
public static ContentMainBinding bind(@NonNull View rootView) {
if (rootView == null) {
throw new NullPointerException("rootView");
}
return new ContentMainBinding((ConstraintLayout) rootView);
}
}
build.grandle (:app)
plugins {
id 'com.android.application'
}
android {
compileSdk 31
defaultConfig {
applicationId "com.example.gym_app"
minSdk 31
targetSdk 31
versionCode 1
versionName "1.0"
compileSdkVersion 31
buildToolsVersion "30.0.2"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
buildFeatures {
viewBinding true
}
}
dependencies {
implementation 'android.arch.navigation:navigation-fragment:1.0.0'
implementation 'android.arch.navigation:navigation-ui:1.0.0'
implementation 'androidx.lifecycle:lifecycle-runtime:2.3.1'
implementation 'androidx.appcompat:appcompat:1.3.1'
implementation 'androidx.multidex:multidex:2.0.1'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'devs.mulham.horizontalcalendar:horizontalcalendar:1.3.4'
implementation 'org.web3j:compat:4.6.0-android'
implementation 'org.jetbrains:annotations:15.0'
implementation 'com.google.android.material:material:1.4.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.1'
}
grande.proprties
org.gradle.jvmargs=-Xmx2048m -Dfile.encoding\=UTF-8
android.useAndroidX=true
android.enableJetifier=true
Solution
The problem is that the compiler can't find some classes from the android.support
package. This is probably because you want to use androidx
but referenced the wrong package in your layout xml.
Make sure, you use the Views and Widgets from the androidx
package in your layout xml.
Also update all android.arch
dependencies to their latest androidx
equivalent.
Answered By - binarynoise
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.