Home > Mobile >  [for] projects write their own class and import the class in the jar package repeated, solving
[for] projects write their own class and import the class in the jar package repeated, solving

Time:10-06

Recently, as the topic, to develop payment functions, projects myself writing class and import the jar package classes in the repeated, not just the name of the class, even the package name repeated,
Such as my own project has com. Firefliex. Utils. FxUtils class, import the jar the bag also has a com. Firefliex. Utils. FxUtils class,
Almost all checked some information on the net, is to solve "import two jars in class repeat" problem, change the loading sequence to go, but the problem on my side is awkward in his own project has much written in by my own FxUtils class, and the realization of the function of pay to use the jar bag FxUtils class, if only load one, the other a corresponding function definitely can't find the corresponding method,

In addition, change their project FxUtils class while it is possible to solve the problem, but there are too many references in this class project, cannot be easily modified, so, in addition to the change path, the name of the class, there is no other way, the small white one, before development projects are too simple, not encountered similar problems, the great god help ~

CodePudding user response:

Modify the name of the class in their project is one of the most simple way

CodePudding user response:

reference 1st floor zhang106209 response:
modify the name of the class in your project is the easiest way to the

So, but this class has 1000 + is referenced, the company projects can't disorderly change

CodePudding user response:

You change class names are unified, generally do not have a problem, you can backup first, then change the look with no problem

CodePudding user response:

All commit code, right-click the Rename directly, what all not afraid, will all change automatically, and then submit alone,
And why is your package name will com. Firefliex. Utils? The package name is not "com. Your company or your own name. XXX" can you repeat this?

CodePudding user response:

You now a jarjar, use this can change the package name unified

CodePudding user response:

Problem has been solved, thanks to the above, reply, back to summarize:
I here is not the problem of two jars in the class repeat the fully qualified name, but in the project of a class and a class repeated in the jars, and this method is not repeated in the two classes, two classes are in different places plays a role, but class loading mechanism leads to a kind of load, another class will be ignored, so the default way, there must be some part of the method to find, part function can't achieve,
My solution: repeat the class in the jar package all methods of copy and paste into my own project in this class, the equivalent of two classes, even in the jars that class obfuscated it doesn't matter,
Why will appear this kind of circumstance? Because of my department need another department in the company development and open platform products, because it is the same company, and comparative basis, so the fully qualified name to repeat this problem (com.com panyname. Utils. XXUtil),