Android studio does not compile classes.dex into apk - android

Every time I try to run my app on an emulator or device, installation fails with an INSTALL_FAILED_DEXOPT error. Examining LogCat and the apk spit out by Android Studio reveals that the apk does not contain any classes.dex file.
Strangely, compiling the project from the command line works properly, and will even get android studio to work for a few builds (although the resulting apk does not work completely).
I have tried EVERYTHING TO GET THIS ERROR TO STOP. Reinstalling AS, reinstalling the SDK, reinstalling the JDK, restarting my PC, recreating projects, nothing helps. This error just won't go away. I really want to be able to use Android Studio and get away from Eclipse, but Google is making that really hard.
Anyone have any ideas?

Related

Android Studio generating correct app-debug.apk file but showing old version of code

I have an app that is build using React and is wrapped in capacitor. I was having no issues running the app in debug mode on android studio a month ago, or creating release files, but now I am.
I have checked the app-debug.apk (static/js/main.chunk......) file that is created when I select run, and it contains the updated code, I have sent the package to a colleague who ran the .apk on their machine and saw the updated code, but on my emulator and on my android devices, I am seeing an old version of the code.
I have removed all debug-release.apk files on my Mac and followed steps online such as clean build/rebuild, updates off mac, android studio etc but still no luck.
I am at a complete loss now.
Any ideas?
Thanks
Update: After much troubleshooting, we deleted the build folder android>app>build and the rebuilt the app, and ran it, and it fixed the issue.

Application installation failed even after reviewing everything clearly

Seems my Android studios isn't working as it used to work before.
When I run the emulator, it loads for a bit of time, later it opens the emulator, but the project isn't loading up. I'm receiving strange type of error:
Installation failed with message Invalid File: C:\google-services-master\android...\app\build\intermediates\split-apk\debug\slices\slice_2.apk.
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?
I had some thoughs maybe the project is broken, so I made a new one. The same problem occurs, I created a new emulator, didn't helped either, rebuilded and cleaned the project and still receiving the same problem.
I've checked these topics:
Installation failed in android studio
Android Studio: Application Installation Failed
Couldn't fix it either.. Idk, maybe I should reinstall Android Studios? But hell yeah, it takes so long to install all the updates..
P.S. The project consumes only 1 layout and 1 imageview.
Everything was working fine until now..

IntelliJ compiles successfully but no signed apk is generated

I recently updated my android SDK platform, since the update when i try to generate a signed APK in intelliJ idea i get no error in compilation and packaging process (even proguard works fine) but no apk file is generated in the destination. I am able to run my app on emulator and devices, means that debug apk is generated correctly.
I tried cleaning and rebuilding, no luck. I thought that this might be a problem with project settings, so i tried to generate APKs for other android projects or even an empty Hello World project, the problem still exists.
Is there any log files or other things that i can post here to help clarify the problem?
Well, this was an irrelevant (to android SDK) problem that i was struggling with last two days.
The problem solved by removing following directory:
%HOME%\.IntelliJIdea14\system\caches
had just the very same trouble, have tried around and got it to my surprise. So the how do to is a better hint:
Make an Ant-Build
Build .. Generate ant on the left side add it press "play"
Build your project.release ..
.. .. Now here I got a clear Error message:
"wrong android sdk build-tools version" hopefully you will get the right for you.
some apk's were generated but not installed on a phone.
Still I was not able to generate signed apk.
Deleted the ant build xx .., restarted IntelliJ 15.x
tried.xx.. now it works. hope it helps.

Failure to install APK [INSTALL_FAILED_DEXOPT] Android Studio

I have tried literally everything to try and rectify this error when trying to deploy an app to an actual android device for debugging but have been unable to solve the matter. Everytime I try to launch I get a failed [INSTALL_FAILED_DEXOPT] error and when checking the logcat it is always because there is no classes.dex in my debug apk.
If I run gradlew.bat clean assembleDebug, there is no difference in the apk size so I'm assuming there is a build error in android studio. I am using android studio beta 0.86 and have tried it on 0.89 with the same result. I have tried build tools for 19.1 to 21 with no result. I have also tried different devices and created a new project (that has never been installed on my devices) and android studio seems to think it needs to be uninstalled first when attempting to deploy.
I have tried switching my device to ART, uninstalling and reinstalling android studio, redownloading the sdk and restarting my computer. NOTHING and I mean NOTHING has worked. I think the problem started after I downloaded the lollipop apis but am not sure. I have tried uninstalling all apps with my package signature on my device but NOTHING works! Not even Project -> Clean Project -> Rebuild
This is extremely frustrating as I cannot debug my apps anymore :/ has anyone had any experience with this error or ways to rectify it?
So turns out that the issue was mismatching sdks between Android Studio and the Project. The project was using an old sdk and once I made them the same, I cleaned and rebuilt the project and everything was good to go.
UPDATE:
I ran into the problem again after I tried to update my SDK and its tools. Turns out that when you try to do this, the SDK locks the tools folder and then you get an error saying some file couldn't be overridden. When this happened to me, all the build tools were deleted so there were errors in the .dex file created when debuggin my app.
We are using android 2.2 (really old i know) and couldn't find a fix for this error. Eventually we found this bug https://android-review.googlesource.com/#/c/30900/. The only solution for us was to remove some libraries...
I kept having the same problem - manually building worked fine, but Android Studio would not build a proper APK.
The problem was that I started the project on Android Studio and Android Gradle plugin version 2.0-beta2. After updating the Gradle plugin to 2.0-beta6 through a simple build.gradle change, the builds stopped working.
Turns out that, although I installed a beta version of Android Studio, the update checker only checked the stable channel. After setting the updater to check the canary channel as well, I was able to upgrade Android Studio to version 2.0-beta6 and builds continued to work normally.
You can change the update preference in Android Studio settings under Appearance and Behavior -> System Settings -> Updates.
I encountered this error when storage of the device is full. Try to open some space.
Try run these commands
adb reconnect
adb reconnect device

Eclipse not compiling new Android code

For some reason, after I build my Android project in Eclipse, it is not giving me any errors, but none of my updates are being compiled.
I've tried both running my app in the emulator, and installing the apk on my phone. It still only compiles the old version of my app, not the new one. I've tried deleting the apk in the bin folder manually before recompiling it, and cleaning the project.
The previous thing that occurred was, my certificate expired, so I deleted the old certificate file.
I do not see any errors in the error log or the console. I'm still pretty new to all this.
This has been driving me nuts recently. I recently migrated from XP to Windows 7, and thought it was a quirk of Eclipse running in XP, but it is still happening, i.e. any changes made, I had to compile twice to get the current version.
For some reason, the solution for me is to make sure the changes are saved before compiling. If you don't save, and do so on the Dialog that pops up when you compile/run, you have to go again. Don't know why this is, maybe I am missing something, it worked fine a few months ago.
Eclipse can mess up sometimes. It would be worth closing Eclipse and rebooting your PC.
Edit: Try reconfiguring your Run Configuration by deleting it and recreating it
Eclipse didn't export the most recent updates for my app.
What worked for me:
In terminal (being in the work folder):
cordova build android
In Eclipse: Clean project.
Refresh
Export app

Categories

Resources