Android Studio 3.1 "Launch" is not compiling code

When I try to install the application, there are two possibilities:

  • Install an existing APK from the build folder when I launched the app
  • Install APK after clean build

For an existing APK in the build folder, the application just works fine. But when I clean the project using Build Clean Project , and then try to run the app (i.e., Install the application on my emulator or physical device), it shows me an error:

The file APK / Users / MyApplicationName / app / build / outputs / apk / app-debug.apk does not exist on disk.

NOTE. This behavior only happens when I clean up the project, and not when I already have a ready-made APK application in my build folder

I mentioned: The APK file does not exist on the disk , but I want to say that when we usually launch the application after cleaning the project, we never need to build it, if the APK does not exist in the build folder, it automatically generates and installs the latest version.

Things I tried:

  • Launching the application when the APK file exists in the build folder (works great)
  • Launch Clean Project → Launch the application (it is expected that the project will be built and the application will be installed, but it shows the above error!)
  • The same process of cleaning and starting the application after executing Invalidate Caches/Restart
+64
source share
3 answers

I have a solution for your problem. Hope this helps!

Also confirmed by Android Studio on Twitter : https://twitter.com/androidstudio/status/981914632892960768

1) Change the configuration of your application as shown below.

enter image description here

2) Here you can see the configuration of your application, as shown below.

enter image description here

3) The Gradle -aware make attribute is missing before configuring the launch. You can see here.

enter image description here

4) Please add this Gradle -aware Make attribute this way. Click on the + icon and select Gradle -aware Do as shown on this screen.

enter image description here

5) You can add this without recording any tasks, just click the “OK” button, and the task will be added, and now it should look like this. Now apply the changes and run the application.

enter image description here

Hope this solves this old problem of installing apk on a clean build in the new version of Android 3.0.

Happy coding !!

+120
source

The file APK / Users / MyApplicationName / app / build / outputs / apk / app -debug.apk does not eat on disk.

There may be a mistake. You must change the settings.

You should open the Run/Debug Configurations dialog and select Run > Edit Configurations

Make sure Gradle-aware Make added to the TaskList or not. If not, press + and select one of the options.

enter image description here

Note

If you get

Completion completed with 0ms error when generating split APK dependencies com.android.ide.common.process.ProcessException: failed on com.android.builder.core.AndroidBuilder.processResources (AndroidBuilder.java:809) in com.android.builder .core.AndroidBuilder.processResources (AndroidBuilder.java:797) in com.android.build.gradle.internal.transforms.InstantRunSplitApkBuilder.generateSplitApkResourcesAp (InstantRunSplitApkBuilder.java liver73)

You should cancel INSTANT RUN .

File-- Settings - Build, Run, Deploy - Instant Launch, and uncheck Enable Instant Launch .

+2
source

clean the project and run it again

If it does not work, then

  • Step 1 Close your project.
  • Step 2 Go to the project folder and delete the entire build folder.
  • Step 3 run the project.
0
source

Source: https://habr.com/ru/post/1276112/


All Articles