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
Related
Recently received a new Android SDK (aar) to bind in Xamarin. When initially starting the binding I receive the error
COMPILETODALVIK : Uncaught translation error : com.android.dx.cf.code.SimException: invalid opcode ba (invokedynamic requires --min-sdk-version >= 26)
This error is due to the SDK containing Java 8 (v1.8) byte code and it needs to be compatible with Java 7 (v1.7) to support lower API versions of Android.
In your Android project (not the binding project), add the following property.
<AndroidEnableDesugar>True</AndroidEnableDesugar>
or if you are in VS 2019+ you can turn on D8 which enables this by default.
<AndroidDexTool>d8</AndroidDexTool>
Desugaring is the process of allowing Java 8 byte code to be converted into Java 7 compatible byte code. This is a Google process that performs the conversion and is part of the Xamarin.Android build process.
Then if the SDK doesn't have any dependencies, it should all work. If you have EmbeddedReferenceJars, then things get more complicated.
In Visual Studio 2017 you will experience errors similar to
Error: java.lang.TypeNotPresentException : Type io.reactivex.functions.Consumer not present
It will be unable to find these types in reference jars, because the desugaring processing isn't working properly. From Github Issues you eventually find the reason:
The first fix here is to add the `--classpath_entry` flag for every
`--input`, for some reason `Desugar` is not treating `--input` jars as
classpath entries
The bug is already tracked and fixed in Visual Studio 2019 Preview 2.
Now you switch to Visual Studio 2019 Preview 2 and you will come across this error.
Java.Lang.NoClassDefFoundError: Failed resolution of: Lcom/google/devtools/build/android/desugar/runtime/ThrowableExtension;
The desugaring processing is failing again because it needs this class to help communicate to the desugared code.
The class ThrowableExtension is actually found: https://github.com/bazelbuild/bazel/blob/master/src/tools/android/java/com/google/devtools/build/android/desugar/runtime/ThrowableExtension.java
You then take that Java class and you can compile it into a jar. A quick way to do it is copy that java file into a folder. Then inside that folder create a folder called output.
Call this command
javac -d ./output ThrowableExtension.java
Then move into the output directory and call this command
jar cvf desugar.jar *
It will create desugar.jar. Add that as an EmbeddedReferenceJar in your Android binding project. Your binding with Java 8 byte code with desugaring should now work.
Hopefully this might be resolved in a future Visual Studio version, so all these steps aren't necessary, but until then, at least you know what is happening and how to fix it.
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);
~~~
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
I try to build SQLite v3 from source using VS2010 and run into problems which I do not know how to tackle.
This is what I have:
VS2010 pro.
using sqlite-amalgamation-3160100.zip
Microsoft article: SQLite databases
This is what I did:
Created a C++ 'Win32 Console application'.
Disabled procompiled headers.
Added preprocessor definitions: (dont do this, this is the problem!)
_HAVE_SQLITE_CONFIG_H;SQLITE_OS_WINRT;SQLITE_API=__declspec(dllexport);
(as specified by 'SQLite databases' section 3.)
Created config.h (which is empty for the moment.)
Included the source files from sqlite-amalgamation-3160100.zip in the project.
build.
I get a number of compiler errors
1> sqlite3.c
1>e:\andre\ontwikkeling\sqlite\sqlite-amalgamation-3160100\sqlite3.c(38515): error C2065: 'MapViewOfFileFromApp' : undeclared identifier
1>e:\andre\ontwikkeling\sqlite\sqlite-amalgamation-3160100\sqlite3.c(38515): error C2099: initializer is not a constant
1>e:\andre\ontwikkeling\sqlite\sqlite-amalgamation-3160100\sqlite3.c(38524): error C2065: 'CreateFile2' : undeclared identifier
....
... which I try to solve.
The first one leads me to the following code snipped:
#if SQLITE_OS_WINRT && (!defined(SQLITE_OMIT_WAL) || SQLITE_MAX_MMAP_SIZE>0)
{ "MapViewOfFileFromApp", (SYSCALL)MapViewOfFileFromApp, 0 },
#else
{ "MapViewOfFileFromApp", (SYSCALL)0, 0 },
#endif
Now 'MapViewOfFileFromApp' leads to MapViewOfFileFromApp function, 'Maps a view of a file mapping into the address space of a calling Windows Store app.', a valid microsoft call for which my project setup is missing the correct configuration.
I could get a workaround for this one, but other errors are depending only on SQLITE_OS_WINRT and as such not possible to work around it.
It looks like that I'm missing some configuration options but I do not know which ones. I read all of the documented compile time options but can't find out what it is that I do wrong.
I tried to find a working exaple of a VS2010 solution but came up with nothing. And of cause I checked here for similar questions! (If there is one covering this then I missed it, sorry.)
Does anybody have a suggestion on what I'm missing? I'm running out of idea's.
* edit 6 jan 2017 *
On advice of MaxFurry I followed the steps of the blog by David Cravey which does exact the same steps as I did but without declaring SQLITE_OS_WINRT;SQLITE_API=__declspec(dllexport);. Leaving these two defines out solved the problem.
Aparently I misinterpreted the advice in the Microsoft article.
Compile time problems solved.
Kind regards.
Do you have your sqlite3.dll file already built? If so just create a folder in your visual studio folder. When u want to use sqlite3 just copy the dll file to the folder of the project in visual studio u want to use it also copy the following files there sqlit3.c, sqlite3.h. When this is done open the project in your visual studio IDE. Right click on the project name, add, add existing then click on the sqlite3.h and sqlite3.c. Let me know how it goes.
I am trying to add UI over my implementation of IdentityServer4, I am following the documentation quickstart guide https://identityserver4.readthedocs.io/en/release/quickstarts/3_interactive_login.html and I have copied folders from the release repo
https://github.com/IdentityServer/IdentityServer4.Quickstart.UI/tree/release
When I try to build this solution on visual studio I get the following error:
Severity Code Description Project File Line Suppression State
Error CS1061 'IResourceStore' does not contain a definition for 'FindEnabledResourcesByScopeAsync' and no extension method 'FindEnabledResourcesByScopeAsync' accepting a first argument of type 'IResourceStore' could be found (are you missing a using directive or an assembly reference?) TrialAuthentication..NETCoreApp,Version=v1.1 C:\Users\admin\trial-authentication\Controllers\ConsentController.cs 121 Active
The problem is that there's a new release candidate for IdentityServer4 - and the latest version of the UI for download reflects that. Meanwhile, the documentation still references rc4.
Just go to project.json and replace
"IdentityServer4": "1.0.0-rc4-update1"
with
"IdentityServer4": "1.0.0-rc5"
And your projects will compile just fine.