簡體   English   中英

使用Proguard導致應用程序崩潰

[英]App crashes using proguard

由於我的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負責管理pro文件:

# 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

好吧,我自己解決了。 謝謝您的幫助。 我很感激。 因為問題是Proguard,所以我通過將“ minify enabled true”更改為“ minimable enabled false”來解決。 通過Studio調試時未顯示該信息的原因是,使用“即時運行”時會自動禁用Proguard。 解決此問題花費了24小時,而且眼睛劇烈疼痛。 希望這個答案有一天能對某人有所幫助。 和StackOverflow開發人員...您確實需要提出新功能,以便像我這樣的菜鳥可以更快地獲得答案。.也許我應該自己開發!

嘗試在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解碼一些日志。 解碼后,我們可以得到一些實際的日志

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM