Visual studio for mac - choose android emulator - android

I'm using Visual Studio for Mac, creating Android apps using Xamarin. Whatever I do, VS seems to start a "default" emulator. But I wan't it to use my newly created emulator.
How can I choose emulator, or set a default one?
Previously in XS, there used to be a dropdown selector, it seems to have been removed:
More information. I created a fresh project from scratch, when the menu actually appears:

I figured it out.
I had not enabled the android project for BUILD in the build configuration.
To enable it just right click your solution, click options, under Build > Configurations > Configuration Mappings you may enable your android project as shown below.

Related

Uno Platform Missing emulator list in debug targets for SDK style projects

Having
latest Uno templates,
all green uno-check,
latest VS 2022 preview (17.4.0 Preview 1.0).
Creating new Uno app (either via commandline or selecting from the new project wizard) including Android head - which is the new SDK style project, I'm unable to start the app in an emulator. It's missing and the VS complains either of:
Please select a valid device before running the application.
----------------------------
Microsoft Visual Studio
---------------------------
Unable to start debugging. The startup project cannot be launched. Ensure that the correct project is set as the startup project. The startup project can be changed by selecting the 'Set as Startup Project' command from the right click menu in Solution Explorer.
Additionally make sure its debug settings are correctly configured in project properties.
---------------------------
OK
---------------------------
When using the old non SDK style Android project, e.g. from Uno.Samples, on the same setup, it won't compile though (until <LangVersion>preview</LangVersion> is added to the .csproj file). Anyway, after that, the list of emulators is available and the project can be started on a selected emulator.
Is there any magic I could do on the new SDK style project to have list of emulators to debug the app on?
There is probably an issue in the Visual Studio itself (no relation to Uno). Using 17.3.1 release (not preview):
shows the emulators,
creates some changes in the project upon load (.vs binary content also as new <proj-name>.user file),
allows the project to run.
Interestingly enough, such modified project then works also in preview (although the emulators are still not listed explicitly), even after the .user file is deleted.

Where did the "Profile or Debug APK..." option disappear to in Android Studio 3.4.1?

Android Studio used to have the option to debug existing APKs from the File->Profile or Debug APK. I have used it in Android Studio version 3.4. Now at version 3.4.1, I cannot find it.
Does anyone know if the option was removed from Android Studio or where can I find it?
I had this same issue and here's how I solved it.
I had disabled APK and NDK support in hopes that it would speed up my IDE. I forgot to turn them back on. So I went into Preferences > Plugins and if you don't have them installed, install Android NDK and Android APK support. If you already have them installed, tick Android APK Support and it will prompt you to enable Android NDK Support if you don't have it enabled already.
Since Android Studio menu can be customize, by some way the option has been removed from your toolbar. To add it again go in File -> Settings -> Appearance & Behavior -> Menus and Toolbar
From here open the Main menu -> File -> File Open Actions folders.
Select the Open line, then click on the plus sign on top of the window next to the search bar. Click Add Action... and search for Profile or Debug APK... options.
Apply and you're good to go !
Edit
After some exchanges in the comments we fixed the issue another way.
You have to go into Settings -> Plugins first. Check if you have the plugin Android APK Support activated/installed. If not then install/activate it.
And now you're really good to go !
That's weird because I am using android studio 3.4.1 and its there:
When I had problems after updating android studio all I did was to re-install it and my problems got fixed.
Also, you should know that downloading another version of Android studio is really user-friendly, check my question about it.

Add Android Run/Debug configuration for Flutter project

I am working with a Flutter example project where it shows how to share a FlutterView inside an Android application (and iOS also).
While working with it I tried this:
I make changes to the android project like changing the theme color, if I do hot-reload/run for main.dart I don't see the changes reflected in the running app. I have to stop it from Android Studio and run the main.dart again to see the changes.
To solve the issue I was thinking to add a run/debug configuration for Android app module. So that I could run android app and not main.dart.
Is there a way how to achieve this in Android Studio?
One solution for me was to open the android(/flutter_view/android/app) project from a new window in Android studio. I could run the app this way.
(But here I encountered another issue in case anyone has the solution).
According to my understanding you face problems when you open your project and try to run.
Android studio asks you to configure your project to be able to run...
It's easy to solve near to run button you will find "add configuration" button just press then from left side select "flutter" and put in the field "entrypoint" your main Dart file path main.dart...
EX. E:/project/lib/main.dart....
Then from top right corner press "create configuration"...
That's it.
For Configure your Flutter app on Android you have to Upgrade Gradle file..
So Go to the Tool and at you will find AGP upgrade Assistant..
It Download new Gradle file then its Config automatic..

