class Androidx.legacy.widget.space not found for Passcode View
Asked Answered
S

4

5

This activity was originally working but then it suddenly stopped working and it showed me this error. I'm not sure how to fix it and I don't recall removing anything from my app.gradle files but does anyone know how to solve it? Any help would be greatly appreciated

Below is my passcode view main activity (XML shown below with error) ''' PasscodeView PasswordView;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_password_view);

    PasswordView = findViewById(R.id.PasswordView);
    PasswordView.setPasscodeLength(4)
            .setLocalPasscode("1234")
            .setListener(new PasscodeView.PasscodeViewListener() {
                @Override
                public void onFail() {
                    Toast.makeText(PasswordView.this, "Passcode do not match",Toast.LENGTH_SHORT).show();
                }
                @Override
                public void onSuccess(String number) {
                    Intent intent = new Intent(PasswordView.this,Main2Activity.class);
                    startActivity(intent);
                }
            });

}}

'''

Screenshot of Error and XML for Password View

1st Part of App.Gradle

2nd Part of App.Gradle (Dependencies)

Sandler answered 22/4, 2020 at 15:25 Comment(0)
G
9

Add androidx.legacy:legacy-support-v4:1.0.0 in project dependencies section.

//app/build.gradle dependencies section

dependencies {

    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'androidx.legacy:legacy-support-v4:1.0.0'
    // Other dependencies
}

More Details : AndroidX Class Mappings,AndroidX Artifact Mappings

Goines answered 2/7, 2020 at 7:43 Comment(0)
S
5

Instead of androidx.legacy.widget.Space you can just use android.widget.Space. Eg.:

<android.widget.Space
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:layout_weight="1"
    android:minHeight="1dp"/>
Superphosphate answered 25/2, 2021 at 13:8 Comment(1)
The replacement note can be found in the androidx.legacy.widget.Space comment as follows: @deprecated Use framework {@link android.widget.Space} class instead. android.googlesource.com/platform/frameworks/support/+/…Link
S
3

In your layout file, replace occurrences of androidx.legacy.widget.Space with View.

eg.

 <androidx.legacy.widget.Space
       android:layout_width="8dp"
       android:layout_height="1dp" />

Should now be

 <View
      android:layout_width="8dp"
      android:layout_height="1dp" />

Had the same issue after updating my Gradle Version.

Sheelagh answered 6/8, 2020 at 9:55 Comment(0)
M
0

in my case I replaced <Space with <androidx.legacy.widget.Space and error disappeared.

Milly answered 19/10, 2022 at 16:6 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.