2

I am using https://github.com/barteksc/AndroidPdfViewer for displaying pdf in my app. But when I build app with minify and shrink resource true, my app crashes when app starts to display pdf viewer.

Error I get

2020-01-13 17:05:55.589 10984-10984/? E/AndroidRuntime: FATAL EXCEPTION: main
    Process: <package>, PID: 10984
    j.e
        at e.h.a.a.e.c.a()
        at <package>.ui.dialog.PdfViewerDialog.a()
        at androidx.fragment.app.Fragment.b()
        at b.k.a.h.a()
        at b.k.a.h.i()
        at b.k.a.h.a()
        at b.k.a.a.c()
        at b.k.a.h.b()
        at b.k.a.h.a()
        at b.k.a.h.c()
        at b.k.a.h.s()
        at b.k.a.h$a.run()
        at android.os.Handler.handleCallback(Handler.java:836)
        at android.os.Handler.dispatchMessage(Handler.java:103)
        at android.os.Looper.loop(Looper.java:203)
        at android.app.ActivityThread.main(ActivityThread.java:6269)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1063)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:924)
RateM
  • 241
  • 1
  • 4
  • 15
  • did you consider ProGuard rules : `-keep class com.shockwave.**` ? – javadroid Jan 13 '20 at 11:20
  • Which kind of erro you got can you please elaborate and post here. – InsaneCat Jan 13 '20 at 11:33
  • @InsaneCat I added the error at the time of crash but its useless – RateM Jan 13 '20 at 11:37
  • @javadroid Yes I tried that first hand but nothing happended – RateM Jan 13 '20 at 11:37
  • shabyWoks is that you? i'm finding of solution @RateM – InsaneCat Jan 13 '20 at 11:54
  • @InsaneCat I am same. – RateM Jan 13 '20 at 12:01
  • If my answer helps you then please mark as a right my answer from tick mark otherwise i'm gonna remove this answer brother : https://www.google.com/search?q=right+mark+as+an+answer+stackoverflow&sxsrf=ACYBGNQVsfXj9VeT9WRKWerxeSRoAMe2uQ:1579936139192&source=lnms&tbm=isch&sa=X&ved=2ahUKEwiQk-DimJ7nAhWBc30KHdm9CGAQ_AUoAXoECAwQAw&biw=1517&bih=730#imgrc=9_JN49MpzDykBM: – InsaneCat Jan 25 '20 at 07:45

2 Answers2

2

add below line in proguard-rules.pro

 -keep class com.shockwave.**
Jai Khambhayta
  • 4,198
  • 2
  • 22
  • 29
0

Replace your proguard-rules.pro content with below code snippet

# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in /home/hbb20/AndroidSDK/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 *;
#}
-ignorewarnings
-keep class com.shockwave.**
-keep class * {
    public private *;
}

App level gradle:

buildscript {
    repositories {
        google()
        jcenter()
    }
}

repositories {
    google()
    jcenter()
}

apply plugin: 'com.android.application'

android {
    compileSdkVersion 28

    defaultConfig {
        minSdkVersion 19
        targetSdkVersion 28
        versionCode 3
        versionName "3.0.0"
    }

    buildTypes {
        release {
            debuggable false
            minifyEnabled true
            shrinkResources true
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }

        debug {
            debuggable true
            minifyEnabled false
            shrinkResources false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation project(':android-pdf-viewer')
    implementation 'com.android.support:appcompat-v7:28.0.0'
    implementation 'org.androidannotations:androidannotations-api:4.6.0'
    annotationProcessor "org.androidannotations:androidannotations:4.6.0"
}

Project level gradle:

buildscript {
    repositories {
        google()
        jcenter()
        mavenCentral()
        maven { url 'https://maven.fabric.io/public' }
        maven { url "https://jitpack.io" }
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.3.0'
        classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.4'
        classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1'
    }
}

allprojects {
    repositories {
        mavenLocal()
        jcenter()
        google()

        maven {
            url 'https://maven.google.com/'
        }
    }
}

enter image description here Hope this may help you.

InsaneCat
  • 2,115
  • 5
  • 21
  • 40