3

I found that after my app reached a fair size (e.g. by adding multiple libraries), running the app threw java.lang.SecurityException: writable dex file '.../code_cache/.overlay/base.apk/classes2.dex' is not allowed.

If I then remove most of the libraries leaving only those that were added by default, and run again, it could work. But then if I add a tiny bit of code, like a log, it could fail with the same error.

If I want it to run without this error, I have to uninstall the app and then run again from Android Studio. This is very inconvenient, because every time I make some changes, I have to uninstall the app. I wouldn't imagine anyone would like to develop Android apps like this.

Does anyone know a solution to this problem?

Wei Wen
  • 133
  • 1
  • 9
  • Maybe try using MultiDex? – Darshan Jun 18 '23 at 04:23
  • why did you tag android-14? is this something specifically related to that OS? – Lino Jun 19 '23 at 07:33
  • @Lino Because the problem I am having is only on Android 14. Earlier Android versions work fine. Android 14 hasn't been released until August this year. – Wei Wen Jun 19 '23 at 13:07
  • @WeiWen : Are you using Dynamic Code Loading (DCL) in your project or can you get info if the libraries are using this feature ? – avinash Jun 21 '23 at 07:30
  • @avinash I didn't use DCL. And I don't think any of the libraries that I included uses DCL. All of them are Android or google libraries, like navigation, lifecycle, material, etc. – Wei Wen Jun 23 '23 at 02:27
  • Try turning off “build automatically “ in settings. https://slack-chats.kotlinlang.org/t/518884/question-1-i-m-starting-to-receive-this-error-more-and-more-#2d02f618-8363-43f8-993c-bef6cb2715ba – avinash Jun 23 '23 at 09:16
  • Did you ever get to the bottom of this? I've been seeing it non-deterministically. The call chain seems to originate from native android OS code. – Smalls Aug 07 '23 at 14:51
  • @Smalls No. I haven't found a solution. I am not actively developing any app on Android 14, just want to see what features there are. I am hoping google will find out the issue and fix it. – Wei Wen Aug 10 '23 at 18:26
  • The issue seems to not be reproducible for me anymore without updating any of the libs I was using so the issue may have been resolved on the Android side. – Smalls Aug 14 '23 at 13:36
  • Not sure if you have resolved the issue but in my case the issue was that I needed to update to java 11 and update the dependencies versions to newer ones. – DPE Aug 31 '23 at 21:05

0 Answers0