注意:配置保留入口点“XXX”,但不保留Android Studio中的描述符类“xxx”

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

当我在Android studio v1.1.0中启用minifyEnabled时出现以下错误

这堂课是:

package com.example.FFmpegBridge;
public class FFmpegBridge {
    static {
        System.loadLibrary("xxx");
    }

    public native void init(AVOptions options, int audio) throws IOException;

    static public class AVOptions {


    }
}

proguard-rules.pro是默认值:

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

错误是:

19:55:06.080 [INFO] [system.out] Note: the configuration keeps the entry point 'com.example.FFmpegBridge { void init(com.example.FFmpegBridge$AVOptions,int); }', but not the descriptor class 'com.example.FFmpegBridge$AVOptions'
19:55:06.086 [INFO] [system.out] Note: there were 2 references to unknown classes.
19:55:06.086 [INFO] [system.out]       You should check your configuration for typos.
19:55:06.086 [INFO] [system.out]       (http://proguard.sourceforge.net/manual/troubleshooting.html#unknownclass)
19:55:06.086 [INFO] [system.out] Note: there were 1 unkept descriptor classes in kept class members.
19:55:06.087 [INFO] [system.out]       You should consider explicitly keeping the mentioned classes
19:55:06.087 [INFO] [system.out]       (using '-keep').
19:55:06.088 [INFO] [system.out]       (http://proguard.sourceforge.net/manual/troubleshooting.html#descriptorclass)
19:55:06.088 [INFO] [system.out] Ignoring unused library classes...
19:55:06.088 [INFO] [system.out]   Original number of library classes: 3686
19:55:06.089 [INFO] [system.out]   Final number of library classes:    326
19:55:06.089 [INFO] [system.out] Printing kept classes, fields, and methods...
19:55:06.125 [INFO] [system.out] Shrinking...
19:55:06.313 [DEBUG] [org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter] Finished executing task ':library:proguardRelease'
19:55:06.313 [LIFECYCLE] [class org.gradle.TaskExecutionLogger] :library:proguardRelease FAILED
19:55:06.313 [INFO] [org.gradle.execution.taskgraph.AbstractTaskPlanExecutor] :library:proguardRelease (Thread[main,5,main]) completed. Took 1.17 secs.
19:55:06.314 [DEBUG] [org.gradle.execution.taskgraph.AbstractTaskPlanExecutor] Task worker [Thread[main,5,main]] finished, busy: 1.763 secs, idle: 0.013 secs
19:55:06.328 [ERROR] [org.gradle.BuildExceptionReporter] 
19:55:06.328 [ERROR] [org.gradle.BuildExceptionReporter] FAILURE: Build failed with an exception.
19:55:06.329 [ERROR] [org.gradle.BuildExceptionReporter] 
19:55:06.329 [ERROR] [org.gradle.BuildExceptionReporter] * What went wrong:
19:55:06.329 [ERROR] [org.gradle.BuildExceptionReporter] Execution failed for task ':library:proguardRelease'.
19:55:06.329 [ERROR] [org.gradle.BuildExceptionReporter] > java.io.IOException: The output jar is empty. Did you specify the proper '-keep' options?
19:55:06.329 [ERROR] [org.gradle.BuildExceptionReporter] 
19:55:06.329 [ERROR] [org.gradle.BuildExceptionReporter] * Try:
19:55:06.330 [ERROR] [org.gradle.BuildExceptionReporter] Run with --stacktrace option to get the stack trace. 
19:55:06.331 [LIFECYCLE] [org.gradle.BuildResultLogger] 
19:55:06.331 [LIFECYCLE] [org.gradle.BuildResultLogger] BUILD FAILED
19:55:06.331 [LIFECYCLE] [org.gradle.BuildResultLogger] 
19:55:06.331 [LIFECYCLE] [org.gradle.BuildResultLogger] Total time: 12.014 secs

如何解决编译错误?

android android-studio android-proguard
1个回答
0
投票

你可能会忘记在你的proguard-rules.pro保护一些包裹

例如,如果你的aidl文件夹IPackageDataObserver.aidl中有android\content\pm。你应该添加

-dontwarn android.content.pm ** -keep class android.content.pm。** {*;}

到你的proguard-rules.pro文件

© www.soinside.com 2019 - 2024. All rights reserved.