Saturday, December 30, 2017

How to update ProGuard for Android SDK

If still using Eclipse for Android app development and targeting newer Android SDK versions you may find ProGuard failing with this error message:
Can't process class [junit/runner/Version.class] (Unsupported class version number [52.0] (maximum 51.0, Java 1.7)) 
Proguard returned with error code 1. See console
Proguard Error 1 
Output: 
java.io.IOException: Can't read [U:\Android\android-sdk\platforms\android-27\android.jar] (Can't process class [junit/runner/Version.class] (Unsupported class version number [52.0] (maximum 51.0, Java 1.7))) 
 at proguard.InputReader.readInput(InputReader.java:230) 
 at proguard.InputReader.readInput(InputReader.java:200) 
 at proguard.InputReader.readInput(InputReader.java:178) 
 at proguard.InputReader.execute(InputReader.java:100) 
 at proguard.ProGuard.readInput(ProGuard.java:196) 
 at proguard.ProGuard.execute(ProGuard.java:78) 
 at proguard.ProGuard.main(ProGuard.java:492) 
Caused by: java.io.IOException: Can't process class [junit/runner/Version.class] (Unsupported class version number [52.0] (maximum 51.0, Java 1.7)) 
 at proguard.io.ClassReader.read(ClassReader.java:112) 
 at proguard.io.FilteredDataEntryReader.read(FilteredDataEntryReader.java:87) 
 at proguard.io.JarReader.read(JarReader.java:65) 
 at proguard.io.DirectoryPump.readFiles(DirectoryPump.java:65) 
 at proguard.io.DirectoryPump.pumpDataEntries(DirectoryPump.java:53) 
 at proguard.InputReader.readInput(InputReader.java:226) 
 ... 6 more 
Caused by: java.lang.UnsupportedOperationException: Unsupported class version number [52.0] (maximum 51.0, Java 1.7) 
 at proguard.classfile.util.ClassUtil.checkVersionNumbers(ClassUtil.java:140) 
 at proguard.classfile.io.LibraryClassReader.visitLibraryClass(LibraryClassReader.java:89) 
 at proguard.classfile.LibraryClass.accept(LibraryClass.java:301) 
 at proguard.io.ClassReader.read(ClassReader.java:86) 
 ... 11 more 

Cause

Newer versions of Android platform are compiled as Java 8 binary and ProGuard 4.7 coming with Android SDK Tools doesn't support it (last updated with SDK Tools Revision 17, March 2012).
> cd \android-sdk\tools\proguard\bin
> proguard
ProGuard, version 4.7
Usage: java proguard.ProGuard [options ...]

Solution

Java 8 support is available with Proguard 5.x onwards, so we will update to the latest version available, in my case 5.3.3 from Apr 2017.
  1. Move / rename the old version:
    rename \android-sdk\tools\proguard\ proguard.old
  2. Download the zip file from SourceForce
     
  3. Extract the contents into \android-sdk\tools\ renaming the new folder to proguard
    rename \android-sdk\tools\proguard5.3.3\ proguard
  4. Check the new version:
    > cd \android-sdk\tools\proguard\bin\
    > proguard
    ProGuard, version 5.3.3
    Usage: java proguard.ProGuard [options ...]
  5. Copy the Android configuration files over:
    > cd \android-sdk\tools\
    > copy proguard.old\proguard-*.txt proguard\
    proguard.old\proguard-android-optimize.txt
    proguard.old\proguard-android.txt
    proguard.old\proguard-project.txt
            3 file(s) copied.
Exporting the APK package again should work now.

Monday, December 11, 2017

Fix: Wireless Display "Your display couldn't connect"

 You may find when trying to project to an wireless display Windows will fail with the following error message, even though other similar computers on your network can project just fine:

    Something went wrong.
    Your display couldn't connect.



Intel ProSet/Wireless Software > Modify > Wireless Software Extensions





Windows Defender Security Center > Firewall & network protection > Restore firewalls to default





Try again projecting and confirm it is working fine now.