Failed to install app at first time in the device I got java.io.IOException: Failed to load asset path
Asked Answered
W

4

11

Everytime I install the app at first time (I mean not installed in device before or when uninstall it and re-install it again) I got this error

E  Failed to open APK '/data/app/~~DMnzdQrGgYoMVn5mnSazHA==/com.mml.dummyapp_kotlin-7QhJglvK4ZbYX3k1LhSksg==/base.apk' I/O error
2022-09-26 16:12:40.817  8427-8606  android.vendin   pid-8427  E  Failed to open APK '/data/app/~~DMnzdQrGgYoMVn5mnSazHA==/com.mml.dummyapp_kotlin-7QhJglvK4ZbYX3k1LhSksg==/base.apk' I/O error
2022-09-26 16:12:40.821  8427-8606  ResourcesManager pid-8427  E  failed to add asset path '/data/app/~~DMnzdQrGgYoMVn5mnSazHA==/com.mml.dummyapp_kotlin-7QhJglvK4ZbYX3k1LhSksg==/base.apk'
java.io.IOException: Failed to load asset path /data/app/~~DMnzdQrGgYoMVn5mnSazHA==/com.mml.dummyapp_kotlin-7QhJglvK4ZbYX3k1LhSksg==/base.apk
 at android.content.res.ApkAssets.nativeLoad(Native Method)
 at android.content.res.ApkAssets.<init>(ApkAssets.java:291)
 at android.content.res.ApkAssets.loadFromPath(ApkAssets.java:140)
 at android.app.ResourcesManager.loadApkAssets(ResourcesManager.java:374)
 at android.app.ResourcesManager.access$000(ResourcesManager.java:67)
 at android.app.ResourcesManager$ApkAssetsSupplier.load(ResourcesManager.java:146)
 at android.app.ResourcesManager.createAssetManager(ResourcesManager.java:451)
 at android.app.ResourcesManager.createResourcesImpl(ResourcesManager.java:538)
 at android.app.ResourcesManager.findOrCreateResourcesImplForKeyLocked(ResourcesManager.java:587)
 at android.app.ResourcesManager.createResources(ResourcesManager.java:866)
 at android.app.ResourcesManager.getResources(ResourcesManager.java:938)
 at android.app.ActivityThread.getTopLevelResources(ActivityThread.java:2225)
 at android.app.ApplicationPackageManager.getResourcesForApplication(ApplicationPackageManager.java:1672)
 at android.app.ApplicationPackageManager.getDrawable(ApplicationPackageManager.java:1437)
 at android.app.ApplicationPackageManager.loadUnbadgedItemIcon(ApplicationPackageManager.java:2950)
 at android.app.ApplicationPackageManager.loadItemIcon(ApplicationPackageManager.java:2929)
 at android.content.pm.PackageItemInfo.loadIcon(PackageItemInfo.java:271)
 at android.app.ApplicationPackageManager.getApplicationIcon(ApplicationPackageManager.java:1501)
 at fva.a(PG:5)
 at fvg.l(PG:1)
 at qt.aci(PG:46)
 at fuj.k(PG:3)
 at fua.f(PG:3)
 at fua.i(PG:3)
 at fve.i(Unknown Source:0)
 at fvh.d(Unknown Source:10)
 at fvh.e(PG:3)
 at ftr.apply(PG:168)
 at ahmn.e(PG:2)
 at ahmo.run(PG:9)
 at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
 at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
 at jjd.run(PG:17)
 at java.lang.Thread.run(Thread.java:923)
2022-09-26 16:14:08.111 13577-13577 studio.deploy  pid-13577   E  InstallClient: Could not copy '/data/local/tmp/.studio/tmp/31c79e06/install_server' to '/data/data/com.mml.dummyapp_kotlin/code_cache/install_server-31c79e06: out='', err='run-as: unknown package: com.mml.dummyapp_kotlin
run-as: unknown package: com.mml.dummyapp_kotlin                     '
2022-09-26 16:14:08.129 13577-13577 studio.deploy  pid-13577     E  run-as: unknown package: com.mml.dummyapp_kotlin
2022-09-26 16:14:08.158 13577-13577 studio.deploy  pid-13577     E  Could not get package user id: run-as: unknown package: com.mml.dummyapp_kotlin
2022-09-26 16:14:08.181 13577-13577 studio.deploy  pid-13577     E  Could not find apks for this package: com.mml.dummyapp_kotlin

manifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools">

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

    <application
        android:name=".BaseApplication"
        android:allowBackup="true"
        android:dataExtractionRules="@xml/data_extraction_rules"
        android:fullBackupContent="@xml/backup_rules"
        android:hardwareAccelerated="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:largeHeap="true"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="false"
        android:theme="@style/Theme.DummyAppKotlin"
        android:usesCleartextTraffic="true"
        tools:targetApi="33">
        <activity android:name=".ui.DetailsActivity" />
        <activity
            android:name=".ui.MainActivity"
            android:configChanges="orientation|screenSize"
            android:exported="true">

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

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

        <service
            android:name="com.mml.dummyapp_kotlin.util.MyFirebaseMessagingService"
            android:enabled="true"
            android:exported="false">
            <intent-filter>
                <action android:name="com.google.firebase.MESSAGING_EVENT" />
            </intent-filter>
        </service>
        <!--
 Set custom default icon. This is used when no icon is set for incoming notification messages.

        -->
        <meta-data
            android:name="com.google.firebase.messaging.default_notification_icon"
            android:resource="@drawable/activity_feed" />

        <!-- Sample AdMob app ID: ca-app-pub-3940256099942544~3347511713 -->
        <meta-data
            android:name="com.google.android.gms.ads.APPLICATION_ID"
            android:value="ca-app-pub-6982469603053718~7540735179" />

    </application>

</manifest>

then when I open the app menu it works normally

Wet answered 26/9, 2022 at 14:34 Comment(3)
What version of Android Studio are you using? Emulator or real device? Tried to just do a rebuild after cleaning the project?Colima
@patrick-elmquist Android Studio Dolphin | 2021.3.1 Build #AI-213.7172.25.2113.9014738, built on August 31, 2022, happens on a real device android 11, clean & rebuild dosen't fix the problemWet
hmm I'm pretty sure I've experienced that issue before, typically when I see something like that I just nuke it all, adb uninstall the app, do an Invalidate and restart in Android Studio and start over fresh and it usually just magically starts working again ¯_(ツ)_/¯Colima
W
4

Okay I didn't find the reason for this error but the following steps helped me to fix it

  1. I followed the steps in this answer to completely uninstall AS

  2. I also found that I used two versions of ADB that's maybe causing conflicts when installing apps, so I decided to uninstall both (then install the newest one that is included with android studio)

Note: the older ADB path was in %SystemDrive%\adb

  1. After restarting the windows I installed a fresh version of AS

enter image description here

Wet answered 12/10, 2022 at 11:24 Comment(0)
D
1

Just wanted to chime in here, months later though I certainly am. In my own testing I HAVE found what I certainly BELIEVE to be the problem, though I, too, am following the solution laid out by @Dr Mido, above.

The root cause appears to stem from one or both of the follow occurrences:

  1. Switching between emulators (like, for instance, Pixel 4 to Pixel 6) without letting the first one FULLY spool down. There appears to be some cached version of the base apk it's attempting to load, but that has been destroyed by the re-launch. I think the reason that's not manifestly obvious is the cache is located ON THE "DEVICE", not the system hard disk.

"BS!" I can hear some saying. "I never switched emulators and it still happens to me!"

  1. Okay, well first off, you really SHOULD be testing on more than one device. But shelving that, changing BRANCHES appears to have the same net effect. If you're using some kind of version control, then that's behaving identically to switching emulators (if you're NOT using any form of version control, then I'm sorry: you're beyond helping). Still doubt? Do a full Wipe Data on the emulator, shut it down ENTIRELY, cold boot it, and reinstall.

Best as I can ascertain, the error isn't HURTING anything (other than, yanno, showcasing a wall of red text during product demos), but if one FULLY shuts down their emulator, follows the excellent advice of Dr Mido's, above, AND one ensures all subsequent executions of the emulator have time to fully spool up and down, it should cease appearing (or at least, per my own testing, that's how it's worked out).

Hope this helps someone!

Duffer answered 8/3, 2023 at 16:22 Comment(0)
P
1
  1. Build -> clean project
  2. File -> invalidate caches -> (check) clear file system and local history -> invalidate and restart
  3. rebuild the project

this helped me

Pavo answered 11/4, 2023 at 12:31 Comment(1)
As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.Creese
C
1

For me emulator was the problem. After I wiped emulator data it worked. You could also delete your emulator and create it again.

Clearsighted answered 8/7, 2023 at 9:53 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.