Implementing ARCore with Xamarin - xamarin

I'm starting to play around with ARCore with Xamarin, and am running into some issues. I see two sample projects:
https://github.com/dotMorten/ARCore.Xamarin
This is outdated, when I update all of the Xamarin packages to the latest, it results in a lot of build errors. It seems that there were a ton of breaking api changes since this was developed.
https://github.com/xamarin/XamarinComponents/tree/master/Android/ARCore
This is up to date (I think), but their sample "HelloAR" solution doesn't build. It references a JavaGL project, which is supposed to have an obj.jar file but it doesn't exist on github.
/Users/justintoth/Downloads/XamarinComponents-master/Android/ARCore/samples/JavaGL/CSC:
Error CS1566: Error reading resource 'obj.jar' -- 'Could not find a
part of the path
"/Users/justintoth/Downloads/XamarinComponents-master/Android/ARCore/externals/obj.jar".'
(CS1566) (JavaGL)
I'm wondering how others are getting started with ARCore with Xamarin? Were you able to get past the build errors above, or are you using a different Xamarin project?

Obj.jar is in "external" jar via http://oss.sonatype.org/content/repositories/releases/de/javagl/obj
You can look at the cake build file to see how it is downloaded/used as it is contained in the component, same for the arcore.aar.
XamarinComponents/Android/ARCore/build.cake
~~~
var AAR_VERSION = "1.0.0";
var AAR_URL = string.Format("https://dl.google.com/dl/android/maven2/com/google/ar/core/{0}/core-{0}.aar", AAR_VERSION);
var OBJ_VERSION = "0.2.1";
var OBJ_URL = string.Format("https://oss.sonatype.org/content/repositories/releases/de/javagl/obj/{0}/obj-{0}.jar", OBJ_VERSION);
~~~

Related

Xamarin Android binding duplicate packages causing "Program type already present" build error

I am trying to build Xamarin Android binding libraries for two different RFID hand held scanner SDKs (from two different companies), and then reference them in a Xamarin.Android project. So the end goal is to have one application that can run on Device A or Device B and depending on the device manufacturer it will use a different implementation of a "scanner" interface. If I try to reference both of the resulting dlls from the Xamarin.Android project, then I get the following error:
Program type already present: com.hsm.barcode.DecodeOptions
Looking in the jars using JD-GUI as suggested in the Microsoft Docs I can see the problem is that both of the jars have a com.hsm.barcode package:
What is the best way to workaround this issue?
Note that if I use only one of the dlls then I have no issues.
What I have tried:
Using a single Xamarin Android binding library project for both jars - this gave exactly the same result
Renaming all of the classes in the jar to eliminate duplicate class names like this: <attr path="/api/package[#name='com.hsm.barcode']/class[#name='DecodeOptions']" name="name">DecodeOptions2</attr>. When I do this, in reflector I can see that the class name has indeed changed, but I still get the build error when building the Xamarin.Android project
Renaming the namespace in one of the projects: <attr path="/api/package[#name='com.hsm.barcode']" name="name">com.hsm.barcode2</attr>. Again, I can see the updated namespace in reflector but still I get the same "Program type already present" error when building the Xamarin.Android project
Similarly I have tried removing both the namespace and the duplicate classes using remove-node but seen similar results
This leads me to believe that this isn't necessarily an issue with the binding process but rather a more Android related problem. I have found some similar Android questions where people mention that you can use exclude module in gradle to remove dependencies [1] [2], but a) there seems to be no concrete answer that this is the right approach in this case and b) as I have been able to find gradle is not a tool that is used as part of the Xamarin/Visual Studio process.
My final desperate attempt to get something working was to unzip one of the jar files, remove all the .class files that are causing issues, then rezip and use this in the Android binding library and then reference this dll in my Xamarin.Android project. This seems to work (the project builds and runs) but I'm not sure it is the correct/safest/most stable solution.
To summarize, the question is: if you have two jars with duplicated namespaces/packages and you want to use both of these Jars in a Xamarin.Android project how can you avoid the resulting Program type already present: com.hsm.barcode.DecodeOptions error message.

Resource Designer is generated with Syntax error in Xamarin Android

I am currently updating our company Mobile application which was created a year back. Recently when I update my project to MonoAndroid 9.0 and build the solution I was bombarded with many errors (attached). I tried to fix it by updating the nuget packages but after I update, Resource.Designer file has generated files with syntax errors like public const int bottomtab.navarea = 2130969385; where in Xamarin can't understand the "." in the above. I am also facing issues like
1. resource style/Widget.MaterialComponents.TextInputLayout.OutlinedBox (aka sg.totalebizsolutions.rocktree:style/Widget.MaterialComponents.TextInputLayout.OutlinedBox) not found. CSMobile.Droid
2. resource style/Theme.MaterialComponents.Light.DarkActionBar (aka sg.totalebizsolutions.rocktree:style/Theme.MaterialComponents.Light.DarkActionBar) not found. CSMobile.Droid
3. failed linking references. CSMobile.Droid
4. expected reference but got (raw string) #000000. CSMobile.Droid
I am not sure what am I missing here. Please find my csproj file attached
CSProjFile

