问题描述:

I changed the manifest file to android:largeHeap="true",

but still I continue with the problem java.lang.OutOfMemoryError. I need to decrypt a file with 31 Mb using AesBase64. With smaller files no problem, but for files larger than 30MB always get java.lang.OutOfMemoryError.

Fragments of my code

AesBase64Wrapper aes = new AesBase64Wrapper();

byte[] output = aes.Decrypt(IOUtils.toByteArray(new FileInputStream(arquivoEntrada)));

...

public byte[] Decrypt(byte[] encrypted) throws Exception {

byte[] decodedValue = encrypted;

Cipher c = getCipher(Cipher.DECRYPT_MODE);

byte[] decValue = c.doFinal(decodedValue);

return decValue;

}

private Cipher getCipher(int mode) throws Exception {

Cipher c = Cipher.getInstance("AES/CBC/PKCS5Padding");

byte[] iv = getBytes(IV);

c.init(mode, generateKey(), new IvParameterSpec(iv));

return c;

}

UPDATE

<uses-sdk

android:minSdkVersion="11" />

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

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

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

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

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

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

<application

android:allowBackup="true"

android:icon="@drawable/img_logo"

android:label="@string/app_name"

android:largeHeap="true"

android:theme="@style/Theme.Customtheme" >

<activity

android:name=".MainActivity"

android:label="@string/app_name" >

</activity>

<activity

android:name=".VideoActivity"

android:configChanges="orientation|keyboardHidden|screenLayout"

android:label="@string/title_activity_video"

android:screenOrientation="landscape"

android:theme="@android:style/Theme.NoTitleBar.Fullscreen" >

</activity>

<activity

android:name=".FileChooserActivity"

android:label="@string/app_name"

android:screenOrientation="landscape" >

</activity>

<activity

android:name=".AudioActivity"

android:configChanges="orientation|keyboardHidden|screenLayout"

android:label="@string/title_activity_audio"

android:screenOrientation="landscape" >

</activity>

<activity

android:name=".SplashScreenActivity"

android:configChanges="orientation|keyboardHidden|screenLayout"

android:screenOrientation="landscape" >

<intent-filter>

<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />

</intent-filter>

</activity>

<activity

android:name=".HomeActivity"

android:label="@string/title_activity_home"

android:screenOrientation="landscape" >

</activity>

<activity

android:name=".ConfigActivity"

android:label="@string/title_activity_config"

android:screenOrientation="landscape" >

</activity>

<receiver android:name=".BootReceiver" >

<intent-filter android:priority="1000" >

<action android:name="android.intent.action.BOOT_COMPLETED" />

</intent-filter>

</receiver>

</application>

相关阅读:
Top