【发布时间】:2019-04-13 01:15:15
【问题描述】:
我是 android 开发的新手,但是我在模拟和生成 apk 时遇到了一个错误,在我的设备中使用 api 26 一切正常,但在任何其他使用另一个 api 的设备中,它以一种意想不到的方式关闭...按部分代码编码,模拟和生成apk部分我注意到android.support.design.button.MaterialButton会导致意外关闭,如果我有一个有效的示例代码,我不明白为什么会出现该错误在任何设备上。
这里是我的 gradle 应用的图片以及我在哪里应用了 materialButton
[https://i.stack.imgur.com/dNo5L.png][1]
[https://i.stack.imgur.com/FUEq0.png][2]
这是我的 gradle 应用程序
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'}
这是我应用materialButton的xml
<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" />
请帮帮我!!!!
【问题讨论】:
-
实际错误(IN TEXT)会有所帮助。
-
更改您的应用主题即可,请查看我的答案:stackoverflow.com/a/52401497/10271334
标签: android material-design material-ui