0

我有我导入到我的项目的fishwjy视频压缩器库,当我在调试模式下运行代码压缩视频时一切正常,但是当我在发布模式下构建apk后运行视频压缩时出现错误,这是proguard的问题吗?我该如何解决这个问题?,以及如何让模块远离 proguard?

我的 build.gradle

buildTypes {
        release {
            lintOptions {
                disable 'MissingTranslation'
                checkReleaseBuilds false
                abortOnError false
            }
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }

我的proguard规则

# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in /Android/AndroidSdk/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 *;
#}

# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable

# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
-keep class com.woxthebox.draglistview.** { *; }
-keep class com.vincent.videocompressor.** { *; }
-keepclassmembers com.vincent.videocompressor.** { *; }
-keep class videocompressor.**
-keepclassmembers videocompressor.**

-keep public class com.vincent.videocompressor.** {
  public protected *;
}
-keep public class videocompressor.** {
  public protected *;
}

这是错误,我进入了发布模式

java.lang.RuntimeException: An error occurred while executing doInBackground()
    at android.os.AsyncTask$3.done(AsyncTask.java:354)
    at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:383)
    at java.util.concurrent.FutureTask.setException(FutureTask.java:252)
    at java.util.concurrent.FutureTask.run(FutureTask.java:271)
    at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:245)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
    at java.lang.Thread.run(Thread.java:764)
Caused by: java.lang.NoClassDefFoundError: Failed resolution of: Lorg/aspectj/runtime/reflect/Factory;
    at com.coremedia.iso.boxes.FileTypeBox.ajc$preClinit(FileTypeBox.java:1)
    at com.coremedia.iso.boxes.FileTypeBox.<clinit>(FileTypeBox.java:1)
    at com.vincent.videocompressor.MP4Builder.createFileTypeBox(MP4Builder.java:155)
    at com.vincent.videocompressor.MP4Builder.createMovie(MP4Builder.java:62)
    at com.vincent.videocompressor.VideoController.convertVideo(VideoController.java:341)
    at com.vincent.videocompressor.VideoCompress$VideoCompressTask.doInBackground(VideoCompress.java:51)
    at com.vincent.videocompressor.VideoCompress$VideoCompressTask.doInBackground(VideoCompress.java:32)
    at android.os.AsyncTask$2.call(AsyncTask.java:333)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    ... 4 more
Caused by: java.lang.ClassNotFoundException: Didn't find class "org.aspectj.runtime.reflect.Factory" on path: DexPathList[[zip file "/system/framework/org.apache.http.legacy.boot.jar", zip file "/data/app/com.myapps.myapps-rN2AAoto-QpoZhVaUg_EFQ==/base.apk"],nativeLibraryDirectories=[/data/app/com.myapps.myapps-rN2AAoto-QpoZhVaUg_EFQ==/lib/arm64, /system/lib64]]
    at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:134)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
    ... 13 more
4

1 回答 1

1

使用 -dontshrink

来自proguard手册

-dontshrink 指定不收缩输入。默认情况下,ProGuard 会缩小代码:它会删除所有未使用的类和类成员。它只保留由各种 -keep 选项列出的选项,以及它们直接或间接依赖的选项。它还在每个优化步骤之后应用收缩步骤,因为某些优化可能会打开删除更多类和类成员的可能性。

于 2019-09-26T04:56:49.623 回答