"APK was defined multiple times" , app fails to install with Android Studio - android-studio

My app was installing just fine... installing and reinstalling for testing, etc. But now it won't install anymore... and Android Studio says,
Application Installation Failed
Installation failed with message Failed to
finalize session :
INSTALL_FAILED_INVALID_APK: Split
lib_slice_3_apk was defined multiple times.
It is possible that this issue is resolved by
uninstalling an existing version of the apk if it is
present, and then re-installing.
WARNING: Uninstalling will remove the
application data!
Do you want to uninstall the existing
application?
[CANCEL] [OK]
I tried uninstalling the app from my phone, but it still won't re-install.
Also, I tried installing it fresh on an emulator where it had never been installed before, and that did not work either.
I suppose I must have inadvertently messed up some compile-related setting that I don't understand (but I haven't been doing anything like that). I don't have a knowledge of the compile process, and pretty much depend on Android Studio to do that.
I have been working on a "sister" app to this one... where I copied some libraries (.jar files such as zixng.jar from [project root]\app\libs) from this app to the other app. And that other app is installed on my phone also... but then again, it's not on the emulator... so I guess that's not the problem. Merp.
Thanks for any suggestions or possible explanations.

Try to clean & then Rebuild the project again. To do so please go to Build menu, both the tools are present their.
If issue not solved with that than try to invalidate caches & restart Android Studio from File menu -> Invalidate Caches/Restart.

Related

The specified Gradle distribution 'https://services.gradle.org/distributions/gradle-7.2-bin.zip' does not exist

In Android Studio, I am getting the following error when trying to run my app on an Android device:
The specified Gradle distribution 'https://services.gradle.org/distributions/gradle-7.2-bin.zip' does not exist.
All my Android Studio projects are affected by this and restoring them to older commits does not change anything.
The problems all started by following the advice given here: Could not install Gradle distribution from 'https://services.gradle.org/distributions/gradle-2.1-all.zip'
I deleted everything in my /.gradle/wrapper/dists/ folder. Now, I get the above error and I do not see how to solve it.
Here is how to reproduce it with Android Studio 2021.1.1 on Windows (but be warned: this might corrupt your projects, too):
Delete everything in /.gradle/wrapper/dists/
Create a new project "Test" in Android Studio (this might take a while, since gradle-7.2-bin.zip will be downloaded in the dists folder)
The project builds and runs without errors
Close Android Studio
Delete everything in /.gradle/wrapper/dists/ again
Open project "Test" in Android Studio
Try to run
Now you should get the above mentioned error.
At this point, /.gradle/wrapper/dists/ is still empty. Now you can do the following:
run gradlew tasks in Terminal in the Project Folder of "Test" (this will take a while, since gradle-7.2-bin.zip will be downloaded in the dists folder again)
run gradlew build (everything should build without errors)
But clicking on "Run" still yields the same error.
I am getting the impression that this is an AndroidStudio / IntelliJ bug.
Can anyone help me with this?
Running Android Studio as Administrator solved the problem for me
It turned out my Android Studio installation was heavily corrupted. Simply, uninstalling it and installing it again also did not help.
I basically had to do everything that was suggested here: How to completely uninstall Android Studio from windows(v10)? and delete everything related to Android Studio. I installed it again and now everything is fine again.
I do not know what the problem was. Maybe the .m2 folder, maybe the Jetbrains folder.
My advice to everyone facing the same issue:
First try around deleting caching folders. If nothing helps, go for the brute force approach and follow the answers (not only the accepted answer) of the above mentioned StackOverflow question.

Android Studio does not install app after using the Internal Test Track version

