Android: application often crashes on instant launch

In my Android app, I am debugging it with instant start enabled.

An application very often causes unexpected errors that are resolved if I make a clean build.

As an example, sometimes there are class exceptions in which the class is actually absent. In addition, cast class exceptions sometimes occur when trying to pass the View returned by findViewById() target type (probably, the Android studio incorrectly interpreted the identifiers of the elements during hot deployment of layouts).

All these errors are resolved without changing the code, just by doing a complete build. Instant start successfully made the build process two to three times slower for me.

Why am I getting these errors? Does anyone know how to get started quickly?

+7
android android-instant-run
source share
4 answers

You are not the only one. Instant startup is a little stable, or we can say that it is unreliable.

Instant startup has several swap steps as this document describes . In your case, Instant Run was not able to recognize your changes well, as well as a warm exchange, even if it requires a cold exchange, etc.

Instant start-up is useful when editing a small placement of the GUI, I want to say that this is the only useful script at the moment, so I recommend that you disable it during general development. You can disable it by unchecking the Settings > Build, Execution, Deployment > Enable Instant Run to hot swap... checkbox.

If you think that Instant Run is bizarre and still wants to use it, you are likely to encounter this problem many times. To do this, simply rebuild how you survived. That is all we can do now.

+5
source share

Instant startup is still full of errors. Even Google says that:

Instant Run is designed to speed up the build and deployment process in most situations. However, there are some aspects of using Instant Run that can affect its behavior and compatibility with your application. if you experience any other problems while using Instant Run, please write a bug

He adds some dex files to our application to speed up the build and deployment process. Sometimes, when you change the layout, and then create and run a project, it still shows the old layout. Even apk will be produced; it will not work on some devices.

Now itโ€™s better if we turn it off:

To disable Instant Run:

  • Open the Preferences or Preferences dialog box.
  • Go to build, run, deploy> Instant Run.
  • Uncheck the box next to "Enable Instant Launch."
+3
source share

This is the document about Instant Run :

  • Android Studio now deploys clean builds faster than ever before. In addition, clicking incremental code changes to an emulator or physical device now almost instantly. Review your updates without redeploying a new debug build or, in many cases, without restarting the application.
  • Instant Run supports the following changes in the running application:
    • Changes to the implementation of an existing instance method or static method
    • Changes to an existing application resource
    • Changes structural code, such as a method signature or static field (requires the target device to work with API level 21 or higher).

Therefore, I think that when you add a new class or add a new view_id, you need to clear - rebuild your project. This is just my opinion, correct me if I am wrong. Learn more about Instant Run

+1
source share

If I modify the AndroidManifest.xml file, Android studio will make the full assembly, but it is much faster than clearing the fist and then building the project.

So, I add an empty line to the manifest file whenever I want Android Studio to complete the project completely. It is very effective to complete a complete assembly manually.

0
source share

All Articles