Run android app on older API AVD - android

I want to support newer themes using values-11, values-14, etc. For the application to compile, I have to increase the target API, but that removes the lower API AVDs from the selection list in the run configuration. How do you get eclipse to run it on an older version to see if it works? I'm sure I can load it manually but it seems Eclipse should allow this.

I think Eclipse will try to launch an AVD that satisfies your targetApiLevel, but if any AVD is running at or above your minSdkLevel, then it will use that instead. But you need to make sure the AVD is properly registered with Eclipse. In my experience, this usually would seem to mean not closing the AVD Manager window until the AVD is fully booted and showing the Home screen (or your app).

You can specify which API level to target, but also the minimum that will run the app, in <uses-sdk android:minSdkVersion="X" android:targetSdkVersion="Y" />
The key is to specify the minSdk version too.

Related

Android SDKs sucking up my hard drive

My app supports Android 4.x all they way through 7.x. As a result, I have all API revs between 14 & 26 installed on my machine. All those API rev's combined are taking up nearly 100Gb on my hard drive.
Do I need all revs still? Does API v25 have everything need to support Android 4.1 (Rev16)?
If I don't need all those lower Revs and I can delete them is there a proper method for permanently removing them from my harddrive? The SDK Manager allows you to Delete specific packages...but does deleting them via the SDK Manager actually delete them from the computer or must I do that separately?
They only one you need is the one you are targeting and/or the versions your physical device has for instant run, if you don't use instant run in android studio then you just need the version your app is targeting

My android virtual device doesnt recognize when I update my code

My problem is that my Android Virtual Device (AVD) doesnt update when I update my code.
For instance, I run the AVD with my first code. Then I make some changes in the code (removing stuff and adding stuff). But still, the things that are shown on my AVD are from the old code. Stuff that should be there because I removed it from the code are still there when I run my AVD. And of course the new stuff isnt there.
I do:
Save my new changes.
Restart my AVD
But still it doesnt work.
If I restart my computer the changes might appear... help!
What helped me sometimes was deleting the old apk that was saved. For some reason it wasn't running replacing the old apk to be installed on the avd properly.
Also...more info could help. Are you running the code through eclipse/android studio/command line? Is your android application native or running html with the help of phonegap?
There is no need to restart the AVD. The thing you have to do is to reinstall yout application. Clicking Run in Eclipse will do the job.
I used the wrong API for my development. I used 20 when my book told me 17.
The Target was wrong. Used: "Android 4.4W.2 - API Level 20" but needed to use: "Google APIs (Google Inc.) - API Level 17"
I thought a higher API would be able to handle all lesser API numbers.
I dont know the difference between Targets "Android 4.2.2 - API Level 17" and "Google APIs (Google Inc.) - API Level 17" though.
Anyway all my problems seems to be resolved now.

Relation between android version of device and version specified in the app

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.

How can I test my android app on older versions?

I have built an android app with targetSDK 15 and minSDK 3. How can I now test it on an older version? When I set the run configurations I only see my "android 4.0" AVD even though I have created AVD for older versions.
Is there any way to test my app?
If you want to test your app for various versions. follow these steps
create all all versions of Android Virtual machines(avd) which you want to test
run your app in all versions of avds which you have created by selecting android target
right click on the project-> properties -> Android -> set target
Enjoy the testing..
Use an Emulator with an older Version.
The android level in project properties is the one which the app is build with. But in Manifest you can specifiy a minSDKVersion - that is the minimal Version for which your App will be available in Play store.
But with adb it is no problem to install it on devices or emulators which are not compatible to your current settings.
Start AVD Manager from Window -> AVD Manager. Run any AVD you like first and then run the app.

Set install location for Android 1.6?

I'm writing an application that is compatible with Android 1.6, but I would like to give users running Android 2.2 the option of moving the application installation to their sd card.
How can I compile my application for 1.6, but still allow 2.2 users to install it to their sd?
In your manifest:
In <manifest>, add "android:installLocation="preferExternal"
Keep your current uses-sdk as "<uses-sdk android:minSdkVersion="4">"
Then go to Project > Properties > Android (on the left), change the build target to 2.2, and you're all set.
Your project will build using 2.2 (but still only requires 1.6), but devices running 1.6 will simply ignore your new "installLocation" setting in the manifest. Just be careful not to add any 2.2-introduced material in your actual code, since the compiler will no longer catch it.
This is not quite as seamless as the developer guide suggests.
First, the application does not build when the installLocation is present in the manifest and the build target is set to anything other than 2.2:
error: No resource identifier found for attribute 'installLocation' in
package 'android'
So in order to test backwards-compatibililty by setting the build target to 1.6, the manifest must be edited as well.
Second, once the build target is set to 2.2, I don't get to pick an emulator with a lower API level for testing. I can still manually start an 1.6 emulator and run the app on it, though, but I am curious if my app will appear on Android Market for 1.6 devices if my build target is 2.2 (even though minSdkVersion=4). I don't have an actual device to test. Can someone confirm that this does not affect the availability on the market?
Lastly, this warning remains:
Attribute minSdkVersion (4) is lower than the project target API level (8)

Categories

Resources