我怎么能强迫Proguard的,以保持我的.xml资源文件? [英] How can I force Proguard to keep my .xml resource file?

查看:146
本文介绍了我怎么能强迫Proguard的,以保持我的.xml资源文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我成功地使用ProGuard的我的Andr​​oid应用程序。

I am succesfully using proguard for my Android apps.

然而,有一个应用程序,我遇到麻烦了。

However, with one app I am having trouble.

此应用程序使用的Java库,也可以是存储在包中的的.xml 文件。

This app uses a java library that has a .xml file that is stored in the package.

InputStream istream = Library.class.getResourceAsStream("resource.xml");

该库的伟大工程时,ProGuard的被禁用。但是,运行ProGuard的,似乎xml文件只是完全剥夺。

This library works great when proguard is disabled. However, running proguard, it seems that the xml file is just completely stripped away.

相关proguard.cfg

Relevant proguard.cfg

-optimizationpasses 5
-dontusemixedcaseclassnames
-dontskipnonpubliclibraryclasses
-dontpreverify
#-dontobfuscate
#-repackageclasses '' //THIS IS DISABLED
-keepattributes *Annotation*
-keepattributes Signature
-verbose
-dontwarn roboguice.activity.RoboMapActivity
-optimizations !code/simplification/arithmetic,!field/*,!class/merging/*

在如何强制保留此xml文件任何想法?

Any ideas on how to force keep this xml file?

推荐答案

首先,原来使用蚂蚁和我的build.xml脚本没有处理的.xml资源文件在所有。您需要手动添加复制操作到build.xml的资源文件复制到输出目录。

First of all, It turned out that using ant and my build.xml script didn't process the .xml resource file at all. You'll need to manually add a copy action to the build.xml for the resource files to be copied to the output dir.

不过,已经解决了,ProGuard的搞砸了我的工作。解决方法是:

Still, having solved that, proguard messed up my work. Solution was:

 -keeppackagenames the.package.where.the.file.is.kept

这确信,.xml文件可以通过调用中找到 Library.class.getResource

This made sure that the .xml file could be found by calling the Library.class.getResource.

这篇关于我怎么能强迫Proguard的,以保持我的.xml资源文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