trying to work with EDSDK from Canon using Xcode

just tried to install the EDSDK framework into the Xcode project framework folder. However I cannot run anything, as I am getting a lot of error messages. for example at this position in the EDSDK.h file:
EdsUInt32 EDSAPI EdsRetain( EdsBaseRef inRef );
I get the error message:
A parameter list without types is only allowed in a function definition
I get these all over the place. I really would like to make an MacOS app that takes an image and saves an image with a certain name.
The EDSDK should include two sample XCode projects written in Objective-C, namely:
CameraControl -- controlling the camera
RawDevelop -- processing (raw) images downloaded from the camera
If you'd like to skip the Objective-C part, you could bridge this into Swift yourself. Alternatively, have a look at the most recent PowerShot G7X SDK where Swift is used to make a similar example project.

Unable to convert classes into dex format Unity

Using the google play games services and Admob plugin I cannot seem to get my back to build into an APK and I am receiving the following error message. Any help would be appreciated as I have removed some duplicate files but I am still failing to find why I cannot build my app.
I am using Unity Unity 5.6.1f1 (64-bit).
game services: https://github.com/playgameservices/play-games-plugin-for-unity Ads: https://github.com/unity-plugins/Firebase-Admob-Unity
CommandInvokationFailure: Unable to convert classes into dex format.
C:/Program Files/Java/jdk1.8.0_121\bin\java.exe -Xmx2048M -Dcom.android.sdkmanager.toolsdir="C:/Users/Jack/AppData/Local/Android/sdk\tools" -Dfile.encoding=UTF8 -jar "C:\Program Files\Unity\Editor\Data\PlaybackEngines\AndroidPlayer/Tools\sdktools.jar" -
stderr[
Uncaught translation error: java.lang.IllegalArgumentException: already added: Lcom/google/android/gms/internal/zzbyb;
Uncaught translation error: java.lang.IllegalArgumentException: already added: Lcom/google/android/gms/internal/zzbyc;
2 errors; aborting
]
Some Background
When Unity builds your project for Android, it invokes several tools from the Android SDK. As part of that process, it converts all of your native (Java) code for Android into a file format called DEX (Dalvik executable).
All of your Android plugins get built up into a single package using that tool. The problems start when a few plugins have the same compiled Java code (classes) in them. This will cause the DEX tool to fail with an error like the one you're seeing:
Uncaught translation error: java.lang.IllegalArgumentException:
already added: Lcom/google/android/gms/internal/zzbyb;
Uncaught translation error: java.lang.IllegalArgumentException: already added: Lcom/google/android/gms/internal/zzbyc;
This means that classes with those names were already included in another library, and so they cannot be added again.
Possible Causes
As explained above, this error occurs when you have duplicate plugins in your project; this can happen in different scenarios, here are some examples:
The same plugin is included more than once, under different folders of the project.
The same plugin is included more than once with different versions.
A plugin contains other dependencies "embedded" inside it, but these dependencies are already included in the project in some form.
How To Fix
You should look up duplicate Android plugins in your project and eliminate them (keep only 1 copy). From the error message you posted, the issue here is related to Google play services libraries. You should look into that (libraries named play-services-xxxx.aar).
Paid Help (Shameless Plug)
I provide a professional service for fixing this exact kind of issue. In case you (or anyone else) are not able to resolve such an issue themselves, feel free to contact me and get it solved.
I was facing the same problem after add admob in my project, here are 2 possible solutions:
Go to the file >> build settings and change the option internal to gradle
Open libs folders separately of both Facebook SDK and Google Play services and delete the matching files
It would be something like (support v4)
Google ads 11.2 has errors. It reuses certain jar classes .
On its own, it isnot an issue
Once you add in another google class, ie firebase, your done for.
There is a fix though. Google put out firebase 4.2 and ads 11.4

Can not build Xamarin's ModernHttp version

I noticed ModernHttp is not being updated long time,
After search some, I noticed there is Xamarin updated version.
here.
https://github.com/xamarin/ModernHttpClient
I want to try this.
But I couldn't find it on nuGet Gallery nor build library to my own.
It gives error "obsolete api" when I try build android library.
Can't understand because I set API level as library use.
Android/OkHttpNetworkHandler.cs(273,48): error CS0619:
System.Net.ServicePointManager.ClientCipherSuitesCallback' is
obsolete:This API is no longer supported.'
Task "Csc" execution -- FAILED
Done building target "CoreCompile" in project "/Users/bright/Devlibs/project/untitled folder/ModernHttpClient2 copy
3/src/ModernHttpClient/ModernHttpClient.Android.csproj".-- FAILED
Done building project "/Users/bright/Devlibs/project/untitled folder/ModernHttpClient2 copy
3/src/ModernHttpClient/ModernHttpClient.Android.csproj".-- FAILED
Build FAILED. Errors:
Any tip please?
Try using this link :
https://components.xamarin.com/view/modernhttpclient
Visual studies and Xamarin studios should have an easy way to add in components.
This link can help with learning about there usage :
https://developer.xamarin.com/guides/cross-platform/xamarin-studio/components_walkthrough/

Resources