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.
Related
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.
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.
I have android project which is written in android 2.3 but when I import in android 2.2 ,Iam receiving an error .could someone possibly tell me ,how to overcome this problem?
Go to project properties then select Android and select 2.2.May solve your problem
DIfferent API versions have changes in their libraries and so something created for 2.2 can be compatible with newer API versions but something made in 2.3 may not be backwards compatible with the previous version. Thus you may need to check what pieces of your code have to be modified if you want to port it to a previous API version.
I know that android version 2.1 and below do not support GLES20. My code can run with both the fixed function pipeline (GLES1.x) and the programmable pipeline (GLES20) based on runtime determination of the version used by a android device and setting the GLES version accordingly.
My situation is that I would ideally like to keep my GLES20 code in my project and just not use the classes that use GLES20 at runtime when an android device of version <= 2.1 is detected. But when I set my project to 2.1 in Eclipse, GLES20 creates a compilation error. I assume that this is so because the Android2.1.jar does not contain GLES20 .
Is their a way I can keep my GLES20 code without getting compile errors when setting the android version lower and to just not use the GLES20 code at runtime, so that the running code will never use the GLES20 portions anyway.
Thanks
Okay, I figured out how. The element minSdkVersion and targetSdkVersion in the manifest allows this. I quote from the "Beginning Android Games" book. "This element allows us to deploy an application that uses APIs that are only available in newer versions to devices that have a lower version installed". So I will use this element accordingly, and develope in eclipse with my target android version set. I'll answer my question with this asap
The relevant documentation on Android developers, as linked by Mārtiņš Možeiko's comment.
developer.android.com/guide/appendix/market-filters.html
I have seen the BusinessCard example provide in Android examples.
I am using ContactAccessor abstract class to seperate out the SDK versions.
My code is running fine for 2.0 onwards, but when I am trying to build the code in Adnroid 1.6 I am getting the following errors:
Build.VERSION_CODES.ECLAIR is not resolved.
Getting errors in the whole class in which I have used Contacts APIs from 2.0 (say in class ContactAccessorSdk5.java).
How to resolve these issues?
I want to run my App on both the versions.
Please help me.
Regards,
Dhaiwat Bhavsar.
In your Eclipse environment, open Project Properties of your project, in Android section, select Android 2.0 as Project Build Target, then click Apply/OK. If you want to test on Android 1.6, just run the app on Android 1.6 emulator/device (always build with Android 2.0)
I'm sure this has been asked on the site before, but it boils down to a few points:
Compile against the later version of the SDK (2.0.1 or later)
Read the Backward Compatibility article on the Android Developers' site
Implement your calls to the contacts APIs by means of a wrapper class