7

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

enter image description here

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

enter image description here

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?

Community
  • 1
  • 1
an00b
  • 11,338
  • 13
  • 64
  • 101

4 Answers4

9

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.

Community
  • 1
  • 1
Regex Rookie
  • 10,432
  • 15
  • 54
  • 88
  • Thanks +1 for the hope that you gave me for a few moments. Your workaround didn't help in my case, but what I did after that allowed me to export a signed APK for the first time since I upgraded! Here is what I did: (1) I ran CCleaner to clean all temp files and caches in the Windows system, (2) then I rebooted Windows. And it worked! but to my dismay, the next time I tried to export I received the same `Failed to export application` with **no console messages!**. Now it's clear to me that the Android dev tools have become unstable. What do I do now? – an00b Jun 14 '12 at 21:14
  • 1
    It worked! **Without** the `-dontwarn` that is. It turned out I needed to do steps #1 & #2 in your EDIT for **each and every library project** on which my application project is dependent. That did the magic. Thank you! You rock!!! – an00b Jun 15 '12 at 19:26
2

How about your error log. Window->Show View->Error Log. Is separate to Console output, error code 1's tend to show up in here.

weston
  • 54,145
  • 21
  • 145
  • 203
  • Thanks +1 for the hope that you gave me for a few moments. The error log provides no further information (see screenshot update in the original post). – an00b Jun 14 '12 at 19:29
  • 1
    Does it export ok with proguard turned off? – weston Jun 14 '12 at 23:22
  • Yes, it exports OK with Proguard turned off. 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? – an00b Jun 15 '12 at 00:18
1

try to reinstall your ADT Plugin in eclipse

Boe-Dev
  • 1,585
  • 2
  • 14
  • 26
  • 3
    LOL. Looks like [voodoo](http://stackoverflow.com/a/8749008/1124861). Maybe the OP should upgrade his Eclipse as well? He didn't provide any information about his Eclipse version. – Bill The Ape Jun 14 '12 at 17:01
  • 2
    @BillTheApe Not voodoo. Proguard hell: http://stackoverflow.com/questions/6974231/proguard-hell-cant-find-referenced-class – Regex Rookie Jun 14 '12 at 17:12
  • @BillTheApe My Eclipse is 3.6.2. Is this a problem? How do I reinstall my ADT plugin? I fired up Android SDK Manager and it shows that `Android SDK Tools` Rev 19 and `Android SDK Platrform-tools` Rev 11 are installed and up to date. How do I make them re-install? – an00b Jun 14 '12 at 17:31
  • 1
    go to help>about eclipse>install detail then choose ADT parts an uninstall it. – Boe-Dev Jun 14 '12 at 17:38
  • @Boe-Dev Thanks. I did just that and I don't get "Failed to export application" anymore but now I get a new error never seen before `Proguard returned with error code 1. See console` with the console showing 17 unresolved references to classes. All these classes exist of course so I have no idea why it fails and where to go from here. Suggestions? – an00b Jun 14 '12 at 17:58
  • @Boe-Dev But the console error messages disappeared again and now all I am getting is the original error message `Failed to export application` with **no console messages!**. This is beyond belief. What am I supposed to do with tools so unpredictable??? – an00b Jun 14 '12 at 18:51
0

Here was the key that worked for me

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

Supposedly fixed in ADT-15, the workaround is

1) For each X_src element,right click on it and then Build Path > Remove from build path.

2) A popup will open. Make sure that “Also unlink the folder from the project” is checked and then accept it.

You can still debug into library code but you need to manage your breakpoints in those projects and then step through the code in the class file tabs.

Melinda Green
  • 2,100
  • 1
  • 21
  • 32