Question

I'm using TagSoup in one of my projects and made some modifications to the HTMLSchema.java to cope with nested list tags. When I tested these changes they had no effect at all. I tested the same changes in a Java stand-alone app and they worked as intended.

When I tried to debug the app I noticed that it didn't show the correct line number in the debugger so I did what you usually do in cases like that: re-building the project, restarting the IDE, restarting the Android device and the PC, creating a new Android project, all to no avail.

I removed all code from some of the classes and the app still ran as it did before, so clearly Android used different classes than the ones I deployed with my app. I made an Android test project empty of everything except the usual MainActivity, layout and drawables, added the TagSoup classes and the code to parse with TagSoup and it still didn't use "my" TagSoup classes. I tested this with two 4.4.2 Nexus devices and on a Note 2 running 4.1.2.

Only when I renamed the package name from org.ccil.cowan.tagsoup to something else (like org.ccil.cowan.tagsoup2) did it use the classes deployed with my app.

My question is simple: what the heck is going on?

Was it helpful?

Solution

TagSoup is part of Android itself. A copy of its classes, that ship with the framework, are loaded into your virtual machine automatically... even though they are not part of the Android SDK. You see the same thing with libraries like BouncyCastle.

Refactoring the third-party library -- using jarjar or other means -- allows both Android's version and your version of the library to coexist.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top