'adb: failed to install my_application-aligned.apk: Failure [INSTALL_PARSE_FAILED_UNEXPECTED_EXCEPTION: Failed to parse AndroidManifest.xml]
When I try to install my apk onto my Android Virtual Device in Android Studio with adb install my_application-aligned.apk, I get the following error: Performing Streamed Install adb: failed to install my_application-aligned.apk: Failure [INSTALL_PARSE_FAILED_UNEXPECTED_EXCEPTION: Failed to parse /data/app/vmdl530526663.tmp/base.apk: AndroidManifest.xml]
Could this be because the apk is corrupted? I can provide my Android Manifest file if that would help. I generated the APK by following this tutorial: https://medium.com/@_sathishshan/decompile-and-recompile-android-apk-7d375e1bca83 . Following this tutorial, I first downloaded an XAPK file from the internet. Then, I decompiled the APK and added some additional files to the application. Next, I recompiled the APK, and generated a new APK file. This new APK file is my_application-aligned.apk. Thanks!
Solution 1:[1]
Uninstall old app from device and re run this app to device again.
Solution 2:[2]
So this doesn't really answer how to get rid of the error, but I think this error is showing up because the original file that I downloaded from the internet was an XAPK file, not an APK file. I just tried to do this whole process again with an APK file downloaded from the internet (not an XAPK file), and the error did not appear. So it might have something to do with the original file that I decompiled being an XAPK.
Solution 3:[3]
It worked for me by clearing the builds folder
./gradlew clean
or
Android Studio --> Build --> Clean
Solution 4:[4]
So the first thing I did was run npm list -g --depth 0
sudo npm list -g --depth 0 This should give you a list of modules that are globally installed. If you don't see node-gyp in there then run npm i -g node-gyp . Run the above command again and you should see it! After doing that I followed a list of steps from this link: https://github.com/nodejs/node-gyp/issues/1136
Which asks you to do this:
sudo su -
npm install -g node-gyp # Does nothing if it's already installed
export PATH=$PATH:/usr/local/lib # Replace /usr/local/lib with the path from npm list
which node-gyp # Should show the path to node-gyp
node-gyp BUILDTYPE=Release rebuild # Don't need sudo cause you're already in a sudo shell
exit # Quit
If that doesn't work try this:
npm i -g node-gyp@latest && npm config set node_gyp "/Users/.nvm/versions/node/v14.15.1/lib" (REPLACE with your own path that prints when you run npm list)
After doing all that, I had a new error.
sh: node-gyp-build: command not found
Then I ran:
npm i -g node-gyp-build
And now I have web3 added as a dependency to my package.json! Happy to help further
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Hardik Mehta |
| Solution 2 | Dharman |
| Solution 3 | procrastinator |
| Solution 4 |
