How do I use functionality available in an embedded jar file? - jar

I'm trying to use GmailSender in my Xamarin Android app. My main project is referencing the binding library, and the binding library has 2 jars - GmailSender 1.1.jar, and mail.jar.
the GmailSender 1.1.jar file is set as an EmbeddedJar in properties, and mail.jar is set as an EmbeddedReferenceJar in properties.
The following image depicts how my project is set up (higher res image: http://i.imgur.com/Xbq5uKa.png)
This is where I got GmailSender 1.1.jar: http://gmailsender.blogspot.ie/
This is where I got mail.jar (renamed from mail-6.0.0.jar) http://www.java2s.com/Code/Jar/m/Downloadmail600jar.htm
How can I get my Xamarin Android app to use GmailSender?

There is a note regarding that issue on Xamarin docs:
Note: Due to bug 6695, when referencing the Java Binding project
directly from a Xamarin.Android project, none of the namespaces,
classes, or other members of the Java Binding project will be visible
in the IDE when working on the Xamarin.Android project. This bug will
be fixed in a future version of Xamarin.Android.
You won't be able to see the bindings unless you reference the generated dll (this is a workaround)

You need to reference the library using the namespace of your binding library. By default, it is probably using "BindingLibrary1" as the root namespace, so try adding a using directive for that namespace.

Related

The type or namespace name 'UWP' does not exist in the namespace 'PdfSharp.Xamarin.Forms'

I am working on a Xamarin.Forms app with PDF features. I am taking my first shot at using PdfSharp (PdfSharp.Xamarin.Forms forked from PdfSharpCore) but finding it's not entirely developer-friendly. I'm trying to use PDFManager and PDFManager.GeneratePDFFromView and was able to do so successfully in my Android project, but it's not working in UWP. The Git page says to init in the UWP App.xaml.cs like this:
PdfSharp.Xamarin.Forms.UWP.Platform.Init();
But when I try this I get the error "The type or namespace name 'UWP' does not exist in the namespace 'PdfSharp.Xamarin.Forms'". Again, I had no problems initializing in Android, but .UWP is not recognized for UWP. I would open this as an issue on GitHub but the option doesn't seem to be there for this repository.
You need to either find PdfSharp.Xamarin.Forms.UWP.dll from the source website directly or download the sample code from that website and build it. Either way this .dll is the file you are looking for. Once you have a copy of this file, use Project>Reference 'Add Reference' to add this .dll to your UWP project. You should find that PdfSharp.Xamarin.Forms.UWP.Platform.Init() is now accepted.
..But of course there is NO guarantee that PdfSharp.Xamarin.Forms will WORK even if you DO successfully add the library ...

When referencing a .Net Standard project within a Xamarin solution, does all the code from the project get compiled into the app

Apologies if this sounds like a silly question. I'm not very experienced with how things are linked/bundled/assembled under the hood.
Before I begin, I'd like to say that I've tried reading documentation (such as https://learn.microsoft.com/en-us/xamarin/cross-platform/app-fundamentals/code-sharing) to find the answer, but was unable to.
If I have a Xamarin.Forms solution and I reference a .Net Standard project:
Question 1: Does all the code from this project get compiled and included into the app such that it may be disassembled later, or is it only code from classes that I actually make use of that gets included?
Bit more elaboration:
For example, I may have a School class that expects an IStudent (inject via DI), and a Student class that implements IStudent. Both of these exist in the .Net Standard project that I reference in the Xamarin.Forms project. However, if I only actually make use of the Student class (by registering it with type IStudent in my IoC container), will the code from School get included in the built app as well?
Question 2: If all the code from the project does get included, is there a way to forcefully specify which classes to include/exclude by way of some configuration setting, attributes, 3rd-party library, or something else?
As far as i know everything in the NETStandard project get compiled and shipped with the app.
If you want to remove unused code from compiled assemblies you have to use the linker.
To link everything, you have to select "Sdk and User Assemblies".
The linker tries to dont strip away mthods and fields you are using, but often is too aggressive (for example, methods referenced only by reflection will be stripped).
Luckily there are few methods where you can fine-tune the linker behaviour and make it work. Some link to elaborate on:
Linker in iOS and Android
https://learn.microsoft.com/en-us/xamarin/ios/deploy-test/linker
https://learn.microsoft.com/en-us/xamarin/android/deploy-test/linker
Official doc about the linker config:
https://learn.microsoft.com/en-us/xamarin/cross-platform/deploy-test/linker
Useful blogposts:
https://xamarinhelp.com/xamarin-linker/
https://medium.com/#harrycblum/reduce-your-xamarin-app-size-with-linking-26247edc87f6

Getting image from Class Library

I am doing a refactor of my Xamarin project, in which I want to build nuget-packages for my platform specific projects.
And since you can't make your "App.Droid", "App.iOS" and "App.UWP" into nugets I am using class libraries for this.
My problem is when I put my images (ordinary *.png-files) in my UWP-class library it won't work. It is working in both iOS and Android.
So my question is if anyone knows if this is possible, and if so how?
My current setup is as follows:
My UWP-project is named "App.UWP". This is the project i build and the project has the "App.xaml" and "MainPage.xaml".
I then created a "Class library (Universal Windows)" named "Company.Mobile.Core.UWP".
My "App.UWP" is referencing "Company.Mobile.Core.UWP".
I know I have a working connection between the two. My Custom renderers are in the "Company.Mobile.Core.UWP"-project and not in "App.UWP" and is working fine.
Cheers,
Tobias

Reference problems when using custom controls within Exrin

Using the base Exrin template, I am unable to use custom controls.
As it stands now, the Droid/iOS projects reference the App/Bootstrapper project, so that seems like the correct place to put them, but when creating a new page or BaseView, I am not able to access the custom control's namespace because the View project does not reference the App/Bootstrapper project.
The Tesla sample app does not have this problem in its current implementation since there is no separation of the App/Bootstrapper and the View projects.
(1) Should a reference to the App/Bootstrapper be placed in the View project or (2) should a reference to the View project be placed in the Android/iOS/etc projects? Or is there a better solution than either of these two?
Edit:
(1) does not work because a reference to the App project from the View would create a circular dependency.
(2) should work (I think), but I'm having trouble getting the Application.Droid project to access the Application.View project namespace because when I add using Application.View;, the namespace isn't found in the Application namespace. Visual Studio attempts to fill in other Application namespaces (.Container, .Logic, .Droid, .Proxy) when I type in using Application.
The native project can have a reference to the View. It already does in a way, because it references the App library, which then references the View. Hence you aren't really adding any further dependencies by doing this, just allowing access further up the chain.
If you are having trouble the namespace, I suggest you start out with
global::Application.
That way it starts from the top, if its getting mixed up with project namespaces.

Flex Sub-Apps and MarhsallingSupport missing in 3.x SDK's

I'm looking at using Sub-Applications within flex, to enable mutli-versioned compilation.
Specifically, I'm looking to have a Flex 4.x host app that loads Flex 3.6 sub-apps.
The docs state this is possible (and the purpose of sub-apps). However they specify this:
When compiling each of these types of applications, you should include
the MarshallingSupport class into the main application and
sub-applications. You do this with the includes compiler argument, as
the following example shows:
-includes=mx.managers.systemClasses.MarshallingSupport
However, from what I can tell, MarhsallingSupport wasn't included until the 4.x releases.
Looking at the mx.managers.systemClasses package for 3.5.0.12683 and 3.4.1.10084 shows no reference of MarshallingSupport (see svn here and here)
This is also true for 3.6a (download of SDK available, but can't find the source).
Am I missing something? How am I supposed to include this class in the 3.x sub-apps, when it's not available?
see http://help.adobe.com/en_US/enterpriseplatform/10.0/AEPDeveloperGuide/WS8cbf8723eeed7311-4cca458e1328d74a115-7fff.html
Like module bundles, there are no special compilation requirements. You can build the
application bundle SWF in any way that is convenient. Note, however,
that application bundles must include marshalling support.
This is automatic with Flex 3, but with Flex 4 you must force the inclusion
of the MarshallingSupport class in your SWF.
For Flex 4 this can be
done by referencing the MarshallingSupport class in your application
code (as in the previous example). You can also explicitly force
inclusion of the MarshallingSupport class on the mxmlc command line
using the following option:
-includes+=mx.managers.systemClasses.MarshallingSupport

Resources