mvisaqrparser-1.6.0.jar incompatible with android 14

Solved! Go to solution
mVisa01
Regular Visitor

mvisaqrparser-1.6.0.jar incompatible with android 14

Hello,

             I'm encountering an error in android when using MVisaQRParser-1.6.0.jar and one of the

class throws security exception and it only occurs in android 14, when parsing QR code data as JSON.

 

Any help is appreciated.

 

2 REPLIES 2
mVisa01
Regular Visitor

Re: mvisaqrparser-1.6.0.jar incompatible with android 14

Error Logs:

Fatal Exception: java.lang.SecurityException: Writable dex file '/data/user/0/com.aeoncredit.android.aeonpay_consumer/cache/.         ' is not allowed.
at dalvik.system.DexFile.openDexFileNative(DexFile.java)
at dalvik.system.DexFile.openDexFile(DexFile.java:406)
at dalvik.system.DexFile.<init>(DexFile.java:171)
at dalvik.system.DexFile.loadDex(DexFile.java:231)
at dalvik.system.DexFile.loadDex(DexFile.java:198)
at com.visa.mvisa.tlvparser.a.If.<clinit>(:10925)
at com.visa.mvisa.tlvparser.QrCodeParser.parseQrData(:25)
at com.visa.mvisa.tlvparser.QrCodeParser.parseQrDataAsJson(:47)
at kh.com.aeon.android.aeonpay.fragment.ScanQRFragment.handleResult(ScanQRFragment.java:109)
at me.dm7.barcodescanner.zxing.ZXingScannerView$1.run(ZXingScannerView.java:164)
at android.os.Handler.handleCallback(Handler.java:958)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loopOnce(Looper.java:222)
at android.os.Looper.loop(Looper.java:314)
at android.app.ActivityThread.main(ActivityThread.java:8680)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:565)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1081)

DianaVisaPM
Visa Developer Support Specialist

Re: mvisaqrparser-1.6.0.jar incompatible with android 14

Hey @mVisa01,

 

It looks like you are encountering a security exception when using the `MVisaQRParser-1.6.0.jar` library on Android 14. The issue arises when attempting to parse QR code data as JSON, resulting in a fatal exception related to writable dex files.

 

Error Analysis:
The error log indicates a `SecurityException` with the following message:

 

```
Fatal Exception: java.lang.SecurityException: Writable dex file '/data/user/0/com.aeoncredit.android.aeonpay_consumer/cache/.         ' is not allowed.
```

 

This typically points to restrictions on writing dex files to the application's cache directory, which seems to be enforced more strictly in Android 14.

 

Potential Solutions:
1. Update the Library:
Ensure you are using the latest version of the `MVisaQRParser` library. There may have been updates or patches to address compatibility issues with newer Android versions.

2. Modify Dex File Handling:
If you have access to the source code of the `MVisaQRParser` library, you might need to modify how dex files are handled. Specifically, avoid writing dex files to locations that are restricted by Android 14.

3. Use a Different Cache Directory:
Consider using a different directory for caching dex files, such as `getCodeCacheDir()` instead of `getCacheDir()`. The `getCodeCacheDir()` is specifically intended for storing compiled code, and may not have the same restrictions.

 

Example Code Adjustment:
If you have access to the part of the code where dex files are being handled, here is a conceptual example of how you might adjust the directory:

```java
// START
Context context = getContext();
File codeCacheDir = context.getCodeCacheDir();
String dexOutputPath = codeCacheDir.getAbsolutePath();

// Load dex file from the new cache directory
DexFile dexFile = DexFile.loadDex(dexFilePath, dexOutputPath, 0);
// END
```

 

Contact Visa Developer Support:
If you do not have access to modify the library or the above solutions do not resolve your issue, it is recommended to email Visa Developer Support at developer@visa.com for assistance. They may provide a version of the library compatible with Android 14 or offer alternative solutions.

 

Next Steps:
1. Check for Library Updates: Ensure you are using the latest version of `MVisaQRParser`.
2. Modify Dex File Handling: If possible, adjust the code to use `getCodeCacheDir()` for dex file storage.
3. Contact Support: Reach out to Visa Developer Support for further assistance.

If you need further help or if these solutions do not resolve the issue, please provide additional details or contact Visa Developer Support directly.




Thanks,

Diana



Was your question answered? Don't forget to click on "Accept as Solution" to help other devs find the answer to the same question.