androidionic-frameworksdkcapacitor

Capacitor on Android fails with error: "ERR_SDK_PACKAGE_NOT_FOUND: SDK package not found by location: D:\Android_SDK_HOME\platform-tools."


I wanted to run my Ionic/Capacitor app via npx cap run android on an Android emulator. Nevertheless, the process got killed with the following error:

× Deploying app-debug.apk to Pixel_3_API_30 - failed!
[error] ADBs is unresponsive after 5000ms, killing server and retrying...
    ERR_SDK_PACKAGE_NOT_FOUND: SDK package not found by location: 
    D:\Android_SDK_HOME\platform-tools.

    More details for this error may be available online:

            https://github.com/ionic-team/native-run/wiki/Android-Errors

The correct location of the platform tools would be: D:\Android_SDK_HOME\Sdk\platform-tools. My ANDROID_SDK_HOME variable is set to D:\Android_SDK_HOME, but when i change it to D:\Android_SDK_HOME\Sdk, this still results in the same error.

Does anyone know how/from wherre Capacitor accesses the SDK location, and how i can configure it?


Solution

  • In my case I have android-studio in /opt/android-studio.

    My SDK in $HOME/Android/Sdk.

    Error message ERR_SDK_PACKAGE_NOT_FOUND said it was looking for the SDK in /opt/android-studio/platform-tools.

    That directory was not there!

    My solution: ln -s $HOME/Android/Sdk/platform-tools /opt/android-studio

    Then, the command native-run android --list worked.