I am creating an android application using Xamarin on Visual Studio 2017. I am trying to use the NuGet package GoogleMaps.LocationServices using this guide (http://www.c-sharpcorner.com/blogs/find-latitude-and-longitude-using-c-sharp1). I have installed the package fine
But when I try to use the package on my code like the guide I following does I just get an error saying it can't find the namespace:
This means that I cannot create a GoogleLocationService() object which is what I need to do to create a Google Maps pin point using a list of location addresses.
Anyone got any idea why I'd be getting this error? Unsure if I just need to use a different namespace now as this guide was from 2013.
The GoogleMaps.LocationServices 1.2.1 NuGet package contains an assembly for .NET 4.0 and no other target frameworks. So it does not support Android projects. NuGet will not add a reference to the GoogleMaps.Gelocation assembly since it is in the lib/net40 directory so it not considered compatible.
Instead I would take a look at the Xamarin.GooglePlayServices.Location NuGet package.
Looking at the content of the NuGet package it has a content file GoogleMaps.LocationServices.readme.txt which seems to be why you can install it into a Android project. This GoogleMaps.LocationServices.readme.txt file is added to your project.
Ideally the NuGet package should have a readme.txt file in the root of the NuGet package and not add a file to the project. Such a readme.txt file would be automatically opened on installation by Visual Studio without the need to add anything to the project. Removing the content file would also prevent the NuGet package from being installed into an Android project, or any other unsupported project type.
The older GoogleMaps.LocationsServices 0.9.0 can be installed into an Android project but that seems to be because the NuGet package is not packaged correctly. The GoogleMaps.Gelocation assembly in this version of the NuGet package is in the lib directory and does not indicate any target framework so it is allowed in all project types, which does not seem to be correct.
It's hard to trace what a new signature of the methods are in 2017, but from my brief look if you change the version on a package to
0.9.0 and use namespace
using GoogleMaps.Geolocation;
The example should work.
Related
In this documentation https://developer.chrome.com/docs/android/custom-tabs/integration-guide/ it says you have to add the AndroidX Browser Library in your project.
Open the app/build.gradle file and add the browser library to the dependencies section"
But I think that's some Android Studio thing.Then I tried to find maybe a NuGet Package but the only thing that showed was some Chrome Custom Tabs version 1.0.0 that couldn't even install:
Severity Code Description Project File Line Suppression State
Error NU1202 Package Xamarin.Android.ChromeCustomTabs 1.0.0 is not
compatible with netstandard2.0 (.NETStandard,Version=v2.0). Package
Xamarin.Android.ChromeCustomTabs 1.0.0 supports: monoandroid50
(MonoAndroid,Version=v5.0)
Is there any way I can use Chrome's Custom Tabs in my Xamarin Project?
Open the app/build.gradle file and add the browser library to the
dependencies section"
For this problem,you can try to install nuget Xamarin.AndroidX.Browser which is developed by Microsoft. Meanwhile, you also need to install nuget Xamarin.AndroidX.Core .
For more details , you can check: https://github.com/xamarin/AndroidX.
Is there any way I can use Chrome's Custom Tabs in my Xamarin Project?
For this , you can try to install nuget Xamarin.Android.Support.CustomTabs.
I am trying to create a Xamarin project using PayTM android library. Since PayTM doesn't have a direct Xamarin binding I have added the appinvokesdk-1.2.aar in the Xamarin Android Biding library project. The build action for appinvoke is "LibraryProjectZip". Now the appinvoke library also have a runtime dependency on easypay-8.7.3-appinvoke.aar (I found this after checking the pom file for appinvoke.aar file). I have set the build action for the easypay aar file as "EmbdedJar". I have also tried setting it to "LibraryProjectZip","ReferenceJar" and "EmbeddedReferenceJar". During runtime I am getting the error as
Java.Lang.ClassNotFoundException: Didn't find class "easypay.listeners.WebClientListener" on path: DexPathList[[zip file "/data/app/com.edmatix.poc.paytmdemo1-WQf3uMctjbNHoAG_ZfsH3A==/base.apk"],nativeLibraryDirectories=[/data/app/com.edmatix.poc.paytmdemo1-WQ…}
Here is my environment details
Visual Studio for Mac 8.5.4 (Build 12)
AndroidX assemblies
Xamarin.Form 4.6.0.726
Android Minimum API version 22
Android Target API 28 (Android 9)
the class easypay.listeners.WebClientListener is only required during run time and not during compile time.
Can you please help about how to properly embed the dependency library?
Thanks
so this is what I did to solve the issue of missing .aar file during runtime. I added the second .aar file (easypay-8.7.3-appinvoke.aar) into another Xamarin binding project (as shown in here) and set the compile type as LibraryProjectZip. And that solved my issue with not finding the class in runtime.
Thanks
Please try to install Xamarin.Kotlin.StdLib in your Xamarin Android project. Installing the Kotlin package worked for me because I was using the .aar file which contains Kotlin code.
Install-Package Xamarin.Kotlin.StdLib -Version 1.3.50.1
I need to generate the javadoc for a Library in Android Studio.
The problem is that, when I start to create the doc, I see the following logs:
Constructing Javadoc information...
Standard Doclet version 1.8.0_31
Building tree for all the packages and classes...
[...]
1 error
javadoc: error - com.sun.tools.doclets.internal.toolkit.util.DocletAbortException: com.sun.tools.javac.code.Symbol$CompletionFailure: class file for java.lang.FunctionalInterface not found
I don't know exactly what is the problem. I think it is the doclet version (it takes by default 1.8.0_31); I tried to modify it but I did not succeed... any help?
I am using Mac OSX and Android Studio 1.2.2
So I'm trying to install this package into my solution and I'm having a weird error I can't seem to fix or find a solution for.
Install failed. Rolling back...
Install-Package : Could not install package 'Xamarin.Android.Support.v7.AppCompat 21.0.3.0'.
You are trying to install this package into a project that targets 'MonoAndroid,Version=v2.2', but the pack
age does not contain any assembly references or content files that are compatible with that framework. For more information, contact the package author.
At line:1 char:16
+ Install-Package <<<< Xamarin.GooglePlayServices
+ CategoryInfo : NotSpecified: (:) [Install-Package], InvalidOperationException
+ FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PowerShell.Commands.InstallPackageCommand
I've tried changing my target MonoAndroid version to either the latest or the earliest and it didn't seem to change anything, so I've put it back to where it was originally.
This is the error I'm getting. The problem is I either need to get this to work (because Xamarin didn't update their website so I can't download it from there and just take their .dll) OR do the bindings for Google Play Services myself which would probably be a pain in the ass.
Unless there is another way?
Thanks in advance!
The following settings work for me:
Looking at the Xamarin.Android.Support.v7.AppCompat 21.0.3.0 NuGet package it only contains an assembly for MonoAndroid 4.0.3 so your project will need to target that version or above before you can install it.
It looks like you are using Visual Studio so you can either go into the project options and change the targeted Android version in the project properties and change the Compile using Android version or edit the project file (.csproj) and change the TargetFrameworkVersion directly in the file.
<TargetFrameworkVersion>v4.3</TargetFrameworkVersion>
If you need to target Android 2.2 then you could use the Xamarin.GooglePlayServicesFroyo NuGet package since that can be installed into a project that targets MonoAndroid 2.2
Following this answer, all you have to do is change this:
to this:
I'm trying to implement this https://github.com/mik3y/usb-serial-for-android/blob/master/UsbSerialExamples/src/com/hoho/android/usbserial/examples/SerialConsoleActivity.java in my project but there is something wrong with this sample.
Line 121:
sDriver.setParameters(115200, 8, UsbSerialDriver.STOPBITS_1, UsbSerialDriver.PARITY_NONE);
Why I can't see this method setParameters()?
I had the same problem when I tried to use the example project. The problem I had was that I was using usb-serial-for-android-v010.jar that you can download from the git repository. I think it was created using an older version of the project and doesn't support some of the newer features like setParameters. If you downloaded the example project there should be a folder inside called UsbSerialLibrary. Import that into your IDE and add it to your build path: (Eclipse) Properties>Java Build Path>Projects>Add. This should let you use setParameters.
Also, the API was recently refactored so you may want to look at that.