Visual Studio .Net Developer : How do I structure an android studio project - c#

I am now starting to learn android development.
I made a small app in visual studio using xamarin (C#) and I wanted copy it to android studio so I can also learn a new language and a new IDE.
I currently have a solution (App.sln) under that I have the main project (App.csproj) and also a class library project to hold my classes (App.Model.csproj)
In android studio, do I create a new module and call it com.app.model or do I just create a new package in the main module?

If you are currently using Xamarin Native approach, the porting from C# to Android Java should be quite straight forward because most of the API is still the same name. The difference mostly is just TitleCase in C# but camelCase in Java. Also, you will need to rename Android layout file from *.axml to *.xml.
If you are using Xamarin.Forms approach, then you will not able to port to Java easily because the API is totally different compare to native Android now. Xamarin.Forms is having its own API set that mapped back to individual native platform's API.
Checking out native Android tutorial will help you to understand better. However, why you want to go back to native when you already know about Xamarin. I came from Android native background and I didn't look back into native since I started with Xamarin.

Related

A very complicated workaround for using a C# dll with an Android app? (xamarin)

I have an proprietary Android app (created with Android Studio) and I need to add some functionality which requires to use a C# DLL.
The app is connecting wirelessly to a development board that does some sensor measurements. Normally on windows apps the dll is used to do some complex calculations of calibration coefficients for the measuring.
My problem is:
I don't have the the source code of the DLL and most likely I won't be approved to access it.
I've read that you can use xamarin to make android apps and use C# dlls but I can't rewrite the whole app for xamarin just to use the dll (also I've never used xamarin)
So far I had the idea to build a simple http server with C# that gets parameters with a GET request, runs them through the dll and returns the results. However it's not an ideal solution because it requires a separate pc to run the server and the adndroid device to have a network connection to it.
My second idea is to build a separate app with xamarin that uses the dll and make my main app start it just to calculate the coefficients and get the results. Perhaps make the second app not visible in the launcher and somehow distribute the two apps together.
Since I am not experienced with android development and especially xamarin and I don't have a lot of time to waste on this project I want to know if my idea is feasible or if there is a better alternative.
Can you suggest some useful tutorials for xamarin and using dlls with it?
===============================================
Edit
I have managed to get the source code of the dll project which is in C++ (and full of windows only stuff) and now I'm trying to use NDK to compile it and JNI with Android studio to use the native functions. Unfortunately almost every step has it's own quirks and problems and it's far from smooth :/ I wouldn't recommend it to beginners like me!
I know this answer is late, but I'm in a similar situation right now.
This project here helped me setup a native Android Studio build with an embedded C# lib:
https://github.com/royd/KotlinAppWithXamarinDependency
The only issue I'm facing right now, that I can't get the R8 obfuscation/optimization to work without breaking the app.

Convert Existing Windows 10 UWP Application in Android

I've found a few examples, as I in a Xamarin.Native use a Windows UWP. But that would mean that I a Xamarin.Nativ in a Windows UWP Convert.
I would like convert a finished Windows UWP application to the target Android or iOS. Is that generally supported or needs my UWP application rebuild again with Xamarin?
Links:
Adding a Universal Windows Platform (UWP) App
Getting Started with Xamarin.Forms 2.0’s Windows 10 Preview
Unfortunately asfar as I know there is no converter that allows to convert UWP app to Android app straight forward.
There are few ways to make the whole process a lot much more easier (so you can create your Android app faster).
If you wrote your UWP application and separated common code that can be used in the other applications you can also use it in Xamarin.Android app - the best way is to have PCL with the common code.
It is also important which type of Xamarin app you would like to create:
1) Xamarin Forms - common UI for each app: Windows, Android and iOS.
There is one shared code that can be used by them. Remember that Xamarin Forms apps are generally speaking the best for displaying the data and they are limited with reference to platform specific functionality.
Please see below to read more:
https://docs.xamarin.com/guides/cross-platform/application_fundamentals/building_cross_platform_applications/sharing_code_options/
2) Xamarin.Platfrom (so Xamarin.Android and Xamarin.iOS):
Here you can create native UI foreach of the project (Windows, Android and iOS) and access specific platform functionality.
With reference to the code - you can put common code in one PCL and have access to it from each project.
Please see this site - here you can find different Xamarin options to create cross-platfrom apps:
https://developer.xamarin.com/
Firstly, if you want a shared code, using Portable class library, you can use the same code for all the platforms including WPF, Android and iOS. First of all what you can do is convert the codes that is used again and again in the PCL (Portable Class Lirary). Once you get used to PCL, you can easily work on any platform you want.
As the Android, iOS are different from windows, a lot of .net framework functionality is not supported in PCL. Although, once you create the basics in PCL, you can integrate the class library in android as well as iOS.

How I can develop an Android application under VisualBasic.Net in VisualStudio?

I would like to develop an Android application using VB.Net language under VisualStudio, for this task I heard about Xamarin framework for VisualStudio, but it only seems to install Android projects for C# language.
My needs as the needs of many other programmers are very simple, just as I said I would like to start developing an Android application using VB.Net language under VisualStudio, I hope is there an existing Xamarin workaround or another alternative to accomplish this task, because it is a global demand/requisite.
What can I do?, I'm not planning a transition to C# or moving to another IDE than VisualStudio.
I think recently they added portable libraries for using VB.Net, you can have more information on the Xamarin Developer Guides (http://developer.xamarin.com/guides/cross-platform/application_fundamentals/pcl/portable_visual_basic_net/)

Android Xamarin:C# library development

I am very new to Android development,I like to develop a library using c# and use the library in Android device application. I got some idea to use Xamarin studio, the library generated was a dll. Am I going in a right path? Please guide me for library development.
Yes, you can create a Android library project and re-use it in multiple Xamarin Android projects.

Problems referencing Facebook SDK C# WP8 from C++ Windows Phone 8 app

I try to reference facebook.dll - wp8 branch - within an app of type "Windows Phone Direct3D App (Native only)" project under Visual C++ VS2012, and I get the error:
a reference to [dllname] cannot be added because the two projects
target different runtimes.
The restriction is that I cannot change the architecture of the application, so the main entry-point must be in the C++ project, and from here to call somehow the code written in C# for facebook.
Based on http://msdn.microsoft.com/en-us/library/windowsphone/develop/jj714080(v=vs.105).aspx , I tried also to reference the C# dll indirectly through a Visual C++ "Windows Phone Runtime Component" but again I get the same error. I tried to change some project settings and nothing worked. Trying to consume C# dll in C++, in all samples and demos which I found on the web, for wp8, the main entry-point is always in C#. Only some hints regarding windows store apps seem to indicate that could be possible to consume C# from C++, but I don't find any reference saying explicitly that my scenario on wp8 is possible or impossible.
How can I use facebook SDK from my WP8 app? Or what options I have?
Thanks in advance to anybody which shares the solution or any suggestion
C++ projects can't just invoke any C# DLL in WP8. You'll have to change how the class is built. Start a new C# XAML + C++ D3D project and have a look at IDrawingSurfaceManipulationHandler and Direct3DInterop. Basically you'll have to recreate and recompile the Facebook C# SDK to use it in WP8 C++.
However, installing and using the Facebook SDK on WP8 C# projects works OK on my machine. Have you considered usign a mixed C# and C++ project? It does have a small perf hit, but as long as you use DrawingSurfaceBackgroundGrid you should still have relatively good perf.

Categories