2

我正在使用https://github.com/barteksc/AndroidPdfViewer在我的应用程序中显示 pdf。但是,当我使用缩小和缩小资源 true 构建应用程序时,当应用程序开始显示 pdf 查看器时,我的应用程序崩溃。

我得到的错误

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)
4

2 回答 2

2

在 proguard-rules.pro 中添加以下行

 -keep class com.shockwave.**
于 2020-01-13T11:23:34.613 回答
0

proguard-rules.pro用下面的代码片段替换您的内容

# 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 *;
}

应用级分级:

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"
}

项目级等级:

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/'
        }
    }
}

在此处输入图像描述 希望这可以帮助你。

于 2020-01-13T11:31:25.643 回答