Hi Guys! I am testing Proguard to apply for all Java project in my company. But after I run obfucate code my jar file cannot run as normal. Could you please help me to check. Here is the error I got:
Error: Could not find or load main class org.springframework.boot.loader.JarLauncher
Caused by: java.lang.ClassNotFoundException: org.springframework.boot.loader.JarLauncher
-dontskipnonpubliclibraryclasses
-printmapping mapping.txt
-ignorewarnings
-keep public class com.example.MyMain {
public static void main(java.lang.String[]);
}
I even cannot obfuscate code. Here is the error I got:
Unexpected error while performing partial evaluation:
Class = [org/springframework/boot/loader/Launcher]
Method = [createArchive()Lorg/springframework/boot/loader/archive/Archive;]
Exception = [java.lang.IllegalArgumentException] (Can't find common super class of [org/springframework/boot/loader/archive/JarFileArchive] (with 1 known super classes) and [org/springframework/boot/loader/archive/ExplodedArchive] (with 1 known super classes))
java.lang.RuntimeException: java.lang.IllegalArgumentException: Can't find common super class of [org/springframework/boot/loader/archive/JarFileArchive] (with 1 known super classes) and [org/springframework/boot/loader/archive/ExplodedArchive] (with 1 known super classes)
at proguard.classfile.visitor.ParallelAllClassVisitor.visitClassPool(ParallelAllClassVisitor.java:126)
at proguard.classfile.ClassPool.accept(ClassPool.java:111)
at proguard.optimize.Optimizer$TimedClassPoolVisitor.visitClassPool(Optimizer.java:1716)
at proguard.optimize.info.RepeatedClassPoolVisitor.visitClassPool(RepeatedClassPoolVisitor.java:78)
at proguard.classfile.ClassPool.accept(ClassPool.java:111)
at proguard.optimize.Optimizer.execute(Optimizer.java:530)
at proguard.ProGuard.optimize(ProGuard.java:447)
at proguard.ProGuard.execute(ProGuard.java:165)
at proguard.ProGuard.main(ProGuard.java:594)
Caused by: java.lang.IllegalArgumentException: Can't find common super class of [org/springframework/boot/loader/archive/JarFileArchive] (with 1 known super classes) and [org/springframework/boot/loader/archive/ExplodedArchive] (with 1 known super classes)
at proguard.evaluation.value.TypedReferenceValue.findCommonClass(TypedReferenceValue.java:527)
at proguard.evaluation.value.TypedReferenceValue.generalize(TypedReferenceValue.java:320)
at proguard.evaluation.value.TypedReferenceValue.generalize(TypedReferenceValue.java:225)
at proguard.evaluation.value.TracedReferenceValue.generalize(TracedReferenceValue.java:276)
at proguard.evaluation.value.TracedReferenceValue.generalize(TracedReferenceValue.java:163)
at proguard.evaluation.value.ReferenceValue.generalize(ReferenceValue.java:354)
at proguard.evaluation.Stack.generalize(Stack.java:143)
at proguard.evaluation.TracedStack.generalize(TracedStack.java:149)
at proguard.optimize.evaluation.PartialEvaluator.evaluateSingleInstructionBlock(PartialEvaluator.java:805)
at proguard.optimize.evaluation.PartialEvaluator.evaluateInstructionBlock(PartialEvaluator.java:723)
at proguard.optimize.evaluation.PartialEvaluator.evaluateInstructionBlockAndExceptionHandlers(PartialEvaluator.java:681)
at proguard.optimize.evaluation.PartialEvaluator.visitCodeAttribute0(PartialEvaluator.java:317)
at proguard.optimize.evaluation.PartialEvaluator.visitCodeAttribute(PartialEvaluator.java:230)
at proguard.classfile.attribute.visitor.MultiAttributeVisitor.visitCodeAttribute(MultiAttributeVisitor.java:278)
at proguard.classfile.attribute.visitor.DebugAttributeVisitor.visitCodeAttribute(DebugAttributeVisitor.java:322)
at proguard.classfile.attribute.CodeAttribute.accept(CodeAttribute.java:141)
at proguard.classfile.ProgramMethod.attributesAccept(ProgramMethod.java:101)
at proguard.classfile.attribute.visitor.AllAttributeVisitor.visitProgramMember(AllAttributeVisitor.java:95)
at proguard.classfile.util.SimplifiedVisitor.visitProgramMethod(SimplifiedVisitor.java:93)
at proguard.optimize.OptimizationInfoMemberFilter.visitProgramMethod(OptimizationInfoMemberFilter.java:99)
at proguard.classfile.ProgramMethod.accept(ProgramMethod.java:93)
at proguard.classfile.ProgramClass.methodsAccept(ProgramClass.java:588)
at proguard.classfile.visitor.AllMethodVisitor.visitProgramClass(AllMethodVisitor.java:47)
at proguard.classfile.ProgramClass.accept(ProgramClass.java:430)
at proguard.classfile.visitor.ParallelAllClassVisitor$MyThreadedClassVisitor$1.run(ParallelAllClassVisitor.java:197)
at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.base/java.lang.Thread.run(Thread.java:830)
Could you please guide me how to fix it? Thanks in advance.
You don’t have any -libraryjars config which means that ProGuard has an incomplete class hierarchy. This will cause issues during optimization. ProGuard Manual: Troubleshooting | Guardsquare