Open artyomszasa opened 2 years ago
I tested in Ubuntu and had the same error message and i had to manually configure folders and enviroment variables to AndroidSdk
dependency correctly read android and java paths.
I added these lines on '.bashrc'
export ANDROID_HOME=$HOME/Android/Sdk
export PATH=$PATH:$ANDROID_HOME/tools
export PATH=$PATH:$ANDROID_HOME/tools/bin
export PATH=$PATH:$ANDROID_HOME/build-tools
export PATH=$PATH:$ANDROID_HOME/platform-tools
export PATH=$PATH:$ANDROID_HOME/cmdline-tools
export JAVA_HOME=/usr/lib/jvm/java-11-openjdk-amd64
export JDK_HOME=/usr/lib/jvm/java-11-openjdk-amd64
cmdline-tools
also downloaded in wrong folder. AndroidSdk
tried to look items on version subfolder of cmdline-tools
so I had to put its content on some sub folder like cmdline-tools/leatest
After that I was able to run my dotnet 6 android (no maui or comet) application on ubuntu.
I found the easiest way to fix it was to link the sdk to where the tool expect it : https://github.com/Redth/AndroidSdk.Tools/blob/master/AndroidSdk/AndroidSdkManager.cs#L13
On my macOS, it was with the following command with the sdk from Android Studio
ln -s ~/Library/Android/sdk/ ~/Library/Developer/android-sdk-macosx
I have this issue too. But my ANDROID_SDK_ROOT
is set correctly to /home/gijsbert/android-toolchain/sdk
which is where my Android is installed. The file @cl3m references has ANDROID_SDK_ROOT
as candidate that's checked, so it ought to work.
When I look at the code and try to reconstruct the command that should be executed, I end up with this:
$ dotnet /home/gijsbert/.vscode/extensions/clancey.comet-debug-0.3.16/src/mobile-debug/bin/Debug/net6.0/mobile-debug.dll util -c=devices -t=android
{"id":"a15f4c51-c78f-484e-b598-f9b43e9c7037","command":"devices","error":"Object reference not set to an instance of an object."}
The usage info seems to have a strange bug, for which I've made https://github.com/Clancey/vscode-comet/pull/35
I've looked at the DLL code and theoretically the issue could be that the AndroidSdk.Adb()
returns null
. ~However, I'm not sure how I would test that.~
I've found that AndroidSdk
comes from NuGet where its repository is listed as https://github.com/redth/AndroidSdk.Tools. So I've followed the instructions there, and installed the tool:
$ dotnet tool install -g AndroidSDK.Tool
You can invoke the tool using the following command: android
Tool 'androidsdk.tool' (version '0.5.2') was successfully installed.
And the tool itself works fine:
$ android device list
┌────────────┬──────────┬───────────────┬─────────────────────┬─────────┐
│ Serial │ Emulator │ Device │ Model │ Product │
├────────────┼──────────┼───────────────┼─────────────────────┼─────────┤
│ ZY326LM65L │ False │ troika_sprout │ motorola_one_action │ troika │
└────────────┴──────────┴───────────────┴─────────────────────┴─────────┘
Note: It was caused by the AndroidSdk.AvdManager.ListAvds()
call. I've made a PR that includes a workaround so that physical devices can still be used when the error occurs.
Error shown is vs code: Cannot read properties of undefined (reading 'map')
$ dotnet ./mobile-debug.dll util -c=devices -t=android
returns{"id":"db0acfbb-edf2-4f04-896a-03690122eb78","command":"devices","error":"Object reference not set to an instance of an object."}