MissingMethodException on Unity Based Dependency Resolution in Xamarin Android - android

On running a Xamarin Android application in debug mode, I am getting the below error:
System.MissingMethodException: bool
System.Collections.Generic.Stack`1.TryPop(!0&)
And it is happening at the below call in the application for the Unity based dependency injection code:
this.Container.Resolve<T>();
There is no more stack trace data is also coming out for this issue.
Surprising thing is that the same project is working fine in VS 2017 (15.7.4) and not in a machine I have with VS 2017 (15.8.8).
Any possible solutions or leads for solving this will be helpful.
UPDATE:
I just downgraded my VS 2017 to 15.7.6 now and I am getting the same error still with that too.
WORK AROUND:
Once I changed targeted Android version of my Xamarin Android csproj in the Application Manifest to 5.1, I am able to get through my app in debug bypassing this issue. But, not sure what exactly solved by that. But, still it does not work in any targeted version above 5.1.
It will be great if a permanent solution can be identified for this issue even in higher Android target versions.

Related

Android Studio doesn't compile changes until second compile with Kotlin

When I am compiling with Kotlin's puglin, I always have to run the project twice if I make a change, Android Studio does not recognize the change until it runs the project twice, Insnat Run its off and this continues happening
If you use kotlin and retrolambda this might fix it:
me.tatarka:gradle-retrolambda:3.4.0
https://stackoverflow.com/a/41076056/7861527
If you're not using the latest Kotlin plug-in version (1.1.2-5 as of now) and/or Android Studio's latest stable version (2.3.3 as of now), then disabling Android Studio's Instant Run feature may not be able to fix this problem even though it's one of the most common solutions (based on blogs, SO posts here, and etc.) for properly running configuration changes to an app. Android Studio, particularly its alpha/beta versions (Alpha 4 as of now), are obviously bound to have buggy features, and the configuration-change bug could be one of them.

Xamarin.Android happens error on Android 7

I'm using Xamarin.Android to development application in my project. When I build app on all version bellow Android 7, no problem happens. But when running on Android 7. It happens error: Detected problem with app native libraries (please consult log for detail): libmonosgen-2.0.so: unauthorized access to "/system/lib/libsqlite.so".
How to fix it? Please help me!!!
Many thanks.
Changes have been made in regards to native linking which SQLite unfortunately is affected by as read here.
The the reason your application crashes is due to the fact, that Android Nougat now no longer allows to dynamically linking against non-NDK libraries; something which SQLite did previously. By updating SQLite, the issue should be resolved. Although, do note that other libraries that you use could be affected by this change as well.
You will also have to inspect every PInvoke that you do yourself.
If that's the case, then you also have to option of decreasing the targetSdkVersion in the manifest for your given Android project to 23. Doing so will simply write a warning to the console instead of throwing a runtime error.

Visual Studio "FileNotFoundException : Could not load assembly" issue, but without file name?

I am trying to work on a cross-platform mobile app using xamarin with visual studio 2015. However, after downloading what I think was all of android sdk/tool, I am getting the exception from the screenshot.
I read multiple if not most of "cannot load assembly" problems from Googling, but most of them have associated file url/name while I have got none of that.
Really desperate to know if anyone had come across this since this is my first time using visual studio & C#, and I am overwhelmed by the amount of new things I am learning.
Thanks
Aloe
API 24 is not fully supported in the current stable Xamarin release. It is only fully supported on a web Preview. See:
https://developer.xamarin.com/guides/android/platform_features/introduction-to-android-n/ .
So use API 23 instead and I would uninstall API 24.
Also do not use the android sdk build tools version 24 as that has been having issues as well. See:
https://releases.xamarin.com/technical-bulletin-android-sdk-build-tools-24/

NoClassDefFoundError exception when using ConcurrentLinkedHashMap 1.4 on Android 2.2

I'm using the latest version of ConcurrentLinkedHashMap as a cache system. It works very fine on android 4+. But when I run the app on my old HTC legend (Android 2.2) it stops with NoClassDefFoundError Exception. I didn't test it with 2.3 or 3.
As I searched the exception relates to a class that is present at compile time but absent during run time. But I don't know why it works fine on android 4 but not 2.2. Maybe it relates to android java coding style? any suggestion is appreciated.
EDIT ---------------------
I just used version 1.2 of ConcurrentLinkedHashMap instead of 1.4. It works fine. But why doesn't version 1.4 works?
EDIT 2 ------------------
The exception is thrown for an internal class of ConcurrentLinkedHashMap which is LinkedDeque. Not an external library. And By the way I compile the code against android 2.2 SDK not 4. So if if it requires any library of android 4 it must not be compiled.
Your LinkedDeque class depends on Deque which is only available on Android since API Level 9 (Android 2.3).
By the way, your class is really overkill and on Android you should use LruCache instead (included in the support library, works on Android 1.6 and above).
As I searched the exception relates to a class that is present at compile time but absent during run time. But I don't know why it works fine on android 4 but not 2.2.
You already answered that question yourself -> it does not work on 2.2 because there's no library that is needed. You need to check stacktrace from crash to see what lib exactly it is missing.

Are the library location on Android 4.2.1 moved?

I faced a suspicious problem when I tried to update my Android App to work on 4.2.1, Nexus 7. I'm using my own .so library, which inclusion was working fine on Android version 4.1, before I updated. Now I get all sorts of problems.
I compared the logs when deploying on an Android device running 3.2.1 and my Nexus 7 running 4.2.1. The library is being placed in two different locations, which might be causing my problems.
ANDROID 3.2.1:
Trying to load lib /data/data/com.my.app/lib/lib_my_app_jni.so 0x407e8218
Added shared lib /data/data/com.my.app/lib/lib_my_app_jni.so 0x407e8218
ANDROID 4.2.1 (Nexus 7):
Trying to load lib /data/app-lib/com.my.app-1/lib_my_app_api_jni.so 0x4257b6c8
Added shared lib /data/app-lib/com.my.app-1/lib_my_app_api_jni.so 0x4257b6c8
Why is it all of the sudden placed in the mysteries app-lib dir? How do I force it back? And where is this documented?
Thanks...
From Android 4.2, multi-user feature added in android frameworks.
And several directory locations are changed, but API is not changed such as Context.get???Dir() or Context.get???Path(). (just return value is changed)
Also android platform make symbolic link for legacy.
These changes are not documented.
I'm going to answer my own question, because we ended up implementing our library differently then originally intended.
The problem was that we were copying over access certificates and more, to the directory that the library was in. This approach worked fine on older Android versions, where that was located in the data/data/package/. But on newer Android versions (data/app-lib/package/) that location is read-only.
What we did was to move the location, simple. Thanks for the input.

Categories

Resources