I've been working on my app for a while now and recently uploaded it to the Google Play Console's Internal Test Track. I installed my app via Google Play Store and it worked fine.
But if I now try to install an updated debug version via Android Studio directly it just launches my main activity without installing the changed app.
What I've tried:
Uninstalling app and running in via AS: "Error: Activity class {...} does not exist."
Restarting phone
Restarting AS
Reconnecting phone
Uninstalling app via AS (gradlew uA)
Uninstalling app via app manager
Invalidating AS cache
Cleaning / rebuilding project
Disabling Skip installation if APK has not changed in Run Configurations -> Miscellaneous
Increasing version number
What may cause it:
The Internal Test Track version is signed, but the key is kept by Google
The app is not selected as 'App to debug', but the dialog to choose one, does not offer it
How can I install my unreleased version via Android Studio directly again?
Thanks in advance. -Minding
QUICKFIX
The "Gradle Aware" task was missing for some reason. To fix it "Run" > "Edit configurations" > "+" > "Gradle-aware Make" > "OK" (leave the field empty) and restart.
The Android Studio team is still investigating why this happened.
Old answer / Workaround
Using the ADB to directly uninstall the release version and installing the debug version worked, but you have reinstall the app for every change! A better solution would still appreciated.
Build your project's debug APK
Enter the following into the terminal:
adb uninstall MY_PACKAGE_NAME
adb install -r ./mobile/build/outputs/apk/debug/mobile-debug.apk
If you get "adb" not found. use %LOCALAPPDATA%\Android\sdk\platform-tools\adb instead.
Select the app to be App to debug in the device's developer options.
Hope this help. -Minding

Visual Studio Installer is not installing node.js

In Visual Studio Installer, I selected the Node.js development option. It runs successfully. But, if I try to run cmd node -v. It tells me node does not exist.
I tried a few other things including uninstalling and reinstalling the Node.js development option in VS Installer. Plus installing the latest version of node from the website.
However, when I try to run the pre-packed Angular solution that comes with VS 2017 I have issues. The solution will not even start.
The best I have been able to do is install Node 6.10.3. Once I do that, the web site comes up. But, I get a JavaScript error in the vendor.js file. I am able to continue but I get this error when I try navigate to another menu item. Plus the Hot Module Replacement does not seem to be working. (It does not automatically recompile my TypeScript file if I made a change).
I think the key is getting the Node.js development option installed correctly since I am able to run the pre-packed Angular solution on another PC and the Hot Module Replacement works fine.
Please let me know if anyone has any ideas on how to resolve.
I had a similar, if not the same, issue. Check the Visual Studio installation directory (2017 Professional in this case) for Node:
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Microsoft\VisualStudio\NodeJs
If the executable is there, add the directory to your PATH.

Finish can only be called once : Android

Recently updated Build: 2.3.1, AI-162.3871768, 20170401,
AI-162.3871768, JRE 1.8.0_112-release-b06x64 JetBrains s.r.o, OS Mac OS X(x86_64) v10.11.6 unknown, screens 1440x900; Retina
Switching back to Android 2.2.2 did not help either. Successfully able to build from command Line though(MacOX Terminal)
Delete your $HOME/.gradle directory (or on Windows, %HOME%\.gradle folder). The next execution of gradle will rebuild this. (It will require some downloads, so make sure you have an internet connection).
You can try just deleting $HOME/.gradle/caches, but this will not solve the problem in all cases.
I have similar issue on 2.3.1
I tried using the Android 2.4 Preview 4 but that did not help. I am able to build from command line too.
Android-Studio-2.3.1-Gradle-Sync
It happens when Android Studio creates two instances of gradle. I tried clearing the gradle cache or even deleting the .gradle but did not help. All this problem started when I deleted my old project repo and re-pulled it and imported to my Android Studio.
Best is to delete all your gradle instance from your home directly before your re-import your project Android Studio.
Android Studio started behaving like this after I tried building with the command line(osx) using ./gradlew
What helps is running the studio with sudo:
sudo /Applications/Android\ Studio.app/Contents/MacOS/studio
I wonder if theres a fix to this problem that allows the studio to be started normally as well.

Android Studio 1.1 won't run project

Suddenly my Android Studio project can't run anymore. Either from the "play" button or Run/Run 'app'. When I click them nothing happens. No errors, nothing.
This started happening after I installed the 1.2 Android Studio update, but then downgraded to 1.1 again and the problem still exists.
I can't remember doing any other changes other than installing the AS 1.2 update.
How can I fix this? Is there any other way to run a project?
Just restarting Android Studio worked for me.
Resolved by deleting the existing run configuration and created a new one with the same settings. I can only guess the run configuration was somewhow corrupted by the Android Studio update.
Even i was facing the same issue, after digging into AndroidStuido i tried going to SDK Manager and installed the suggested the install packages (shows in install button with 'Install(1) Package') ..after installing that now i am able to run my app...
i think some SDK was not uptodate or might not installed properly..so try this!
No answer worked for me. So I tried to Invalidate and Restart and it worked well.
Just go to File -> Invalidate caches/Restart... Click Invalidate and Restart button.
In my case restarting the device worked.

Resources