Skip to content Skip to sidebar Skip to footer

"invalid Argument(s): Cannot Find Executable For Null" When Emulated Android On Vs Code - Mac Os X

When I try to emulate Android on VS Code in Mac OS Catalina after installing Android SDK by Android Studio it returns the message: Invalid Argument(s): Cannot find executable for n

Solution 1:

You can get this error both through command line flutter emulator --create flutteremu or using Flutter: Launch Emulator in Visual Studio Code.

Oops; flutter has exited unexpectedly: "Invalid argument(s): Cannot find executable for null.".

You get this error despite flutter doctor telling you that everything is in order.

There is a log file, which details the error here.

If you dig deeper you fill find out that the following Android command line tool does not work:

avdmanager
NoJavaruntimepresent,requestinginstall.

Boo hoooooooo. So despite the fact that Android SDK is full of Java, you still need to install a separate Java just to run some command-line commands. Android SDK might not work if you have a wrong version of Java installed. Here is one good known version installed through Homebrew:

# Install Java 8 and Android SDK
brew tap homebrew/cask-versions

# See details here https://stackoverflow.com/a/61521063/315168
brew cask install adoptopenjdk/openjdk/adoptopenjdk8

Check that Java works now:

java -version
openjdk version "1.8.0_252"
OpenJDK Runtime Environment (AdoptOpenJDK)(build 1.8.0_252-b09)
OpenJDK 64-Bit Server VM (AdoptOpenJDK)(build 25.252-b09, mixed mode)

Now in your shell make sure you have all correct environment variables.

export JAVA_HOME=$(/usr/libexec/java_home)
export ANDROID_HOME=/Users/$USER/Library/Android/sdk
export ANDROID_SDK_ROOT=/Users/$USER/Library/Android/sdk
export PATH=${PATH}:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools

And then run avdmanager again:

avdmanager list

And now you should be able to launch emulator with Flutter support:

flutter emulator --create flutteremu
No suitable Android AVD system images are available. You may need to install these using sdkmanager, for example:
  sdkmanager "system-images;android-27;google_apis_playstore;x86"

So let's install the images:

sdkmanager "system-images;android-27;google_apis_playstore;x86"

And now Flutter should be able to launch an emulator:

flutter emulator --create flutteremu

And finally it will work:

Emulator 'flutter_emulator' created successfully.

Close any running Visual Studio Code. Start Visual Studio Code from shell and explicitly set the environment variables for VSCode process:

export JAVA_HOME=$(/usr/libexec/java_home)
export ANDROID_HOME=/Users/$USER/Library/Android/sdk
export ANDROID_SDK_ROOT=/Users/$USER/Library/Android/sdk
export PATH=${PATH}:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools
code

And now Flutter: Launch Emulator works.

enter image description here

Post a Comment for ""invalid Argument(s): Cannot Find Executable For Null" When Emulated Android On Vs Code - Mac Os X"