由于我的Proguard错误,我的应用程序崩溃了。我也在某处发布了这个问题。 如何格式化proguard错误?请帮助我解决这个问题:
我的build.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 24
buildToolsVersion "24.0.1"
defaultConfig {
applicationId 'com.quorate.android'
minSdkVersion 16
targetSdkVersion 24
versionCode 3
versionName "1.2"
testInstrumentationRunner 'android.support.test.runner.AndroidJUnitRunner'
vectorDrawables.useSupportLibrary = true
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.debug
debuggable true
}
}
productFlavors {
}
}
configurations.all {
resolutionStrategy.force 'com.android.support:support-annotations:24.0.0'
}
dependencies {
testCompile 'junit:junit:4.12'
compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2.2'
androidTestCompile 'com.android.support.test:runner:0.5'
compile 'com.android.support:appcompat-v7:24.1.1'
compile 'com.android.support:recyclerview-v7:24.1.1'
compile 'com.android.support:cardview-v7:24.1.1'
compile 'com.android.support:design:24.1.1'
compile 'com.firebaseui:firebase-ui-database:0.4.3'
compile 'com.google.firebase:firebase-auth:9.2.1'
compile 'com.google.firebase:firebase-database:9.2.1'
compile 'com.android.support:support-v4:24.1.1'
compile 'com.google.firebase:firebase-core:9.2.1'
}
apply plugin: '
我的proguard规则专业档案:
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in C:\Users\Vyshnav\AppData\Local\Android\Sdk/tools/proguard/proguard- android.txt
# You can edit the include path and order by changing the proguardFiles
# directive in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# Add any project specific keep options here:
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
-keepattributes Signature
-keepattributes *Annotation*
-keep class com.quorate.android.PostViewHolder.** {
*;
}
-keepclassmembers class com.quorate.android.User.** {
*;
}
-keepclassmembers class com.quorate.android.Post.** {
*;
}
-keepclassmembers class com.quorate.android.Comment.** {
*;
}
logcat错误:
java.lang.RuntimeException: java.lang.NoSuchMethodException: <init> [class android.view.View]
at com.a.a.a.d.b(Unknown Source)
at android.support.v7.widget.ek.c(Unknown Source)
at android.support.v7.widget.fb.a(Unknown Source)
at android.support.v7.widget.fb.c(Unknown Source)
at android.support.v7.widget.dj.a(Unknown Source)
at android.support.v7.widget.LinearLayoutManager.a(Unknown Source)
at android.support.v7.widget.LinearLayoutManager.a(Unknown Source)
at android.support.v7.widget.LinearLayoutManager.c(Unknown Source)
at android.support.v7.widget.RecyclerView.J(Unknown Source)
at android.support.v7.widget.RecyclerView.k(Unknown Source)
at android.support.v7.widget.RecyclerView.t(Unknown Source)
at android.support.v7.widget.RecyclerView.c(Unknown Source)
at android.support.v7.widget.ee.run(Unknown Source)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:767)
at android.view.Choreographer.doCallbacks(Choreographer.java:580)
at android.view.Choreographer.doFrame(Choreographer.java:549)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:753)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5930)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1405)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1200)
Caused by: java.lang.NoSuchMethodException: <init> [class android.view.View]
at java.lang.Class.getConstructor(Class.java:531)
at java.lang.Class.getConstructor(Class.java:495)
... 25 more
答案 0 :(得分:2)
好的,我自己解决了。谢谢你的帮助guyz。我很感激。 我通过将“minify enabled true”改为“minify enabled false”来解决它,因为问题是Proguard。在通过Studio进行调试时未显示的原因是,当使用“Instant Run”时,Proguard会自动禁用。 解决了这个问题需要24小时和严重的眼睛疼痛。希望有一天这个答案可以帮助某人。 和StackOverflow开发人员......你真的需要提出新的功能,所以像我这样的新手可以更快地获得答案..也许我应该自己开发!
答案 1 :(得分:0)
尝试在我们的proguard中添加以下行。
-keep public class android.support.v7.widget.** { *; }
-keep public class android.support.v7.internal.widget.** { *; }
-keep public class android.support.v7.internal.view.menu.** { *; }
否则,您可以尝试使用proguard文件中的 - printmapping myapplication.map
解码部分日志。解码后我们可以使用一些实际日志