Gabriela Yumie
Gabriela Yumie

Reputation: 3

Why materialButton closes my application?

I am new in the development of android, but I have run into an error where I emulate and generate the apk, in my device with api 26 everything works fine but in any other device with another api it closes in an unexpected way ... coding, emulating and generating the apk part by part of the code I noticed that the android.support.design.button.MaterialButton makes that unexpected closure happen, I do not understand why that error if I have a sample code that works on any device.

here images of my gradle app and where I apply the materialButton

[https://i.sstatic.net/dNo5L.png][1]

[https://i.sstatic.net/FUEq0.png][2]

this is my gradle app

apply plugin: 'com.android.application'

android {
compileSdkVersion 28
defaultConfig {
    applicationId "com.ts.ts.ts"
    minSdkVersion 19
    targetSdkVersion 28
    versionCode 1
    versionName "1.0"
    testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    vectorDrawables.useSupportLibrary = true
}


buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}}



dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
//noinspection GradleCompatible
api 'com.android.support:design:28.0.0'



implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:design:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'me.dm7.barcodescanner:zxing:1.9.8'
implementation 'com.journeyapps:zxing-android-embedded:2.0.1@aar'
implementation 'com.android.volley:volley:1.1.1'

implementation 'com.google.code.gson:gson:2.8.2'

implementation 'com.android.support:support-v4:28.0.0'
implementation 'android.arch.lifecycle:extensions:1.1.1'
implementation 'com.google.android.gms:play-services-plus:16.0.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'}

and this is the xml where I apply the materialButton

<android.support.design.button.MaterialButton
            android:id="@+id/cancel_button"
            style="@style/Widget.Shrine.Button.textButton"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginEnd="12dp"
            android:layout_marginRight="12dp"
            android:layout_toStartOf="@id/next_button"
            android:layout_toLeftOf="@id/next_button"
            android:text="@string/shr_button_cancel" />

please help me!!!!

Upvotes: 0

Views: 145

Answers (1)

In the styles.xml file, change the base of application theme to the one from material design library. For example:

<style name="AppTheme" parent="Theme.MaterialComponents.Light">

Upvotes: 1

Related Questions