Select target API in the Android Studio layout design preview - android

My application targets API 17 but the min Sdk version is the 8. In the layout design preview page I can se how my layout appears on an API 17 version, but if I click on the API selector drop down menu, I can't choose any other API level.
Obviousely I can run my application in a 2.3 Android version and on a real device I can see the result, but is there a way to test in also in the design preview page?
My manifest snippet:
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />

UPDATE
Actually I found out what the problem was:
when you install Android Studio, by default it uses its own Android SDK (located in the Android Studio.app/sdk folder), instead of the ones you downloaded (for example to use with Eclipse).
So I simply had a misalignement between the SDK I thought I was using and the ones I was actually using. To solve this you have 2 options:
-from Android Studio select File -> Project Structure. Under "platform settings" you can add your (updated) downloaded SDK folder and use it for your projects.
-open the Android Studio SDK manager and install also the older android versions SDKs

It seems like 17 is the only available API level for preview at the moment.
I have all the SDKs installed correctly and it appears the same as yours.

Related

In eclipse I a getting the API level 20 .I want ot use lower versions of API

How to change API level. when selecting this API level it shows no CPU/ABi available and also I am not able to add text fields it throws an exception.
Image 1Image 2
In Eclipse go to manifest.xml
<uses-sdk android:minSdkVersion="int" />
In android studio: go to your app Gradle there you can find the minSdkVersion. Lower it to the version you needed.
android {
....
defaultConfig {
....
minSdkVersion 17
....
}
}
Quick Fix: Uncheck installed checkbox to see other downloads and try to refresh android sdk manager, restart it or restart the computer. API 19 worked fine for me before I moved to android studio.
I'm not sure if API 20 is supported in eclipse, I recommend Android Studio for android development. Anyway, if you have an old PC that does not meet android studio minimum requirement, download IntelliJ IDEA https://www.jetbrains.com/idea/, it's a bit lighter and free and require 1 GB of RAM (But 1 GB is very bad, you need at least 2 GB without running android emulator). However, if you still want to work with eclipse I think you need API 19 you have to download it manually from the web and move it to android SDK location. Or you can install android studio to download SDK without using it.
Newer APIs are way better, they have more libraries that supports both old and new android versions. It's really worth upgrading to Android Studio.
For the CPU/ABi error check this post Android 4.3 Virtual Device CPU/ABI - No system images installed (eclipse)

Intellij Android preview pane when editing layout xml does not allow me to select other SDK versions

I'm using Intellij13 running Android SDK 19.
There is a bug in the DatePicker component which causes the preview pane to exception rather than showing a preview of the layout.
Posts on the web recommended selecting an earlier SDK version in the preview pane. A version of 16 is meant to bypass this particular exception.
I've downloaded the SDK 16 using the Android SDK Manager. However the dropdown in the preview pane does not show version 16. It only shows 19, and an option to "Automatically Pick Best".
I've ensured that my AndroidManifest has a minSdkVersion which is below 16.
Does anyone know how I can get version 16 showing in this dropdown?
Cheers
Make sure that needed SDK versions are installed using the same SDK Manager, re-add SDK. IDEA restart may be necessary for changes to take effect.

Android AVD with lower API level

A bit of a silly question, but I am trying to play around with supporting different Android API levels and created a simple application which has the following SDK version settings:
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="18" />
I have a device to test on which has the latest version installed, but when I am trying to create AVD with lower version API I can't choose any other option apart from the latest one (18) as nothing is available in the list. I've tried a variety os sample devices with no luck. How can I create an AVD with API level 8 or 10?
Download that sdk level and emulators for the level from the Android SDK manager. If the sdk is set up properly, simply type android in the command prompt and it should show up.
Download:
Sdk platform
System image
for API you want to use from Android SDK manager.

Unable to resolve target 'Google Inc.:Google APIs:16'

I experience this problem when I added another project from internet. I think it asks me to use another version of target android. But I want that my app will work in android 2.2.
But it doesn't require API-8, it requires API-16 and I m not sure what I should do.
Modify the AndroidManifest.xml file so that any versions in there are Android 2.2. Also change the version of the SDK used by right clicking the project in eclipse and go to properties->android and change the version to 2.2. Some things might break though. Usually the version declared in the manifest is declared because the project uses SDK features only available for that version or later.
Your app will still work on older versions even if you are targeting newer version. The target is what version you have tested your app to work on. If you target the most recent version (API 16), then your app will not be put in 'compatibility mode' when running on older phones. For example, if you have a menu button in 2.x but you target API 16, this menu button will not show up on certain phones since you're supposed to be using the ActionBar.
The minSdkVersion is what you are thinking of, which will make sure your app runs on older versions:
<uses-sdk android:minSdkVersion="8" />
So the solution to your problem is just to download the newest API level through the SDK Manager. You most likely just don't have API 16 installed.

Android application built in eclipse for 2.3 will it work in 2.2?

I've built an Android application in eclipse. Before starting the project I selected the 2.3.3 api. The code is very basic.
A friend of mine asked to have a copy, but he's using 2.2, do I have to rebuild the project in 2.2 or will it work just fine if I send him the APK build with the 2.3.3 api?
change
<uses-sdk android:minSdkVersion=.... />
in the android manifest to
<uses-sdk android:minSdkVersion="8" />
Change the Project Build Target to 2.2, in the Properties Menu of your project in the Android drill down.
You should only get errors if you used methods that were introduced with the level 10 API (Android 2.3.3). Since you pointed out that your application is very basic, I highly doubt you'll run into major problems.
From the docs
Selecting a platform version and API Level
When you are developing your application, you will need to choose the platform version against which you will compile the application. In general, you should compile your application against the lowest possible version of the platform that your application can support.
You can determine the lowest possible platform version by compiling the application against successively lower build targets. After you determine the lowest version, you should create an AVD using the corresponding platform version (and API Level) and fully test your application. Make sure to declare a android:minSdkVersion attribute in the application's manifest and set its value to the API Level of the platform version.
So in short, you'll have to recompile it
If you go to the properties for your project and then select the Android dialog, you can change the API which your project is using. Provided you have have it installed.
In the AndroidManifest file set android:minSdkVersion to 7. In this way you force it to run in compatibility mode on devices that have lower version than the target mode(which is 8 in your case).

Categories

Resources