1

I have an app that uses lots of audio and video files which increases the size of the apk. I don't want the user to download the audio and video files from the internet every time, I want to bundle it with the apk. What are the design options available ?

megjosh
  • 101
  • 1
  • 9
  • 2
    You have them download the video and audio files. If you have the originals you can try to re-encode them at a higher compression ratio/better codec, but that may result in quality loss. Video is already compressed (and audio generally is), so that's all you can do. You don't need them to download it every time though- save them to disk when they download it, and check if they're on disk before you download them again. If they are, use that version instead. – Gabe Sechan Apr 12 '18 at 15:27
  • How much bytes your audio and video contains? There can be different approaches. – Khemraj Sharma Apr 12 '18 at 18:31
  • @Gabe Sechan Will this be possible. On demand I will download a zip file of audio and video . Can I unzip this into the /res/raw or should it go to /assets directory ? I may have to re-think the scope of the app due to this. – megjosh Apr 13 '18 at 04:29
  • 1
    You can't unzip anything to assets or res. You could unzip it to the local filesystem in the phone – Gabe Sechan Apr 13 '18 at 04:30
  • @khemraj I will know the size of the individual audio/video files . The list of all the audio/video files is not known , hence the total size is not known presently. Can you elaborate your idea assuming we know the total size of the audio/video files ? – megjosh Apr 13 '18 at 04:34
  • @Gabe Sechan How about this ? I will include the most important a/v files within the apk keeping its size down. I will create a you tube channel with the rest of the a/v files. i can either use the embedded you tube option or ask the user to use you tube to watch the other a/v files from the channel. The other way would be to have a master apk and lots of detail apk's. On demand master apk will call activities from the detail apk's. In this case, 1) I need to figure out how I can install multiple apk's when clicking on the master install and 2) using broadcast intent to call activities – megjosh Apr 13 '18 at 05:14

1 Answers1

2

Try using Proguard. It removes all the unused classes and refactor the class name to prevent reverse engineering and thus reduces the apk file size.

https://developer.android.com/studio/build/shrink-code.html

Hope this helps

Jeffy
  • 276
  • 3
  • 9
  • If he has lots of video files, the savings from Proguard would be minimal compared to the size of the rules. It would be like getting a haircut to lose weight – Gabe Sechan Apr 13 '18 at 05:17
  • 1
    @jeffy I have only about 6/7 classes so coding wise there isn't much. the size is increasing due to the addition of many a/v files. – megjosh Apr 13 '18 at 05:17
  • Did you end up with a good solution @megjosh? Maybe you download the files from internet and keep them as local files? – JCarlosR Jul 28 '19 at 18:48
  • Thanks @JCarlos for your suggestion. Again since this is video and audio the size of the file increases very quickly. Hence the solution I could think of was to download the song and take only 1 minute of the video to include in the app. Provide a link to the song on youtube where the user can listen to the song completely. Something like Show less/more kind of functionality. – megjosh Jul 30 '19 at 02:06