Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Instant run doesn't work due to "multiple process"

After having configured instant run, the run button has a small yellow thunderbolt.But while I run the app, Android Studio still performed a full build & install, full message is listed in the picture.

I've searched the official documents in http://tools.android.com/tech-docs/instant-run , but there wasn't anything about "multiple process".I wonder "multiple processes" means compiling or my android app.

What should I configure to turn off multiple processes and experience instant run ?

like image 289
futureer Avatar asked Feb 28 '16 08:02

futureer


People also ask

Can a program be running in multiple processes?

A Computer ProcessThere can be multiple instances of a single program, and each instance of that running program is a process. Each process has a separate memory address space, which means that a process runs independently and is isolated from other processes.

Can multiple process execute the same code?

In multiple processing environments, each process executes the same code but has its own memory and file resources. All threads can share same set of open files, child processes. If one process is blocked, then no other process can execute until the first process is unblocked.

Can we have many processes running for one program?

Many processes may execute a single program. There program code may be the same but program data may be different.

What is instant run in Android Studio?

If you are an Android Studio user, one of the most important steps to take is to disable Android Studio Instant Run. Instant Run is a feature that is designed to streamline the development process by reducing the time to apply code changes to your app.


1 Answers

I ran into this problem when running ProcessPhoenix. Instead of disabling it completely, I just disabled it for my debug build.

Instead of compile I use
releaseCompile 'com.jakewharton:process-phoenix:2.0.0'

And to not break the build I use reflection to trigger the application process restart:

try {
    Class clazz = Class.forName("com.jakewharton.processphoenix.ProcessPhoenix");
    Method triggerRebirthMethod = clazz.getMethod("triggerRebirth", Context.class);
    triggerRebirthMethod.invoke(this, new Object[]{getActivity()});
} catch (Exception e) {
    // Exception handling
}

So now I can still use Instant Run and keep the lib included. :)

(Of course, reflection is never ideal, but the app process restart is only used in one rare particular case in the app.)

like image 80
Roy Solberg Avatar answered Nov 11 '22 20:11

Roy Solberg