You don't really need to see the devices in VS. As long as ADB can see it, you can work with your app manually.
The process should look like this, but for more information, please read the documentation on using ADB:
Step 1: Open the correct Terminal
Do not use the Windows cmd.
- Open Windows Search bar.
- Type "Developer Command Prompt for VS 2022".
- Right-click it and select "Run as administrator". (This terminal automatically knows where
msbuild and adb are located).
Step 2: Verify connection
- Connect your device via USB.
- In the command prompt, type:
adb devices
- Check the output:
- List of devices attached:
-
ZE223... device -> Success.
-
ZE223... unauthorized -> Check your phone screen. You need to tap "Allow USB Debugging" on the popup.
- (Empty List) -> The issue is your cable or drivers. You cannot proceed until this list shows your device.
Step 3: Navigate to your project
You need to be in the folder where your .csproj file is.
- Type
cd followed by the path to your project. For example: cd "C:\Users\Michael\source\repos\MyApp\MyApp.Android"
Step 4: Build the app manually
We will ask MSBuild to create the APK directly.
- Type the following command:
msbuild /t:SignAndroidPackage /p:Configuration=Debug
- Wait for the build to finish.
Step 5: Install the app manually
- The APK file is now located in your
bin\Debug folder.
- Type this command to install it (the
-r flag means "reinstall/update" so you don't lose data): adb install -r bin\Debug\com.yourcompany.yourapp.apk (Note: Replace com.yourcompany.yourapp.apk with the actual name of your APK file. You can type dir bin\Debug\*.apk to find the exact name).
Step 6: Debug with logs (the important part)
Since the debugger won't attach automatically:
- Do not close the command prompt.
- Type this command to clear old logs:
adb logcat -c
- Type this command to watch for new logs:
adb logcat -s "YourLogTag" (Replace "YourLogTag" with the tag you use in your C# code, e.g., Log.Debug("MyApp", "Test") means your tag is "MyApp").
- Manually tap the app icon on your phone to launch it.
- Trigger the notification issue.
- Watch the command prompt. You will see your debug messages scroll by in real-time.