【发布时间】:2018-01-09 17:50:11
【问题描述】:
如果使用此代码在我的应用程序中启用 proguard:
release {
debuggable false
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
只有在 Play Store 中发布的应用程序才会崩溃,当尝试从 Android Studio 应用程序以调试或正常模式运行时不会崩溃。
崩溃时出错:
Error inflating class android.support.v7.widget.Toolbar
Caused by: android.view.InflateException: Binary XML file line #0: Binary XML file line #0: Error inflating class android.support.v7.widget.Toolbar
Caused by: android.view.InflateException: Binary XML file line #0: Error inflating class android.support.v7.widget.Toolbar
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.support.v7.widget.aj.a()' on a null object reference
我正在使用最新版本的 support.v7:
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:27.0.2'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation 'com.android.support:support-v4:27.0.2'
implementation 'com.google.firebase:firebase-messaging:11.8.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
}
今天之前一切正常=(
德克斯特说:
-dontwarn android.support.v7.**
-keep class android.support.v7.widget.** { *; }
它可以工作,但为什么在更新 android studio 后我总是有问题?为什么 Android Studio 在今天最新版 proguard 取消小部件之后?
【问题讨论】:
-
谢谢你。这就是我开始讨厌 Google/Android 等的原因。你照本宣科。你做他们想做的一切。没有任何效果。为什么 proguard 会删除导入和引用、声明和使用的库?然后只有在测试来自 playstore 的签名 apk 时,当每个人都已经在手机上拥有它时,你才会发现。现在我必须在上传之前测试已签名、缩小的 apk
标签: java android-studio crash