I have an app which target is from 3.0 to 4.3. API. When I test my app to 2.2 from PC, eclipse runs another emulator which target is greater. When I change my app's preporties to 2.2 then I get many eroors so I can not test my app from 2.2 emulator. When I test my app from 2.2 device everything is just okei. I am litle bit confused about what is going on with my app.
When I change target to 2.2 I get errors in this line. In (HONEYCOMB and addAll):
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
adapter.addAll(reminders);
Then I get error in this(isEmpty):
if (editTextDescription.getText().toString().isEmpty())
And then when I extend this PreferenceFragment : I think I can add Sherlock to get this right am i correct about PreferenceFragment.?
But I do not get why I have so many errors in pc and in device my app work great..!?
Build.VERSION_CODES.HONEYCOMB is not defined in 2.2 so you would get an error.
But I do not get why I have so many errors in pc and in device my app
work great..!?
I don't think your app works in 2.2 if it gives error when you change to target 2.2. Is the device running 2.2? What does the Android version in the device says?
Build.VERSION_CODES.HONEYCOMB
This constant means Android 3.0 and as such it does not exist in 2.2 (there was no Android 3.0 when 2.2 was released).
adapter.addAll
I don't know what type is adapter but if it shows an error this means this call is not available in 2.2. If this is a List, then you're compiling with Java 5 API. Switch to Java 6.
if (editTextDescription.getText().toString().isEmpty())
If String#isEmpty() shows error, then you're compiling with Java 5 API. Switch to Java 6.
Related
I am an android beginner, I have developed one app, it was working kitkat version, but it's not supported in lollipop version (nexus 5). When I run the app in nexus 5 the app get force stop. This problem arrives development side or lollipop side Any one can help me
For your reference I have used android version as below
Min sdk is 14
Taget Sdk is 21
It may be because of some libraries you have used.I got the same issue when I was having simonvtmenudrawer in my app which was not supported in lolipop.I replaced the same and it is now working fine.
I have an android library project where I use android 2.3 private API. I have the main android 4.2 project that uses this library project. I need to run this project on android 4.2 device. (android 4.2 doesn't have this api available in android 2.3)
And every time I get the runtime exception:
AndroidRuntime(1395): java.lang.NoSuchMethodError: android.content.pm.IPackageManager.getPackageInfo
It's clear why I get it;
but does it possible to resolve this problem?
Since getPackageInfo is API that added in level 1, it sounds weird.
See link : http://developer.android.com/reference/android/content/pm/PackageManager.html#getPackageInfo(java.lang.String, int)
Does Context (Activity, ApplicationContext, etc) was properly set?
because getPackageInfo() usually used like below,
context.getPackageManager().getPackageInfo
So if context or packageManager is wrong, getPackageInfo cannot be called.
Just Refresh - Clean and do it again. Sometimes it works.
Definitely, There exists getPackageInfo() in Android 4.2. (Actually, 2.2 ~ 4.3) It seems that android works fine.
While creating a project using eclipse i have Minimum SDK required as Android 2.2(Froyo) and Target SDK as Android 4.2(Jelly Bean) compile with Android 4.3. I have used sqlitebrowser v2.ob1 for creating database. My app runs without any errors (few lines in red in logcat though) and meets my requirements when i run it in an emulator. I tried 3 different emulators and it works fine. But when i tried this app in a mobile device it shows force close whenever there is something to do with database. I mean to say that it shows force close when it has to retrieve from database or connect to database. By searching i learned that just the .apk file is enough for the app to run even if externally created database is used in it (copying to assets folder and then to the default location). My questions are
Shouldn't my app work fine in any device ranging from Android 2.2 to 4.2 ?
Should i try compiling the app with Android 4.2 instead?
Am not sure about the version of the device i tried it in but am sure its within 2.2 and 4.2 . (Probably gingerbread). Other than plugging the device to PC via USB and seeing logcat (bcoz i dont own an android mobile phone) what can i do to solve this?
How is the app's version, emulator and version of mobile or any other device related?
My app can run on what versions of devices?
This is my first android app so any help is appreciated. Thanks in advace
It's possible that you are using a feature in your application that isn't supported by a lower version of the SDK. It's difficult to tell you exactly what that might be without any source code or stacktrace, but I can clear up your understanding of minSdkVersion and targetSdkVersion.
Consider that with each new version of the Android SDK, additional features and APIs are introduced that did not exist in previous versions. Obviously, the older versions of Android don't support those features.
When you specify a targetSdkVersion you are specifying that you are using features that were introduced in that particular version of Android. You are also implying that you have tested your application at that particular API level, and that it works as it should.
When you specify a minSdkVersion that is lower than your targetSdkVersion, you are implying that your application will work properly on a lower API level because you have manually programmed tests or checks in your code to ensure that the current API level is compatible with a feature before running it.
For example, if I wanted to run a feature introduced in Jelly Bean but I want to retain support for a lower API level (e.g. Gingerbread), I might add the following check before I run the feature (see other version codes here):
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
// run some code specific to API level 16
}
The Android SDK can automatically deal with code introduced in a lower API level, but it can't automatically deal with code specific to a higher API level.
So with that in mind, to answer your questions:
No, it's only guaranteed that your application will work properly on Android 4.2. It's up to you to ensure that it remains backwards compatible for earlier versions that you wish to support.
It shouldn't matter. Instead, you should first determine if your application runs on a device/emulator that is running the same API level as you are targeting (Android 4.2, API level 17), then run it on a device/emulator running a lower version and try to isolate the code that is causing it to crash (logcat will be helpful).
You can check the Android version of a device by going into Settings > About phone > Android version. If it is running Gingerbread, keep in mind that a lot of new features have been introduced since then and your application might be using some of those features. For the emulator, you can specify an API level when you create an emulator (you can download other versions to use from the SDK Manager).
I think my answer so far has made this relationship clear.
To reiterate, your application WILL run on any device running Android 2.2 or later, but it can crash if you are using features from a higher API level than the device is running.
If this is still not clear, you should read more about supporting multiple platform versions in the Android documentation: here.
I'm trying to use Sensor.TYPE_LINEAR_ACCELERATION. Accrording to documentation, starting since level 9 (gingerbread) this API should be callable. However, eclipse is giving me syntax error, and thinks Sensor does not have access to TYPE_LINEAR_ACCELERATION. I have no problem calling Sensor.TYPE_ACCELEROMETER tho. My running configuration on eclipse shows that my target is android 2.3.3 or API level 10. Is there any other place that I need to check to whether the packages are imported from 2.3 and not older versions?
Thanks
Fixed it. Even though I was running the emulator with 2.3, I was building with 2.1. So I changed it so it now builds with 2.3.
I installed android sdk 3.1 and 2.3.3 And i created emulator using both of them.
But when i run 3.1(api level 12) emulator it doesn't work some features(applications) like contact,settings but in 2.3.3(api level 1) it works well.
I don't know why.So i re-installed them few times and the result was same.After i asked this about others and they had the same experience.can anyone explain why this happened?
Dear the aplication u have been running in api 12 is not compatible with it... it must run on lower api. Application execution differs in api levels.
u must try to run ur application in api 1 if u have developed application in android 2.3.3.