3

I have some mp3 files in my res/raw/ folder when it first gets signed with android debug key the mp3 file bundled with the apk is not compressed.

I verify this by typing unzip -lv and i get this

1670  Stored     1670   0%  06-23-14 18:48  3b4b6017  res/raw/swipe.mp3

then it gets re-signed as a part of the build job using jarsigner plugin I have removeExistingSignatures set to true after that when i run unzip -lv the method of the mp3 is Defl:N instead of Stored (i.e it gets compressed)

I need it to be in Stored state even after re-signing becasue i get this error if the mp3 file is compressed

07-17 03:36:00.068 E/AndroidRuntime( 9487): FATAL EXCEPTION: AsyncTask #3

07-17 03:36:00.068 E/AndroidRuntime( 9487): android.content.res.Resources$NotFoundException: File res/raw/swipe.mp3 from drawable resource ID #0x7f060000

07-17 03:36:00.068 E/AndroidRuntime( 9487):     at android.content.res.Resources.openRawResourceFd(Resources.java:982)

07-17 03:36:00.068 E/AndroidRuntime( 9487):     at android.media.MediaPlayer.create(MediaPlayer.java:874)

07-17 03:36:00.068 E/AndroidRuntime( 9487):     at <my_package_here>
07-17 03:36:00.068 E/AndroidRuntime( 9487):     at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:230)

07-17 03:36:00.068 E/AndroidRuntime( 9487):     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)

07-17 03:36:00.068 E/AndroidRuntime( 9487):     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)

07-17 03:36:00.068 E/AndroidRuntime( 9487):     at java.lang.Thread.run(Thread.java:856)

07-17 03:36:00.068 E/AndroidRuntime( 9487): Caused by: java.io.FileNotFoundException: This file can not be opened as a file descriptor; it is probably compressed

I am not able to get it directly signed with my key. in spite of setting <sign><debug>false</debug></sign> in my android-maven-plugin it gets signed with the android debug key.

How do i sign directly with my key ? Or how do i re-sign such that the mp3 file is not compressed?

Navin GV
  • 700
  • 3
  • 10
  • 24

1 Answers1

1

Inside of putting it inside Raw, you can put it in the assets folder. To access files from the asset folder you can getAssets().

For example to get a File object you can do :

File f = new File(getAssets().open("music/something.mp3"));
Hiemanshu Sharma
  • 7,702
  • 1
  • 16
  • 13