0

I need help with this, the problem is that the project i'm working needs a custom tile map provider for maps, the project usually takes no longer than 30 seconds to build, with online gradle and all that.

The problems begin when I add the images with the custom tiles to the assets folder, the build times can take up to 3 hrs. or as little as 10 minutes then I get this error.

java.lang.OutOfMemoryError: GC overhead limit exceeded

I've found that with this setting added to the gradle settings the error should go away, but it doesn't work.

dexOptions { 
          incremental true 
          javaMaxHeapSize "4g" 
} 

I've been thinkering with this option and increasing it to even 8g but it does nothing.

When i try to build the app the cpu goes to 100% and 7.9Gb out of 8Gb ussage until the build crashes and I get the previous error.

the app needs to work offline so i cant download the tiles and the size of the app isnt important as it wont be released through any app store, and will be installed directly by us to some devices.

The tiles folder is about 250Mb in size and has about 30000 files, 7000 files but I keep having the same results.

Is it because of the files size, ammount of files?, maybe both?

Any help will be appreciated, I'm "new" to android development, I leanrt some basics in 2011, but hadn't done or learnt anything until about 4 months ago, so I'm kinda lost.

Also sorry if there is something misspelled or is worded in a weird way, I'm not a native english speaker.

Edit:

Extra details as Morrishon Chang asked
OS: window 10
Memmory: 8Gb
JDK: 1.8.0_144
average tile image size: 13kb
image tile format: png
image tiles ammount: about 32000 images
  • Given that the recommended max size for a Google Play app is [100MB](https://developer.android.com/google/play/expansion-files), and you won't be using the App store, what about having your assets as a second file which is loaded on external memory/SD card. – Morrison Chang Aug 10 '18 at 22:44
  • @MorrisonChang it's a good idea but the devices that will be using it do not have an sd card slot, altough it could be transfered to a file to the internal memory, I dont think my boss would like that option, but if everything else fails I'll try to convince my boss about it – Nicolás Medina Parra Aug 13 '18 at 12:36
  • Perhaps it may help if you described your build setup (OS/memory/version of JDK) as well as the size & type of tile image you are trying to build with. Possibly related article: https://medium.com/@duhroach/smaller-pngs-and-android-s-aapt-tool-4ce38a24019d – Morrison Chang Aug 13 '18 at 16:34
  • @MorrisonChang thanks i'll read that article and see if it has something that can help me to build the app – Nicolás Medina Parra Aug 13 '18 at 21:00

1 Answers1

1

First, I would recommend to use Android Drawable Importer plugin. You can access it from Android Studio -> Preferences -> Plugins, I usually import assets using that plugin and everything works fine.

Second, I would suggest you to use image processing library, such as Glide, which is really powerful in my opinion.

Third, try to optimize the loading of your tile, maybe use RecyclerView?

Good luck!

  • Thanks, I'll try what you said about the importer plugin, then i'll see tath library, but the third option is way ahead of what I have, android studio doesn't even build the apk so no recyclerview to optimize, and i'm using the solution in [this](https://stackoverflow.com/a/14833256/10210526) question that i found was usefull for us – Nicolás Medina Parra Aug 13 '18 at 12:41