无法升级到ProGuard的4.8后导出应用(Failed to export applicatio

2019-09-18 03:28发布

I just upgraded my Android SDK, ADT and Proguard to the latest and greatest.

My project compiles builds and runs fine in debug mode, but as soon as I try to export a signed release APK of it, I receive an error from the Export Wizard without any error log messages on the Eclipse console!*

If I try to view the error log via Window->Show View->Error Log all I see is more of the same:

I have no idea what to do because neither Eclipse nor Proguard would give any hint about what the problem could be.

My project exported fine until this recent upgrade. No build warnings. No lint warnings!

I am using the standard configuration file for Android in ${sdk.dir}\tools\proguard\proguard-android.txt:

-dontusemixedcaseclassnames
-dontskipnonpubliclibraryclasses
-verbose

-dontoptimize
-dontpreverify

-keepattributes *Annotation*
-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.BackupAgent
-keep public class * extends android.app.backup.BackupAgentHelper
-keep public class * extends android.preference.Preference
-keep public class * extends android.support.v4.app.Fragment
-keep public class * extends android.app.Fragment
-keep public class com.android.vending.licensing.ILicensingService

-keepclasseswithmembernames class * {
    native <methods>;
}

-keep public class * extends android.view.View {
    public <init>(android.content.Context);
    public <init>(android.content.Context, android.util.AttributeSet);
    public <init>(android.content.Context, android.util.AttributeSet, int);
    public void set*(...);
}

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

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

-keepclassmembers class * extends android.app.Activity {
   public void *(android.view.View);
}

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

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

-keepclassmembers class **.R$* {
    public static <fields>;
}

-dontwarn android.support.**

And my project's proguard.cfg only contains:

-assumenosideeffects class android.util.Log {
    public static *** v(...);
    public static *** i(...);
    public static *** d(...);
    public static *** w(...);
    public static *** e(...);
}

Anyone seen this problem before? Any idea how to fix this?

Some progress? I was able to export a signed APK for the first time since I upgraded by doing this:

  1. I ran CCleaner to clean all temp files and caches in the Windows system,
  2. Then I rebooted Windows.

But to my dismay, the next time I tried to export the signed APK again, I received the same Failed to export application with no console messages! Again!

Now it's clear to me that the Android dev tools have become unstable. I can't really run CCleaner and reboot Windows every time I want to export a signed APK. And I don't care whose fault is it: Android SDK? ADT plugin? Proguard?

What do I do now?

Some more progress? I tried exporting a signed APK with Proguard turned off. It exported OK but when I launch it, it immediately crashes for being unable to find the application's activity class (ClassNotFoundException). This is weird! It runs fine in debug mode and if the application's activity class weren't there, it shouldn't have compiled! What's going on? Are the latest & greatest Android dev tools broken?

I tried playing with the Order and Export tab as described in this solution (and this one too) but it didn't help.

What do I do now?

Answer 1:

您正在运行的是Windows XP,所以我不知道我能帮助(我运行Windows 7 64位),但@ BOE-开发您的评论对“17类未解决的引用”让我想起了我最近的磨难与升级你类似的:

我解决它通过将下面的行proguard.cfg

-dontwarn com.bta.myapp.MyAppActivity.R**

不知道你的问题是我的一样,但它可能是值得一试。

编辑:我注意到,即使你关闭Proguard的你有问题,我可以建议以下?

  1. 从标准的Java构建路径删除库:右键单击项目名称>属性> Java构建路径>标签库>删除以外的所有“Android的XX”和“Android的依赖关系”
  2. 重命名库从“LIB”到“库”文件夹中。 通过这样做,在文件夹“库”中的所有库由Android插件找到,并添加到项目的“Android的依赖关系”项目
  3. 清理项目(总需要给出的Android开发工具是如何不可预知的是)

让我们知道它是如何工作的。



Answer 2:

谈谈你的错误日志。 窗口 - >显示视图>错误日志。 是独立于控制台输出,错误码1的倾向在这里露面。



Answer 3:

尝试重新安装你的ADT插件在Eclipse



Answer 4:

这里是为我工作的关键

http://android.foxykeep.com/dev/fix-the-conversion-to-dalvik-format-failed-with-error-1-with-adt-14

推测固定于ADT-15,解决方法是

1)对于每个X_src元素,右键单击它,然后构建路径>从构建路径中删除。

2)弹出框将打开。 确保选中“同时从项目断开链接的文件夹”,然后接受它。

您仍然可以调试库代码,但你需要管理你的断点在这些项目中,然后通过在类文件选项卡上的代码步骤。



文章来源: Failed to export application after upgrade to Proguard 4.8