如何防止proguard缩小模块库? JAR

问题描述 投票:0回答:1

我有导入到项目中的fishwjy videocompressor库,当我在调试模式下运行用于压缩视频的代码时一切都很好,但是在发布模式下构建apk后运行视频压缩时却出现错误,这是Proguard的问题吗? ?以及如何解决此问题?以及如何使模块远离proguard?

我的build.gradle

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

我的保护规则

# 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
android module proguard android-library video-compression
1个回答
0
投票
来自proguard manual
© www.soinside.com 2019 - 2024. All rights reserved.