Intellij cannot select rendering target

I have been using Android Studio, that worked like a charm. Then I reinstalled my computer and switched to IntelliJ, but I kept the SDK on SD card so I don't have to re/downloading it.
It works, I can build an app, but layout editor is not working. I cant select rendering target.
Here is what I see.
When I open the dropdown menu to select rendering target it says just: <null>.
Any ideas?
First download proper SDKs in the SDK manager, and then you need to select the device on which you want to preview. To do so, click on the icon of the two little phones left of the AppTheme above the editor.
You need to have properly configured the IntelliJ project with the Android SDK.
Check your Project Settings at Ctrl+Shift+Alt+S.
Also check your Gradle settings to see if your SDK version has been defined there.

Visual studio can't debug Android Xamarin app

I've started with Xamarin and Android using Visual Studio 2013.
When I start debugging the android app, it builds, deploys to device and then debugging in Visual Studio stops. I can't hit any breakpoint. App is working in device, but I cannot debug it.
Am I missing something?
I've tried various emulators and a physical android device but debugging doesn't work in any of them. It just act like I have stopped it.
Debugging the same solution in Xamarin Studio works, I just can't get it working in Visual Studio.
I was having the same problem and I found this workaround with Hyper-V in Xamarin's documentation: https://developer.xamarin.com/guides/android/deployment,_testing,_and_metrics/debug-on-emulator/visual-studio-android-emulator/
TL;DR; Open Hyper-V Manager -> Go to settings on your emulator -> Go to processor settings -> Select Compatibility -> Mark the "Migrate to a physical computer with a different processor version" checkbox -> Done! (At least for me) VS is now debugging my Android App
Another reason why Visual studio can't debug Android Xamarin app with a Hyper-V is due to you donĀ“t have 'Deploy" option check in android project.
Steps: 1) Enter in "Solution properties" 2) Select "Configurarion Properties" 3) Check "Deploy" in Android project.
Make sure you are running on Debug mode (on target).
Then, check the Properties of the App Project and see if it's using the Xamarin debugger instead of the VisualStudio Debugger.
Enter in "Solution properties"
Select "Configurarion Properties"
Check "Deploy" in Android project.
Open Hyper-V Manager
Go to settings on your emulator
Go to processor settings
Select Compatibility
Mark the "Migrate to a physical computer with a different processor version" checkbox
This will also happen if you don't have any activity marked as your main launcher activity:
[Activity(
...
MainLauncher = true,
...)]
public class MainActivity ...
Easy mistake to make if you're shifting code in from a prior project and the prior project is using a splash activity and your new project is not yet doing so.
Go to property of app project then click android option and checked checkbox in debugging section.then run again.
For anyone who might still need help. Also make sure the build and deploy checkbox's are checked in the configuration manager. .
In my case, after some investigation, I saw I was having this warning: "Failed to read .android.dll' with debugging symbols. Retrying to load it without it. Error details are logged below. 2>Mono.Cecil.Cil.SymbolsNotMatchingException: symbols were found but are not mathing the assembly"
The solution was to disable linking:
Right-click the Android Project -> Properties -> Android Options -> Under "Linker properties", set Linking to None (see image below)
Got this from TedFalasco's answer on this post.
Hyper-V manager can't be installed on Windows 7 (only the management tool gets installed) so if you get this problem, following those steps don't help.
Here is the thing that worked for me and it's mentioned here as an answer but hasn't been marked up or marked as an answer. This is actually the best and easiest solution. nothing else worked for me.
In Visual studio, make sure you choose the solution file (not project files) in the solution explorer. Then go "Project > [project]properties"
in the left pane choose "Configuration Properties > Configuration"
Now check the Deploy feature if possible. Only deployable projects have the option.
This saved my life and I almost gave up on Xamarin. I really hope this helps others like me.....
In my case, the warning was self-explanatory:
Set the debugging information to Portable in the Visual Studio project property pages or edit the project file in a text editor and set the 'DebugType' MSBuild property to 'portable' to use the newer
In other words: Right click on project => properties => build => click on advanced => set the debugging information to portable.
I have tried every answer and none of them worked.
Here is what I did to make it work again:
Plug your physical android device to the computer. Android device must have Developer options enabled.
Choose your android device in Visual Studio.
Run app in Debug mode. Your app should appear on your android device.
Unplug your android device from computer.
Try running your app in android emulator. For me Debug option starts working again.

Categories

Resources