升级到Proguard 4.8后无法导出应用程序 [英] Failed to export application after upgrade to Proguard 4.8

查看:227
本文介绍了升级到Proguard 4.8后无法导出应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚将Android SDK,ADT和Proguard升级到最新,最棒。



我的项目编译构建并在调试模式下运行正常,但是一旦我尝试导出签名的版本APK,我会从导出向导在Eclipse控制台上没有任何错误日志消息!*





如果我尝试通过查看错误日志窗口>显示视图> ;错误日志所有我看到的都是一样的:





我不知道该怎么办,因为Eclipse和Proguard都不会给任何提示关于什么问题可能是。



我的项目导出正常,直到最近的升级。没有建立警告。没有lint警告!



我在 $ {sdk.dir} \tools\proguard\proguard中使用Android的标准配置文件-android.txt

  -dontusemixedcaseclassnames 
-dontskipnonpubliclibraryclasses
-verbose

-dontoptimize
-dontpreverify

-keepattributes *注释*
-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 publi c 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枚举* {
public static ** [] values();
public static ** valueOf(java.lang.String);
}

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

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

-dontwarn android.support。**

而我的项目的proguard.cfg只包含:

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

以前有人看到这个问题吗?
任何想法如何解决这个问题?



有些进展?自从我以来,我第一次导出了一个签名的APK升级为这样做:


  1. 我运行CCleaner清理Windows系统中的所有临时文件和缓存,

  2. 然后我重新启动Windows。但是令我失望的是,下次再次尝试导出已签名的APK时,我收到了相同的无法导出应用程序没有控制台消息!再次!



    现在我很清楚,Android开发工具变得不稳定。每次要导出已签名的APK时,我都无法真正运行CCleaner并重新启动Windows。我不在乎他的错误是什么:Android SDK? ADT插件? Proguard?



    现在我该怎么办?



    尝试导出已签名的APK与Proguard关闭。它导出了OK,但是当我启动它时,它立即崩溃,因为无法找到应用程序的活动类( ClassNotFoundException )。这很奇怪!它在调试模式下运行正常,如果应用程序的活动类不在,则不应该编译!这是怎么回事?是最新&最好的Android开发工具破损?



    我尝试使用订单和导出选项卡,如这个解决方案(和这一个)也是),但它没有帮助。



    现在我该怎么办?

    解决方案

    您正在运行Windows XP,所以我不知道我可以帮助(我运行的是Windows 7 64位),但您对@ Boe-Dev的评论有关17个未解决的对课程的引用,提醒我我的最近的升级与您的升级类似:



    解决了通过在 proguard.cfg 中放置以下行:

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

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



    编辑:注意到即使关闭Proguard您遇到问题,可以建议以下内容吗?


    1. 从标准Ja​​va构建路径中删除库:右键单击项目名称>属性> Java构建路径>选项卡库>删除除Android XX和Android依赖关系之外的所有内容

    2. 将库文件夹从lib重命名为libs 。通过这样做,文件夹libs中的所有库都由Android插件找到,并被添加到项目的Android依赖关系项目中。

    3. 清理项目(必须给定Android开发工具有多么不可预测)

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


    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?

    解决方案

    You're running Windows XP so I'm not sure I can help (I'm running Windows 7 64-bit) but your comment to @Boe-Dev about "17 unresolved references to classes" reminded me of my recent ordeal with an upgrade similar to yours:

    I solved it by placing the following line in proguard.cfg:

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

    Don't know if your problem is the same as mine but it may be worth a try.

    EDIT: Noticing that even when your turn off Proguard you are having problems, can I suggest the following?

    1. Remove the libraries from the standard Java build path: Right click on the project name > Properties > Java Build Path > tab Libraries > remove everything except the "Android X.X" and the "Android Dependencies"
    2. Rename the libraries folder from "lib" to "libs". By doing that, all the libraries in the folder "libs" are found by the Android plugin and are added to the "Android Dependencies" item of the project
    3. Clean the project (always necessary given how unpredictable the Android dev tools are)

    Let us know how it worked.

    这篇关于升级到Proguard 4.8后无法导出应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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