0

In my Android project I'm using barcodescanner.

I need to customize the size of the framing rectangle displayed when targeting a qr code and I noticed that the only way to achieve this is to modify a class in the library.

Now I'm wondering, what is the best way to include the changes I made to the library?

It would be great if I could simply include the class with the original package in my sources as I used to do in some java projects, however in Android I get an error:

com.android.dex.DexException: Multiple dex files define Lme/dm7/barcodescanner/core/ViewFinderView;

because it finds 2 classes with the same signature (1 in the library and 1 in my source code).

Is there a way to avoid this conflict? Or are there better ways to include the 3rd party library with the changes?

Community
  • 1
  • 1
Giordano
  • 1,401
  • 15
  • 26
  • 2
    Quick answer without doing all the legwork to explain it all like I should: Fork the repo, make the changes and push them to your fork, then point gradle to your fork. – Jon Adams Feb 01 '16 at 18:06
  • I guess I need to include the built forked libs (=aar files) in my project, unless I publish the artifacts to some repository. Correct? – Giordano Feb 01 '16 at 18:13
  • 1
    Is there no way you can simply extend the classes and override their behavior? – Drazen Bjelovuk Feb 01 '16 at 18:13
  • Unfortunately no... I would need to modify and import in my project 4 classes just to change the value of a private static final constant... I'm trying to understand if there is a cleaner and easier-to-maintain way than doing that. – Giordano Feb 01 '16 at 18:16

1 Answers1

1

Git clone the library project to your computer, make all the changes you need, then add it to you project as a library module:

New module -> import gradle project

Mark it a module dependency for your app module:

Open module settings -> dependencies -> add module dependency

Remove old dependency from build.gradle to avoid

multiple dex files define ...

error.

fweigl
  • 21,278
  • 20
  • 114
  • 205