应用程序崩溃使用proguard [英] App crashes using proguard

查看:133
本文介绍了应用程序崩溃使用proguard的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用程序崩溃,因为我的Proguard错误。我也在某处发布了这个问题。
如何格式化proguard错误?请帮我解决这个问题:

我的build.gradle:

  apply plugin:'com.android.application'
android {
compileSdkVersion 24
buildToolsVersion24.0.1
defaultConfig {
applicationId'com.quorate。 android'
minSdkVersion 16
targetSdkVersion 24
versionCode 3
versionName1.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'
}

依赖关系{
testCompil e'junit:junit:4.12'
compile fileTree(include:['* .jar'],dir:'libs')
androidTestCompile'c​​om.android.support.test.espresso:espresso-core :2.2.2'
androidTestCompile'c​​om.android.support.test:runner:0.5'
compile'c​​om.android.support:appcompat-v7:24.1.1'
compile'c​​om .android.support:recyclerview-v7:24.1.1'
compile'c​​om.android.support:cardview-v7:24.1.1'
compile'c​​om.android.support:design:24.1.1 '
compile'c​​om.firebaseui:firebase-ui-database:0.4.3'
compile'c​​om.google.firebase:firebase-auth:9.2.1'
compile'c​​om.google .firebase:firebase-database:9.2.1'
compile'c​​om.android.support:support-v4:24.1.1'
compile'c​​om.google.firebase:firebase-core:9.2.1 '
}

apply plugin:'

我的程序规则pro文件:

 #在这里添加项目特定的ProGuard规则。 
#默认情况下,这个文件中的标记被附加到C:\ Users \Vyshnav\AppData\Local\Android\Sdk / tools / proguard / proguard中指定的
# - android.txt
#您可以通过修改build.gradle中的proguardFiles
#指令来编辑包含路径和顺序。

#有关更多详细信息,请参阅
#http://developer.android.com/guide/developing/tools/proguard.html

#添加任何项目特定的保留选项在这里:

#如果您的项目使用带有JS的WebView,请取消注释以下
#并为JavaScript界面​​指定完全限定的类名称
#class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
#public *;
#}

-keepattributes签名
-keepattributes *注释*

-keep class com.quorate.android.PostViewHolder。** {
*;
}

-keepclassmembers类com.quorate.android.User。** {
*;
}

-keepclassmembers class com.quorate.android.Post。** {
*;
}

-keepclassmembers class com.quorate.android.Comment。** {
*;

$ / code $ / pre
$ b $ logcat错误

  java.lang.RuntimeException:java.lang.NoSuchMethodException:< init> [类android.view.View] 
在com.aaadb(未知源)
在android.support.v7.widget.ek.c(未知源)
在android.support.v7 .widget.fb.a(未知源)
在android.support.v7.widget.fb.c(未知源)
在android.support.v7.widget.dj.a(未知源)
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(未知源)
在android.support.v7.widget.RecyclerView.J(未知源)
在android.support.v7.widget.RecyclerView.k(未知源)
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)
在android.view.Choreograph er.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)
在java.lang.reflect.Method.invoke(本地方法)$ b $在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)
引起:java.lang.NoSuchMethodException:< init> [class android.view.View] $ b $在java.lang.Class.getConstructor(Class.java:531)$ b $在java.lang.Class.getConstructor(Class.java:495)
... 25更多


解决方案

感谢您的帮助guyz。我很感激。
我通过将minify enabled true改为minify enabled false来解决它,因为问题是Proguard。在通过Studio进行调试时未显示的原因是,使用即时运行时Proguard会自动禁用。
花费了24小时的时间和严重的眼痛来解决这个问题。希望这个答案有一天会帮助别人。
和StackOverflow开发人员...你真的需要提出新的功能,所以像我这样的noobs可以更快得到答案..也许我应该自己开发!

My app crashes because of my Proguard error. I have posted this question somewhere too. How can I format the proguard error? Kindly help me out to solve this:

My 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: '

My proguard rules pro files:

# 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 error:

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

解决方案

Ok I solved it myself. Thanks for your help guyz. I appreciate that. I solved it by changing "minify enabled true" to "minify enabled false", since the problem was Proguard. The reason it wasn't shown while debugging through Studio was that Proguard is disabled automatically when "Instant Run" is used. It took 24 hours and a severe eye pain to solve this out. Hope this answer helps someone someday. And StackOverflow Developers...you really need to come up with new features so noobs like me can get answers more fastly.. maybe I should develop that myself!

这篇关于应用程序崩溃使用proguard的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