Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ERR_SDK_NOT_FOUND: No valid Android SDK root found. #235

Open
PacoRivera13 opened this issue May 26, 2022 · 8 comments
Open

ERR_SDK_NOT_FOUND: No valid Android SDK root found. #235

PacoRivera13 opened this issue May 26, 2022 · 8 comments
Labels

Comments

@PacoRivera13
Copy link

Version:
1.6.0

Description:
I have defined my sdk location using this command on the cmd
set ANDROID_SDK_ROOT=D:\Android\sdk
set ANDROID_HOME=D:\Android\sdk
But any of these are working as expected.

Command Output:
npx capacitor run android --verbose
√ Copying web assets from www to android\app\src\main\assets\public in 1.96s
√ Creating capacitor.config.json in android\app\src\main\assets in 1.53ms
copy android [info] Found 8 Cordova plugins for android:
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
√ copy android in 2.09s
√ Updating Android plugins in 7.77ms
[info] Found 5 Capacitor plugins for android:
@capacitor/[email protected]
@capacitor/[email protected]
@capacitor/[email protected]
@capacitor/[email protected]
@capacitor/[email protected]
/ update android [info] Found 8 Cordova plugins for android:
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
√ update android in 240.14ms
[error] native-run failed with error

    ERR_SDK_NOT_FOUND: No valid Android SDK root found.

    More details for this error may be available online:
    https://github.com/ionic-team/native-run/wiki/Android-Errors

SDK Info:
ERR_SDK_NOT_FOUND: No valid Android SDK root found.
More details for this error may be available online:
https://github.com/ionic-team/native-run/wiki/Android-Errors

@pi0neerpat
Copy link

Did you try using the link from the error? https://github.com/ionic-team/native-run/wiki/Android-Errors

@PacoRivera13
Copy link
Author

Yes I did, I have my SDK installed at C:\Program Files (x86)\Android\android-sdk
then I installed it on a D:Android\sdk

set ANDROID_SDK_ROOT=D:\Android\sdk
set ANDROID_HOME=D:\Android\sdk

But any of these are working as expected.

@timvahlbrock
Copy link

timvahlbrock commented Jun 2, 2022

What worked for me: Reboot.

I just set the env variables shortly before. Seems like even after restarting the terminal NodeJs still applies new scripts with the old env variables.

@agungss
Copy link

agungss commented Jul 4, 2022

I am facing the same problem. Do you have the solution right now?

@agungss
Copy link

agungss commented Jul 4, 2022

I also try "npx cap open android"
when gradle, there was an error: Supplied javaHome must be a valid directory.

But I set the JAVA_HOME correctly (edit .bashrc file, adding PATH JAVA_HOME="thepathtotheJavaJRE". But still, the problem persist.

Anyone got the solution? Many thanks

@timvahlbrock
Copy link

I am facing the same problem. Do you have the solution right now?

I think this is not a bug but a configuration issue. Make sure that Java Home is actually set where you run the command. If you are on windows, make sure to reboot after setting the environment variable. Last one was the reason I had trouble. I think this issue needs to be closed.

@ilyakatz
Copy link

ilyakatz commented Jan 21, 2023

My issues was that native-run expect SDK to live in a very specific place, eg on linux it has to be $HOME/Android/sdk (link), so I had to change my folder structure to accommodate that

@xlinxie
Copy link

xlinxie commented Jun 19, 2023

My issues was that native-run expect SDK to live in a very specific place, eg on linux it has to be $HOME/Android/sdk (link), so I had to change my folder structure to accommodate that

Actually native-run will resolve Android SDK root folder by parsing env variables in the sequence of ANDROID_HOME, ANDROID_SDK_ROOT, SDK_DIRECTORIES.

export async function resolveSDKRoot(): Promise<string> {

if your installed Android SDK in folder other than $HOME/Android/sdk, you should set either ANDROID_HOME or ANDROID_SDK_ROOT environment variables to point to your Android SDK folder.

try run native-run android --sdk-info --verbose to check if Android SDK root folder get parsed correctly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants