Hi !
Step : Set Up Your Salesforce Mobile Developer Tools for Lightning Web Components > Use Salesforce Mobile Developer Tools
sub step: SFDX: Preview Component Locally
after install @salesforce/lwc-dev-mobile
close and re-open visual studio
Android studio is open.
Device is create for simulation.
(I tested running the simulator directly before and everything is fine.)
Error :
Starting SFDX: Start Local Development Server
09:33:51.221 sfdx force:lightning:lwc:start
Starting SFDX: Preview Component Locally
09:33:51.326 sfdx force:lightning:lwc:preview -p Android -t Android1 -n c/bikeCard -a browser -d c:\Salesforce\Formation\bikeCard --loglevel warn
(node:1860) Warning: Deprecated environment variable: SFDX_JSON_TO_STDOUT. Please use SF_JSON_TO_STDOUT instead.
(Use `node --trace-warnings ...` to show where the warning was created)
(node:21892) Warning: Deprecated environment variable: SFDX_JSON_TO_STDOUT. Please use SF_JSON_TO_STDOUT instead.
(Use `node --trace-warnings ...` to show where the warning was created)
» Warning: @salesforce/cli update available from 2.26.10 to 2.27.6.
» Warning: @salesforce/cli update available from 2.26.10 to 2.27.6.
» Warning: force lightning lwc start is not a sf command.
Did you mean force lightning lwc test run? [y/n]:
» Error: Run sf help force for a list of available commands.
09:34:06.773 sfdx force:lightning:lwc:start
ended with exit code 127
Error: To run this command, install the @salesforce/lwc-dev-server plugin. For more info, see [Set Up LWC Local Development](https://developer.salesforce.com/tools/vscode/en/localdev/set-up-lwc-local-dev).
> Requirements
> Checking SDK root location
> Checking Android SDK Prerequisites
> Checking Android Command Line Tools
> Checking SDK Platform Tools
> Checking SDK Platform API
> Checking SDK Platform Emulator Images
› SfError: SDK root location not found. Please set up ANDROID_SDK_ROOT or ANDROID_HOME in your environment.
› SfError: Android command line tools not found.
› SfError: No supported Android platform tools found. Minimum supported Android platform tools version is 23.
› SfError: Android SDK is missing prerequisites: Android SDK root is not set.
› SfError: No supported Android API package found. Minimum supported Android API package version is 23.
› SfError: Install at least one of these emulator images: google_apis,default,google_apis_playstore
√ Requirements (0.000 sec)
Error (1): Requirement verifications for platform %s failed.
Try this:
Please see the error messages above for details on resolving your requirement issues.
09:34:11.483 sfdx force:lightning:lwc:preview -p Android -t Android1 -n c/bikeCard -a browser -d c:\Salesforce\Formation\bikeCard --loglevel warn
ended with exit code 1
Error: Failed to start Android Emulator 'Android1'.
Android1 is the good name for the emulator. (cf screen 001)
They say to install the @salesforce/lwc-dev-server plugin... so i do it.
Error :
PS C:\Salesforce\Formation\bikeCard> sf plugins install @salesforce/lwc-dev-server
» Warning: @salesforce/cli update available from 2.26.10 to 2.27.6.
Polling for new version(s) to become available on npm... done
Successfully validated digital signature for @salesforce/lwc-dev-server.
Finished digital signature check.
Installing plugin @salesforce/lwc-dev-server@latest... failed
» Warning: @salesforce/lwc-dev-server > @oclif/config@1.18.17: Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.
Error: C:\Users\xxxx\AppData\Local\sf\client\2.26.10-b796e35\node_modules\yarn\bin\yarn.js add @salesforce/lwc-dev-server@latest --non-interactive
--mutex=file:C:\Users\xxxx\AppData\Local\sf\yarn.lock --preferred-cache-folder=C:\Users\xxxx\AppData\Local\sf\yarn --check-files exited with code 1
PS C:\Salesforce\Formation\bikeCard>
Well : Package no longer supported.
ok....
start/stop vs
launch again SFDX: Preview Component Locally
(Is it normal that it always takes so long to get started?)
same error than first... so i search for the other error...
› SfError: SDK root location not found. Please set up ANDROID_SDK_ROOT or ANDROID_HOME in your environment.
› SfError: Android command line tools not found.
› SfError: No supported Android platform tools found. Minimum supported Android platform tools version is 23.
› SfError: Android SDK is missing prerequisites: Android SDK root is not set.
› SfError: No supported Android API package found. Minimum supported Android API package version is 23.
› SfError: Install at least one of these emulator images: google_apis,default,google_apis_playstore
well.... first error missing sdk root location... This seems like an obvious error seen like that... but in fact, no...
However, I installed Android Studio in accordance with the previous exercise. I did not find in the trailhead where we must indicate where the path of this environment variable (ANDROID_SDK_ROOT) is and especially what value to put there. I have no idea where the android sdk is... For ANDROID_HOME it's c:\users\<username>\.android ?
Should we install the Android SDK in addition to the Android simulator ?
I welcome all help!
THANKS !
Regards,
C.
next :p
Well... instead of use API 30 i use API 23... it's old version so you must go into tab x86 image instead of recommander. API 23 corresponding to marshmallow version. Intalls it, create new device.
but... no... this is not good.... (an obstacle course....)
√ PASSED: Checking SDK Platform Tools (0.101 sec)› SfError: Android SDK is missing prerequisites: Command failed: C:\Users\xxxxx-cabannes\AppData\Local\Android\Sdk\cmdline-tools\latest\bin\sdkmanager --versionException in thread "main" java.lang.UnsupportedClassVersionError: com/android/sdklib/tool/sdkmanager/SdkManagerCli has been compiled by a more recent version of the Java Runtime (class file version 61.0), this version of the Java Runtime only recognizes class file versions up to 52.0› at java.lang.ClassLoader.defineClass1(Native Method)› at java.lang.ClassLoader.defineClass(ClassLoader.java:756)› at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)› at java.net.URLClassLoader.defineClass(URLClassLoader.java:473)› at java.net.URLClassLoader.access$100(URLClassLoader.java:74)› at java.net.URLClassLoader$1.run(URLClassLoader.java:369)› at java.net.URLClassLoader$1.run(URLClassLoader.java:363)› at java.security.AccessController.doPrivileged(Native Method)› at java.net.URLClassLoader.findClass(URLClassLoader.java:362)› at java.lang.ClassLoader.loadClass(ClassLoader.java:418)› at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:355)› at java.lang.ClassLoader.loadClass(ClassLoader.java:351)› at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:620)› SfError: Android command line tools not found.› SfError: No supported Android API package found. Minimum supported Android API package version is 23.› SfError: Install at least one of these emulator images: google_apis,default,google_apis_playstore√ Requirements (1.635 sec)
well ??? regression... don't do that !! :p
----
Edit : 16h04
Okay I'm not going to create another post again.
To resolve the java version problem, I installed the latest available online (retrievable here: https://www.oracle.com/fr/java/technologies/downloads/#jdk21-windows ), I then updated the JAVA_HOME environment variable to point to this version (C:\Program Files\Java\jdk-21). Then in the java interface I made sure that only the latest version is active. (windows menu, java, configure java, java tab, visualize, check only latest version).
Then restart visual studio.
I come back to the problem "SfError: Install at least one of these emulator images: google_apis,default,google_apis_playstore"
A year late, but - I've had exactly the same troubles you had, and this what fixed it for me:
› SfError: SDK root location not found. Please set up ANDROID_SDK_ROOT or ANDROID_HOME in your environment.
=> ANDROID_SDK_ROOT is obsolete. ANDROID_HOME must be configured manually and point to the location of the SDK. On my box this is "C:\Users\xxxx\AppData\Local\Android\Sdk
". No other environment variables needed.
› SfError: Android command line tools not found.
=> Open Android Studio and install them from its Settings.
› SfError: No supported Android platform tools found. Minimum supported Android platform tools version is 23.
› SfError: Android SDK is missing prerequisites: Android SDK root is not set.
› SfError: No supported Android API package found. Minimum supported Android API package version is 23.
› SfError: Install at least one of these emulator images: google_apis,default,google_apis_playstore
=> From what I understood, you (like me) had a couple of system images under "C:\Users\xxxx\AppData\Local\Android\Sdk\system-images", each with a subdirectory like "google_apis". What was missing in my case to get rid of the afore "SfError" lines is just a Java JDK above 16 in the PATH (Salesforce mostly recommends 21). Some more details here.
I set up a couple of emulators, and some came back blank in accordance to what you described. The blank one's use versions that are too old. For example API version 23 (Android 6.0) seems too old! API version 31 (Android 12.0) rendered the LWC.
Hi @Christophe BRACCHI CABANNES
I'm a member of Trailhead Help, if your issue is resolved, please make sure to mark the response which helped you to resolve your query as 'Best Answer' so that it may help other users with a similar issue.
If your issue is still not resolved do let us know the URL of the unit you are stuck in and we'll create a help case on your behalf
next...
re-launch command :
sfdx plugins:install @salesforce/lwc-dev-server
failed...
Installing plugin @salesforce/lwc-dev-server@latest... failed » Warning: @salesforce/lwc-dev-server > @oclif/config@1.18.17: Package no longer » supported. Contact Support at https://www.npmjs.com/support for more info. Error: C:\Users\xxxxxxx\AppData\Local\sf\client\2.26.10-b796e35\node_ modules\yarn\bin\yarn.js add @salesforce/lwc-dev-server@latest --non-interactive --mutex=file:C:\Users\xxxxx\AppData\Local\sf\yarn.lock --preferred-cache-folder=C:\Users\xxxxx\AppData\Local\sf\yarn --check-files exited with code 1
in the page https://developer.salesforce.com/tools/vscode/en/localdev/set-up-lwc-local-dev they have it easy. After giving the instruction, they point out that there are problems. Then suggest to see the installation and if it's ok, then it's ok... but there's absolutely nothing to say what to do if it's not ok... Oo
try again the command (thx Booker EVail )
npm install -g @salesforce/lwc-dev-server
failed...
lot of "deprecated" and "not supported"...
problem with python...
re-install python (https://www.python.org/downloads/) for all users
re-launch command
failed
too long cf pj log.txt
cf log, we must install visual studio 2019 (or other version) in addition to visual studio code ?
This is all totally mind-blowingly complicated... :/
Synthetic 2024-02-13 15h56 :
- All problems launching the emulator are resolved. I manage to display the Android emulator and it tries to connect to the simulated site.
- I have a problem installing the server. The tested commands crash on errors that I can't understand. The impact is that the Android emulator opens the browser, tries to connect to the site URL but cannot find it and returns a classic site not found error.
thx Booker EVail but I had already arrived at these results ;) (the server installation step is still ko despite your suggestions).
Well, in the end I ended up with:
- Completely uninstall Android studio then re-install.
- Reconfigure environment variables to the default path C:\Users\<username>\AppData\Local\Android\Sdk
- Re-add the SDK tools android SDK command-line
Another point of attention, if the device name contains a “_”, this is not recognized! You need a space instead otherwise VC won't find it.
Okay now, I have everything working except the display of the application in the simulator browser, the page remains completely white...
The pages come directly from the git of the exercise, I will try in a version other than API 34 to see if the problem comes from there...
I try with a device API 30 and is not better... after a moment, error page :
Uninstall SDK 34, and re-install 34...
stop/start visual studio
now....
√ Requirements (22.431 sec)
Start Preview... searching for device Android_API34
creating device Android_API34...
starting device Android_API34...
Error (1): Invalid emulator: Android_API34
16:09:01.115 sfdx force:lightning:lwc:preview -p Android -t Android_API34 -n c/bikeCard -a browser -d c:\Salesforce\Formation\bikeCard --loglevel warn
ended with exit code 1
But, i try launch Android_API34 manualy and it's ok...
it's exhausting....
Any ideas ?
Thx,
C.
next... in the series "I answer myself" :p
the sdkmanager command is not install by default... you must install it. In android studio, projects > more actions > SDK manager > select tab SDK tools > check Android SDK command-line tools (latest) and button apply.
Some description can be find here : https://developer.salesforce.com/docs/atlas.en-us.mobile_offline.meta/mobile_offline/mobile_extensions_setup_android_studio.htm
For now, I have this error :
› SfError: Install at least one of these emulator images: google_apis,default,google_apis_playstore› SfError: No supported Android API package found. Minimum supported Android API package version is 23.› SfError: Android SDK is missing prerequisites: Command failed: C:\Users\cbracchi-cabannes\AppData\Local\Android\Sdk\cmdline-tools\latest\bin\sdkmanager --versionException in thread "main" java.lang.UnsupportedClassVersionError: com/android/sdklib/tool/sdkmanager/SdkManagerCli has been compiled by a more recent version of the Java Runtime (class file version 61.0), this version of the Java Runtime only recognizes class file versions up to 52.0› at java.lang.ClassLoader.defineClass1(Native Method)› at java.lang.ClassLoader.defineClass(ClassLoader.java:756)› at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)› at java.net.URLClassLoader.defineClass(URLClassLoader.java:473)› at java.net.URLClassLoader.access$100(URLClassLoader.java:74)› at java.net.URLClassLoader$1.run(URLClassLoader.java:369)› at java.net.URLClassLoader$1.run(URLClassLoader.java:363)› at java.security.AccessController.doPrivileged(Native Method)› at java.net.URLClassLoader.findClass(URLClassLoader.java:362)› at java.lang.ClassLoader.loadClass(ClassLoader.java:418)› at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:355)› at java.lang.ClassLoader.loadClass(ClassLoader.java:351)› at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:620)› SfError: Android command line tools not found.
This trailhead is really not well done, it's missing a ton of things....
All help... etc... thanks...
C.
Well, I was able to move forward with my problem. It's not finished but I'll let you know ;)
I updated three environment variables:
ANDROID_HOME ==> C:\Users\xxxx\AppData\Local\Android\Sdk
ANDROID_SDK_HOME ==> C:\Users\xxxx\AppData\Local\Android\Sdk
ANDROID_USER_HOME ==> C:\Users\xxxx\.android
For update environment variable, in windows, windows key, enter the text variable, click on environment variable, click on button "envrionment variable", and add the 3 variables.
To find the way C:\Users\xxxx\AppData\Local\Android\Sdk (or other) :
in Android studio, more action > SDK manager > the path is on "android SDK location" field.
stop/start visual studio.
Now, I have this error :
› SfError: Android command line tools not found.
› SfError: Android SDK is missing prerequisites: Command failed: C:\Users\xxxx\AppData\Local\Android\Sdk\cmdline-tools\sdkmanager --version
Le chemin d'acc�s sp�cifi� est introuvable.
› SfError: No supported Android API package found. Minimum supported Android API package version is 23.
› SfError: Install at least one of these emulator images: google_apis,default,google_apis_playstore
For now, I haven't found where to configure the correct path.
I always welcome your good ideas ;)
THANKS,
Sincerely,
C.
I can see your query i give me my best...
First, it's multiple issues related to setting up your Salesforce Mobile Developer Tools for Lightning Web Components (LWC) and previewing components locally on an Android emulator. Let's address each problem step by step:
Android SDK Root Not Found:
This error indicates that the environment variable ANDROID_SDK_ROOT or ANDROID_HOME is not set. Since you've installed Android Studio, the SDK is typically located within its installation directory.
You can find the Android SDK location by navigating to the Android Studio installation directory. Usually, it's something like C:\Program Files\Android\Android Studio\.
Set the ANDROID_SDK_ROOT environment variable to point to this directory. For example, ANDROID_SDK_ROOT=C:\Program Files\Android\Android Studio\.
Alternatively, you can set ANDROID_HOME to the same directory.
More information is here: https://developer.salesforce.com/tools/vscode/DogNeedsBest/en/troubleshooting
Android Command Line Tools Not Found:
After setting up the SDK root location, ensure that the Android command-line tools are installed.
You can install them through the Android Studio SDK Manager.
No Supported Android Platform Tools Found:
Ensure that the necessary Android platform tools are installed. These are typically included with the Android command-line tools.
Make sure that the minimum supported Android platform tools version (version 23) is installed.
Install Emulator Images:
Install at least one of the recommended emulator images: google_apis, default, or google_apis_playstore.
You can do this through the Android Studio AVD Manager.
@salesforce/lwc-dev-server Plugin Installation Error:
It seems like there might be an issue with the installation of the @salesforce/lwc-dev-server plugin.
You may try reinstalling it using npm or yarn:
npm install -g @salesforce/lwc-dev-server
or
yarn global add @salesforce/lwc-dev-server
Once you've addressed these issues, try running the preview command again (sfdx force:lightning:lwc:preview). Ensure that the Android emulator is properly configured and running before attempting to preview the Lightning Web Component locally.
I hope my answer is helpful for you, If yes please select as solution..
Best regard,
Booker EVail