ProGuard: Problems using obfuscated JAR

2019-08-07 07:32发布

问题:

I have a JAR myapp-logic with classes, some of which are obfuscated and some non-obfuscated.

I want to use myapp-logic in a web application called myapp-web. When I add the obfuscated version of myapp-logic to the dependencies of myapp-web, I get following error message (when I run mvn clean compile):

EntryPageController.java:[55,41] incompatible types
found   : java.lang.Object
required: ru.altruix.ccp.logic.api.simfacade.SimulationFacade

The code with the error looks like this:

final SimulationFacadeFactory factory = this.injector.getInstance(SimulationFacadeFactory.class);
simulationFacade = factory.create(); // The error occurs here (line 55)

When I open the obfuscated myapp-logic JAR with Jad, SimulationFacadeFactory interface is not obfuscated (or looks like it was not obfuscated):

Original code:

package ru.altruix.ccp.logic.api.simfacade;

import ru.altruix.commons.api.conventions.Factory;

public interface SimulationFacadeFactory extends Factory<SimulationFacade> {
}

Eclipse doesn't show that error (it appears only in Maven).

What can I do in order to fix the error (make the code of myapp-web compile with reference to obfuscated myapp-logic) ?

回答1:

Try if that helps: In your Proguard Rules, especially the keep Signature might help.

<keepattribute name="*Annotation*" />
<keepattribute name="Signature" />
<keepattribute name="Exceptions" />