I have Android application which was working fine but few hours ago it started showing me error on Run 'app' click in Android Studio:
Error:Execution failed for task ':app:transformClassesWithInstantRunForDebug'.
> org.objectweb.asm.tree.analysis.AnalyzerException: Execution can fall off end of the code
If I build app from console like gradle assembleRelease everything works fine.
So my question is how to fix this, what could cause this problem. It drives me crazy, because I can't start my app only from Android Studio.
Btw: I already tried to google it and a lot of answers about multidex problem but I guess it's not an option in my case.
Delete build dir
Try deleting the contents of your build directory, and then rebuilding.
appName/build and/or appName/app/build
Alternatively, clean your build
A less brute force option to try is to clean the build.
Build -> Clean Project or Build -> Rebuild Project
Related
I have a simple project and I remove some color resources from my file.
Expectations:
I build the project and it should fail. In the Build Output I should have the logs where it shows me the files where build fails. (Because the color resources are missing)
Reality (Android Studio 3.4.2):
I build the project and it fails. In the Build Output I see:
Android resource linking failed...
I navigate through all the failed tasks and none of them shows the proper logs.
Android Studio used to have this working properly. Does any one know any settings that maybe can fix what the Build Output shows?
I know that if I Analyze > Inspect code I can see the proper list of files where there are errors. But this takes time. I also know that running the build task in terminal it shows the files where there are errors. I want to have it like it used to be before.
I know that someone at Android Studio had one job and he didn't do it right but here I am for your help.
Try: Build -> Clean Project
That cleans the gradle file
Alternatively: File->Invalidate Caches / Restart
Then Sync Project with gradle files
Give these a go and see if it changes anything. It should start giving error for resource file.
This issue is fixed in Android Studio 3.5
Just in case:
Be aware of this issue: Android studio 3.5 refactor issue
I had an Android project that transferred all the code and resources and files to a new project! But build gradle is still being processed when I want to run the project and apparently never wants to finish. My project has no errors..
Does anyone have a solution to this problem?
i set http proxy to none .
i cleaned project and tried again .
i invalid caches/restart and tried again.
But none of these ways helped..
I have to close the android studio from Task Manager. And then delete the contents of the crash folder from gradle and invalid caches/restart and clean project and after that, I will run the program, and with any error, all these things should be done
this is image link https://imgur.com/uVn8UMm
My problem Solved when i install new windows and new android studio ...
There may be a problem with my previous SDK
When I try to install an app, there are two possibilities:
Install existing APK from build folder when I run the app
Install APK after performing clean build
For existing APK in the build folder, the app just works fine. But when I clean the project using Build -> Clean Project, and then try to run the app (i.e. install the app to my emulator or physical device), it shows me error:
The APK file /Users/MyApplicationName/app/build/outputs/apk/app-debug.apk does not exist on disk.
NOTE: This behaviour happens only when I clean the project and not when I have already have a pre-built app APK in my build folder
I've referred to: The APK file does not exist on disk but my point is, when we usually run the app after cleaning the project, we never need to make a build of it, if the APK is not existing in the build folder, it automatically generates and installs the latest one.
Things I've tried:
Running the app when APK file exists in the build folder (works perfectly fine)
Running the Clean Project -> Running the app (expected is the project would be built and the app would get installed but it shows the above mentioned error!)
Same process of cleaning and running the app after doing Invalidate Caches/Restart
I have solution for your issue.
Also confirmed by Android Studio on Twitter : https://twitter.com/androidstudio/status/981914632892960768
Edit your app configuration as below.
Here you can see your app configuration as below.
Here is missing Gradle-aware make attribute in before launch configuration. You can see here.
Please add this Gradle-aware Make attribute through this way. Click on + icon and select Gradle-aware Make as seen in this screen.
You can add this without writing any task just press OK button and task will be added and now it should look like this. Now apply changes and run your application.
It will solve this old apk installing issue on clean build in new Android Studio 3.1 issue.
Note : This issue is resolved in new Android Studio 3.1.1 Stable release.
The APK file
/Users/MyApplicationName/app/build/outputs/apk/app-debug.apk does not
exist on disk.
May be bug. You should change Settings.
You should open the Run/Debug Configurations dialog & select Run > Edit Configurations
Make sure, Gradle-aware Make is Added in TaskList or not. If not then click + & select from the options.
Note
If you receive
Shutdown finished in 0ms Error while generating dependencies split APK
com.android.ide.common.process.ProcessException: Failed to execute
aapt at
com.android.builder.core.AndroidBuilder.processResources(AndroidBuilder.java:809)
at
com.android.builder.core.AndroidBuilder.processResources(AndroidBuilder.java:797)
at
com.android.build.gradle.internal.transforms.InstantRunSplitApkBuilder.generateSplitApkResourcesAp(InstantRunSplitApkBuilder.java:373)
You should Un-Check INSTANT RUN.
File-- Settings-- Build, Execution, Deployment -- Instant Run and
uncheck Enable Instant Run.
clean your project and run again
If it's not work then
Step 1 Close your project.
Step 2 Go to your project folder and delete all build folder.
Step 3 run your project.
This issue has been fixed with Android studio 3.1.1 (April 2018) release.
Update your android studio to 3.1.1.
Here is there explanation regrading the issue details, cause and solution:
In some cases, when a project created in Android Studio 3.0 was opened for the first time in Android Studio 3.1, the Gradle-aware Make task was removed from the Before launch area in Run/Debug Configurations. The result was that projects did not build when the Run or Debug button was clicked, which in turn caused failures such as deployment of incorrect APKs and crashes when using Instant Run.
To solve this problem, Android Studio 3.1.1 adds the Gradle-aware Make task to the run configuration for projects that are missing this entry. This modification occurs after the first Gradle sync when the project is loaded.
Official release notes: https://developer.android.com/studio/releases/index.html#3-1-0
For all people seing this and having the issue on Android Studio +4.0.0:
Run -> Edit configurations... -> disable check box (Allow parallel run)
It may slow your build a little but it better than running the app more than one time.
When I try to install an app, there are two possibilities:
Install existing APK from build folder when I run the app
Install APK after performing clean build
For existing APK in the build folder, the app just works fine. But when I clean the project using Build -> Clean Project, and then try to run the app (i.e. install the app to my emulator or physical device), it shows me error:
The APK file /Users/MyApplicationName/app/build/outputs/apk/app-debug.apk does not exist on disk.
NOTE: This behaviour happens only when I clean the project and not when I have already have a pre-built app APK in my build folder
I've referred to: The APK file does not exist on disk but my point is, when we usually run the app after cleaning the project, we never need to make a build of it, if the APK is not existing in the build folder, it automatically generates and installs the latest one.
Things I've tried:
Running the app when APK file exists in the build folder (works perfectly fine)
Running the Clean Project -> Running the app (expected is the project would be built and the app would get installed but it shows the above mentioned error!)
Same process of cleaning and running the app after doing Invalidate Caches/Restart
I have solution for your issue.
Also confirmed by Android Studio on Twitter : https://twitter.com/androidstudio/status/981914632892960768
Edit your app configuration as below.
Here you can see your app configuration as below.
Here is missing Gradle-aware make attribute in before launch configuration. You can see here.
Please add this Gradle-aware Make attribute through this way. Click on + icon and select Gradle-aware Make as seen in this screen.
You can add this without writing any task just press OK button and task will be added and now it should look like this. Now apply changes and run your application.
It will solve this old apk installing issue on clean build in new Android Studio 3.1 issue.
Note : This issue is resolved in new Android Studio 3.1.1 Stable release.
The APK file
/Users/MyApplicationName/app/build/outputs/apk/app-debug.apk does not
exist on disk.
May be bug. You should change Settings.
You should open the Run/Debug Configurations dialog & select Run > Edit Configurations
Make sure, Gradle-aware Make is Added in TaskList or not. If not then click + & select from the options.
Note
If you receive
Shutdown finished in 0ms Error while generating dependencies split APK
com.android.ide.common.process.ProcessException: Failed to execute
aapt at
com.android.builder.core.AndroidBuilder.processResources(AndroidBuilder.java:809)
at
com.android.builder.core.AndroidBuilder.processResources(AndroidBuilder.java:797)
at
com.android.build.gradle.internal.transforms.InstantRunSplitApkBuilder.generateSplitApkResourcesAp(InstantRunSplitApkBuilder.java:373)
You should Un-Check INSTANT RUN.
File-- Settings-- Build, Execution, Deployment -- Instant Run and
uncheck Enable Instant Run.
clean your project and run again
If it's not work then
Step 1 Close your project.
Step 2 Go to your project folder and delete all build folder.
Step 3 run your project.
This issue has been fixed with Android studio 3.1.1 (April 2018) release.
Update your android studio to 3.1.1.
Here is there explanation regrading the issue details, cause and solution:
In some cases, when a project created in Android Studio 3.0 was opened for the first time in Android Studio 3.1, the Gradle-aware Make task was removed from the Before launch area in Run/Debug Configurations. The result was that projects did not build when the Run or Debug button was clicked, which in turn caused failures such as deployment of incorrect APKs and crashes when using Instant Run.
To solve this problem, Android Studio 3.1.1 adds the Gradle-aware Make task to the run configuration for projects that are missing this entry. This modification occurs after the first Gradle sync when the project is loaded.
Official release notes: https://developer.android.com/studio/releases/index.html#3-1-0
For all people seing this and having the issue on Android Studio +4.0.0:
Run -> Edit configurations... -> disable check box (Allow parallel run)
It may slow your build a little but it better than running the app more than one time.
I pulled some recent changes from my git repo, and suddenly, Android Studio was throwing up token not found errors for R.java. I hit "Make Project" in Android Studio, thinking a new build would fix these errors, when instead I got this:
Information:Compilation completed with 2 errors and 0 warnings in 5 sec
Information:2 errors
Information:0 warnings
Error:Gradle:
FAILURE: Could not determine which tasks to execute.
* What went wrong:
Task 'assembleDebug' not found in root project 'project'.
* Try:
Run gradle tasks to get a list of available tasks.
Error:Could not execute build using Gradle distribution 'http://services.gradle.org/distributions/gradle-1.6-bin.zip'.
The fact that it won't compile explains the problems with R.java, but I'm mystified about the problems Gradle is having. Any help?
[Edit:] I booted into Linux and noticed that it didn't have the same issue. I also noticed under Project Properties that, in Windows there are no linked Gradle projects but in Linux, the project is listed as a linked project. Unfortunately, this tool to help me fix my issues apparently doesn't exist in Android Studio, only in IntelliJ proper.
Just close everything and Restart the Android Studio and compile once again. I faced the same problem many times. It worked for me !
I had the same issue. I got it resolved my setting to the correct JDK folder path.
Also make sure you have "JAVA_HOME" environment variable.
Closing Android Studio and opening it again solved my problem.