orbisgis / cts

Projection library in Java
GNU Lesser General Public License v3.0
50 stars 16 forks source link

Error when minifyEnabled true ini gradle script #102

Closed ptsagkis closed 5 years ago

ptsagkis commented 5 years ago

Hi there,

I am developing an android app that executes some projection transformations. Recently I face the following problem. When I set on gradle script minifyEnabled true my apk may be build without any errors, but when I call

GeodeticCRS targetGCRS = (GeodeticCRS) cRSFactory.getCRS(epsgCode); I get the following error

Unable to access CRS file: epsg . And this is happening only when minifyEnabled true. So it seems there is a confusion with class names of CTS when obfuscation takes place. (check 1 and 2 stackoverflow links) I ended up excluding org.cts from the process of obfuscation . To do so you just need to add the following line in proguard file of the app. -keep class org.cts.** { *; } In my case I added the line above in proguard-rules.pro file which is configured to be used in my gradle script.

And inside my gradle script I do force my app to use this proguard file. default

And here is the location of my proguard file default

An finally the contents of the file default

I dont expect any action, I just share my workaround for people facing the same problem.

  1. https://stackoverflow.com/questions/39098768/after-setting-the-minifyenabled-as-true-im-getting-the-following-error
  2. https://stackoverflow.com/questions/36249005/minifyenabled-true-leads-to-crash-on-app-start
SPalominos commented 5 years ago

Thank you very much for the troubleshoot! We have added it to the wiki to keep track of it.