1

When I run my app on emulator or regular android phone through debug mode everything works. But installing it via signed app causes it to crash when (I believe) accessing or rather trying to access non saved files in internal private storage.

I have

<uses-permission android:name="android.permission.WRITE_INTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_INTERNAL_STORAGE" />

in my manifest file just in case.

My app has some raw test data in res folder that is copied to internal storage where it would normally be created by user through regular use. Everything works in debug mode but not normally. (saving through usage of app works so I guess the problem is either accessing raw resources or copying them to internal storage)

What could be the cause?

here is the code for raw -> internal transfer

File file = getApplicationContext ().getFileStreamPath(userTemp);
        try {
            InputStream inputStream = getResources().openRawResource(
                    getResources().getIdentifier(user, "raw", getPackageName())
            );

            FileOutputStream fileOutputStream = new FileOutputStream (file);

            byte buf[]=new byte[1024];
            int len;
            while((len=inputStream.read(buf))>0) {
                fileOutputStream.write(buf,0,len);
            }

            fileOutputStream.close();
            inputStream.close();
        } catch (IOException e1) {}

user and userTemp are just simple string file names

EDIT: just to confirm, res files exists in apk file

EDIT2: the files are copied from raw resources to internal app storage but for some reason they can't be read, however as I said before, debug runs great

user3086720
  • 191
  • 1
  • 1
  • 7
  • 1
    What the error that you are getting ? What Android version your device have ? – Lucas Queiroz Ribeiro Aug 08 '16 at 20:26
  • api19 and 22 on emulators, api23 on samsung s III. It wokrs perfectly when lunchin through debug from android studio but when installed from release app it says "Unfortunately appname has stopped" I know it can't read the files in application's internal storage cause there is a null. File exists shows true yet it can't be red. (and the app itself wrote that files) – user3086720 Aug 09 '16 at 16:41
  • Even if you install the app via an APK file, you can see the Android Monitor, paste the error you are getting, this way is easier to help. My guess is that the folder you are saving when debug, does not exists on the installed version, for example the debug version uses a Folder named "Emulated", and this folder normally not exists in production version – Lucas Queiroz Ribeiro Aug 09 '16 at 19:25
  • well System.err: java.io.InvalidClassException: com.example.username.myapplication.Credential; Incompatible class (SUID). I think I get it now – user3086720 Aug 10 '16 at 16:15
  • 1
    Try see this question : http://stackoverflow.com/questions/6920352/java-io-invalidclassexception-during-serializing-deserializing – Lucas Queiroz Ribeiro Aug 10 '16 at 16:47
  • Seems to be an error with proguard – Lucas Queiroz Ribeiro Aug 10 '16 at 16:48

0 Answers0