1

I migrated my app to androidx, and now in the released version, I'm getting that error. It works fine in all my tests, even the test lab doesn't find that error.

I've checked through every reference for it and they're all fine.

The line with the error:

    private MaterialButton mShiftStartDate;

private void getVars() {
.
        mShiftStartDate = v.findViewById(R.id.shift_start_date_tv);
.
}

and the xml:

    <com.google.android.material.button.MaterialButton
        style="@style/Widget.MaterialComponents.Button.OutlinedButton"
        android:id="@id/shift_start_date_tv"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="8dp"
        android:textSize="18sp"
        android:visibility="visible"
        app:layout_constraintEnd_toEndOf="@id/shift_start_date_label"
        app:layout_constraintHorizontal_chainStyle="spread_inside"
        app:layout_constraintStart_toStartOf="@id/shift_start_date_label"
        app:layout_constraintTop_toBottomOf="@id/shift_start_date_label"
        tools:text="10/10/18" />

and parts of build.gradle

    defaultConfig {
        applicationId appId
        targetSdkVersion 28
        minSdkVersion 19
        versionCode buildCode
        versionName versionMajor+"."+versionMinor+"."+versionRevision+"."+versionBuild
        resValue "string", "CURRENT_VERSION", versionName
    }
    compileOptions {
        sourceCompatibility 1.8
        targetCompatibility 1.8
    }
dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation 'androidx.legacy:legacy-support-v4:1.0.0'
    implementation 'androidx.appcompat:appcompat:1.1.0-alpha03'
    implementation 'com.google.android.material:material:1.1.0-alpha04'
    implementation 'androidx.recyclerview:recyclerview:1.1.0-alpha03'
    implementation 'androidx.browser:browser:1.0.0'
    implementation 'androidx.constraintlayout:constraintlayout:2.0.0-alpha3'
    implementation 'androidx.preference:preference:1.1.0-alpha04'
    implementation 'androidx.annotation:annotation:1.1.0-alpha02'
    implementation 'com.android.support:appcompat-v7:28.0.0'
    implementation 'android.arch.navigation:navigation-fragment:1.0.0'
    implementation 'android.arch.navigation:navigation-ui:1.0.0'
    implementation 'com.google.android.gms:play-services-ads-lite:17.2.0'
    implementation 'com.google.android.gms:play-services-oss-licenses:16.0.2'
    implementation 'org.jetbrains:annotations:17.0.0'
}

Searching for it doesn't turn up any other examples of the problem. The only thing I can think of is proguard is renaming something it shouldn't. Since I can't manage to reproduce it (It's only happened to 5 users, but 26 times for them in all) in any emulator or using test devices, I can't test something like

-keep class androidx.appcompat.widget.** {*;}

which is all I can think to do.

1 Answer 1

1

you have a duplicate dependency there:

implementation 'androidx.appcompat:appcompat:1.1.0-alpha03'
// implementation 'com.android.support:appcompat-v7:28.0.0'

and there is no widget N. the ProGuard mapping might tell what it actually is.

-keep,includedescriptorclass class androidx.appcompat.widget.** { *; }

using stable versions might also help to sort out unexpected results.

Sign up to request clarification or add additional context in comments.

3 Comments

I didn't catch that duplicate. thanks. I'm aware there's no widget "N", but with that being so, why is it trying to cast a non-existent widget to MaterialButton?
@user unsure about that... includedescriptorclass might help, as well as keeping R (which appears likely for an obfuscated resource descriptor). add switch -verbose to see about what it complains... it ordinary tells exactly what to do.
@IbrahimAli because the Jetifier will rewrite the name-space and each class must only exist once within a package, therefore it will result in a duplicate entry... however, the error message is related to class R (most likely).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.