首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Android Proguard兼容库

Android Proguard兼容库
EN

Stack Overflow用户
提问于 2011-11-01 05:50:16
回答 2查看 5.7K关注 0票数 4

你好,我正在编写一个使用兼容性库的应用程序,我在应用程序中使用了一个视图寻呼机。我还使用了一个操作栏库,这是我从这个链接中获得的。

https://github.com/johannilsson/android-actionbar

我的proguard.cfg文件如下所示

代码语言:javascript
复制
-optimizationpasses 5
-dontusemixedcaseclassnames
-dontskipnonpubliclibraryclasses
-dontpreverify
-verbose
-optimizations !code/simplification/arithmetic,!field/*,!class/merging/*

-keep public class * extends android.app.Activity
-keep public class * extends android.app.Application
-keep public class * extends android.app.Service
-keep public class * extends android.content.BroadcastReceiver
-keep public class * extends android.content.ContentProvider
-keep public class * extends android.app.backup.BackupAgentHelper
-keep public class * extends android.preference.Preference
-keep public class com.android.vending.licensing.ILicensingService

#keep all classes that might be used in XML layouts
-keep public class * extends android.view.View
-keep public class * extends android.app.Fragment
-keep public class * extends android.support.v4.Fragment


#keep all public and protected methods that could be used by java reflection
-keepclassmembernames class * {
    public protected <methods>;
}

-keepclasseswithmembernames class * {
    native <methods>;
}

-keepclasseswithmembernames class * {
    public <init>(android.content.Context, android.util.AttributeSet);
}

-keepclasseswithmembernames class * {
    public <init>(android.content.Context, android.util.AttributeSet, int);
}


-keepclassmembers enum * {
    public static **[] values();
    public static ** valueOf(java.lang.String);
}

-keep class * implements android.os.Parcelable {
  public static final android.os.Parcelable$Creator *;
}

-dontwarn **CompatHoneycomb
-dontwarn org.htmlcleaner.*

然后我的defualt.properties看起来像这样

代码语言:javascript
复制
# This file is automatically generated by Android Tools.
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
#
# This file must be checked in Version Control Systems.
#
# To customize properties used by the Ant build system use,
# "build.properties", and override values to adapt the script to your
# project structure.

# Project target.
target=android-8
android.library.reference.1=../android-actionbar/actionbar
proguard.config=proguard.cfg

然而,当我运行编译和签署我的应用程序时,我会得到一个对话框,上面写着"Proguard返回错误代码1。请参阅控制台“。

因此,我看一下我的控制台,它读到了以下内容

代码语言:javascript
复制
[2011-11-01 01:48:39 - Test App] Proguard returned with error code 1. See console
[2011-11-01 01:48:39 - Test App] proguard.ParseException: Unknown option 'Manager' in argument number 9
[2011-11-01 01:48:39 - Test App]    at proguard.ConfigurationParser.parse(ConfigurationParser.java:170)
[2011-11-01 01:48:39 - Test App]    at proguard.ProGuard.main(ProGuard.java:491)

但这对我来说并不意味着什么,我也不知道该怎么做才能让这件事奏效?我以前在一个不使用兼容性库的应用程序上使用过这个脚本,但是,我从哪里得到的那个脚本说它应该与兼容性库一起工作,但它不能?任何有想法的人都会非常感激的

===EDIT===

在从构建路径中删除空格之后,我能够走得更远一些,但由于错误1仍然失败,控制台现在有了一个新的错误列表,如下所示。

代码语言:javascript
复制
[2011-11-01 14:01:20 - TestApp] Proguard returned with error code 1. See console
[2011-11-01 14:01:20 - TestApp] Warning: android.support.v4.os.ParcelableCompatCreatorHoneycombMR2: can't find superclass or interface android.os.Parcelable$ClassLoaderCreator
[2011-11-01 14:01:20 - TestApp] Warning: android.support.v4.os.ParcelableCompatCreatorHoneycombMR2: can't find referenced class android.os.Parcelable$ClassLoaderCreator
[2011-11-01 14:01:20 - TestApp] Warning: android.support.v4.os.ParcelableCompatCreatorHoneycombMR2: can't find referenced class android.os.Parcelable$ClassLoaderCreator
[2011-11-01 14:01:20 - TestApp] Warning: there were 3 unresolved references to classes or interfaces.
[2011-11-01 14:01:20 - TestApp]          You may need to specify additional library jars (using '-libraryjars'),
[2011-11-01 14:01:20 - TestApp]          or perhaps the '-dontskipnonpubliclibraryclasses' option.
[2011-11-01 14:01:20 - TestApp] java.io.IOException: Please correct the above warnings first.
[2011-11-01 14:01:20 - TestApp]     at proguard.Initializer.execute(Initializer.java:308)
[2011-11-01 14:01:20 - TestApp]     at proguard.ProGuard.initialize(ProGuard.java:210)
[2011-11-01 14:01:20 - TestApp]     at proguard.ProGuard.execute(ProGuard.java:85)
[2011-11-01 14:01:20 - TestApp]     at proguard.ProGuard.main(ProGuard.java:499)
EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2011-11-01 15:00:53

我猜您的项目路径包含空格(在本例中是word Manager)。最新的(ADT R14)仍然存在将包含空格的路径传递给ProGuard的问题。替代工作-周旋:

  • 使用基于Ant的命令行构建。
  • 安装ProGuard 4.7 beta2 (或更高版本)。对于在包含空格的文件名周围缺少引号,则比较宽容。您只需将发布后的jars复制到没有空格的android-sdk/tools/proguard/lib.
  • Use项目路径。
票数 5
EN

Stack Overflow用户

发布于 2011-11-01 15:14:06

这可能不算什么,但当我遇到这个问题时,我所做的是:

Eclipse

  • Install的
  • 更新ADT插件-- android-sdk/tools/proguard
  • Create中ProGuard的最新版本--这是Eclipse中的一个新项目,并将所有类和资源复制到新project
  • Export!

中的新project

  • Configure程序保护程序中

我不知道以前的项目不起作用,但我所知道的是,这个技巧对我有效。我希望它能帮上忙

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/7962926

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档