Using ProGuard on my jar files has broken my calls to class.getResource("")
. I have seen that in the ProGuard manual you need to specify the -keepdirectories mypackage
(manual link). However, I have specified the -keepdirectories
option and it doesn't seem to be working. I think there is something wrong with my ProGuard configuration. I have also looked at this related question, but I am having trouble getting the -keeppackagenames
working as well.
In my code I have something similar to the following.
package com.example.mypackage;
public class MyClass{
public static void main(String [] args){
//url is always returned as null
URL url = MyClass.class.getResource("");
//do additional stuff including retrieving manifest file
}
}
ProGuard Configuration
-injars ...
-outjars ...
-libraryjars ...
-dontoptimize
-keepattributes SourceFile,LineNumber,Table,LocalVariable*Table,*Annotation*
-renamesourcefileattribute SourceFile
-repackageclasses
-overloadaggressively
-keep public class com.example.mypackage.MyClass{
public static void main(java.lang.String[]);
}
-keepdirectories com.example.mypackage,com.example.mypackage.MyClass
-keeppackagenames com.example.mypackage,com.example.mypackage.MyClass
ProGuard expects dots in packages names, and slashes in file names and directory names:
-keeppackagenames com.example.mypackage
-keepdirectories com/example/mypackage
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With