简体   繁体   English

Proguard + RenderScript 支持库错误

[英]Proguard + RenderScript support library error

I have a project that is using the new RenderScript support library and is also using proguard for obfuscation.我有一个项目正在使用新的RenderScript 支持库,并且还使用 proguard 进行混淆。

Proguard was working great on the code when using the normal RenderScript SDK (android.renderscript.*).当使用普通的 RenderScript SDK (android.renderscript.*) 时,Proguard 在代码上工作得很好。 And the code is working great with the RenderScript support library when compiled in a non-release build where proguard does not run.当在 proguard 不运行的非发布版本中编译时,代码与 RenderScript 支持库一起工作得很好。

But, bring the two together and the result is this:但是,将两者放在一起,结果是这样的:

Warning: android.support.v8.renderscript.RenderScript: can't find referenced class android.os.SystemProperties
Warning: android.support.v8.renderscript.RenderScript: can't find referenced class android.os.SystemProperties
Warning: android.support.v8.renderscript.RenderScriptThunker: can't find referenced method 'android.renderscript.RenderScript create(android.content.Context,int)' in class android.renderscript.RenderScript
      You should check if you need to specify additional program jars.
Warning: there were 2 unresolved references to classes or interfaces.
         You may need to specify additional library jars (using '-libraryjars').
Warning: there were 1 unresolved references to program class members.
         Your input classes appear to be inconsistent.
         You may need to recompile them and try again.
         Alternatively, you may have to specify the option 
         '-dontskipnonpubliclibraryclassmembers'.

I know just enough about proguard to be dangerous.我对 proguard 的了解就足够了。 One thing I have learned is that the suggestions in the warning/error messages tend not to necessarily point at the actual cause of the issue.我了解到的一件事是警告/错误消息中的建议往往不一定指向问题的实际原因。 This time is no different: implementing the suggested changes in the warnings results in no change of the output.这一次也不例外:在警告中实施建议的更改不会导致输出更改。

Can the RenderScript support library be used with proguard? RenderScript 支持库可以与 proguard 一起使用吗? And if so, is there some magic that I need to add to my proguard config to make it work?如果是这样,我是否需要将一些魔法添加到我的 proguard 配置中以使其工作?

-dontwarn android.support.v8.** -不要警告 android.support.v8.**

actually encountered this yesterday...昨天居然遇到了这个……

For androidX对于 androidX

-keep class androidx.renderscript.** { *; -保持类androidx.renderscript.** { *; } }

Combining the previous two ansers, in any modern app that uses Renderscript, you should add the follwing to your proguard-rules.pro file.结合前两个分析器,在任何使用 Renderscript 的现代应用程序中,您应该将以下内容添加到您的proguard-rules.pro文件中。

# Render Script
-keep class android.support.v8.renderscript.** { *; }
-keep class androidx.renderscript.** { *; }

This will take care of both apps that use the Android support library, or Android X这将处理使用 Android 支持库或 Android X 的两个应用程序

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM