Android Proguard 兼容性库

发布于 2024-12-13 04:48:26 字数 4457 浏览 3 评论 0原文

您好,我正在编写一个使用兼容性库的应用程序,并且我在应用程序中使用视图寻呼机。 获得的操作栏库

我还使用从此链接https://github.com/johannilsson/android -actionbar

我的 proguard.cfg 文件看起来像这样

-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 看起来像这样

# 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。请参阅控制台。 ”

所以我看了一下我的控制台,上面写着以下内容

[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)

但这对我来说并没有多大意义,我不知道我应该做什么才能让它工作?我之前在不使用兼容性库的应用程序上使用过该混淆脚本的任何想法,但是,我获得该脚本的地方说它应该与兼容性库一起使用,但事实并非如此?任何人有任何想法,我们将不胜感激

===编辑===

从我的构建路径中删除空格后,我能够走得更远,但仍然失败,错误 1 ​​控制台现在有一个新的错误列表现在看起来像这样。

[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)

Hello I'm writing an application that uses the compatibility library and i'm using a view pager in the app. I also am using an action bar library which i got from this link

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

my proguard.cfg file looks like this

-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.*

and then my defualt.properties looks like this

# 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

However when i run to compile and sign my app i get a dialog that reads "Proguard returned with error code 1. See console."

So i take a look at my console which reads the following

[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)

But this doesn't really mean much to me and i don't know what i'm supposed to do to get this working? Any ideas i've used that proguard script before on an app that didn't use the compatibility library, however, the place i got that script from says it should work with the compatibility library but its not? Anyone have any ideas it would be greatly appreciated

===EDIT===

After removing the spaces from my build path i was able to get a bit farther but still failed with error 1 the console now had a new list of errors which looks like this now.

[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)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

美人骨 2024-12-20 04:48:26

我猜测您的项目路径包含空格(在本例中为“Manager”一词)。用于 Eclipse 的最新 Android 插件 (ADT R14) 在将包含空格的路径传递给 ProGuard 时仍然存在问题。替代解决方法:

  • 使用基于 Ant 的命令行构建。问题应该在那里解决。
  • 安装 ProGuard 4.7 beta2(或更高版本)。对于包含空格的文件名周围缺少引号的情况更为宽松。您只需下载该版本并将 jar 从 proguard/lib 复制到 android-sdk/tools/proguard/lib 即可。
  • 使用不带空格的项目路径。

I'm guessing your project path contains spaces (and in this case the word Manager). The latest Android plugin for Eclipse (ADT R14) still has problems passing paths containing spaces to ProGuard. Alternative work-arounds:

  • Use the command-line build based on Ant. The problem should be solved there.
  • Install ProGuard 4.7 beta2 (or later). It is more lenient for missing quotes around file names containing spaces. You can just download the release and copy the jars from proguard/lib to android-sdk/tools/proguard/lib.
  • Use a project path without spaces.
网名女生简单气质 2024-12-20 04:48:26

这可能是几件事,但当我遇到这个问题时我所做的是:

  • 更新 Eclipse 的 ADT 插件
  • 在 android-sdk/tools/proguard 中安装最新版本的 ProGuard
  • 在 Eclipse 中创建一个新项目并将所有类和资源复制到新项目
  • 在新项目中配置proguard
  • 导出!

我不知道以前的项目是否有效,但我知道这个技巧对我有用。我希望它有帮助

It could be few things, but what I did when I had that problem was:

  • Update ADT plugin for Eclipse
  • Install the latest version of ProGuard in android-sdk/tools/proguard
  • Create a new project in Eclipse and copy all the classes and resources to the new project
  • Configure proguard in the new project
  • Export!

I don't know with the previous project didn't work, but what I know is that trick worked for me. I hope it helps

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文