Search code examples
androidfirebaseproguardfirebase-realtime-database

App crashes using proguard


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

Solution

  • 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!