I have an Android project using Rome for rss, that works perfectly fine when using the debug build (refer to down below). But when I switch to release, it gives me:
java.lang.ClassNotFoundException: Didn't find class "com.rometools.rome.feed.synd.impl.ConverterForAtom10" on path: DexPathList[[zip file "/data/app/~~KaWHVUAFHxJthThQtBTQVg==/com.theredspy15.thanelocker-Yv1ajdDGETGskLhAp9OAmw==/base.apk"],nativeLibraryDirectories=[/data/app/~~KaWHVUAFHxJthThQtBTQVg==/com.theredspy15.thanelocker-Yv1ajdDGETGskLhAp9OAmw==/lib/arm64, /system/lib64, /system/system_ext/lib64]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:207)
Along with:
java.lang.ClassNotFoundException: com.rometools.rome.feed.synd.impl.ConverterForAtom10
The error also mentions this line:
feed = input.build(new XmlReader(new URL(url)));
My build types: (normally minify is enabled & debug is false)
debug {
minifyEnabled false
shrinkResources false
debuggable true
signingConfig signingConfigs.debug
}
release {
minifyEnabled false
shrinkResources true
debuggable true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.release
}
My best guess is only that proguard is removing something it shouldn't be. I am using the default proguard rules file with android studio. Everything is latest version and if it is related to proguard rules, I have no idea how to allow Rome to work in this situation on both debug and release build types
A -keep option as the one below should do the trick, it prevents ProGuard from removing the class and renaming it. You might see similar issues for different classes and methods show up afterwards, you will need to add a -keep option for those as well.
-keep class com.rometools.rome.feed.synd.impl.ConverterForAtom10
While creating these -keep options try not to use too many wildcards, it will allow ProGuard to better shrink, optimize and obfuscate the code. You can see the impact of your -keep rules in a visual way using the ProGuard Playground.