I have completed the basics of android application using eclipse. I am now trying to create games using the ANDengine which I'm sure I have done correctly.
To make sure I'm on the right track, I downloaded examples and tried to run them on my tablet. After importing the sample code, I received an error "cannot resolve target android-15" which I solved by installing SDK 4.0.3 which had the Api level 15. I downloaded the bundle with sdk 4.4 and api level 19. I would have thought level 19 would be sufficient but I downloaded it anyway.
I downloaded a second example and it now cannot resolve "android-8" which I'm assuming is going to require another SDK.
How does the api levels work? Am I required to install all of the SDK versions?
The SDKs themselves are not downwards compatible. If it say in your AndroidManifest.xml that the target SDK version is 15, you'll need exactly that version to compile the project.
Anyway, the code itself is upwards compatible. Just open your AndroidManifest.xml and look for something like that:
<uses-sdk
android:minSdkVersion="15"
android:targetSdkVersion="15" />
Change it to
<uses-sdk
android:minSdkVersion="15"
android:targetSdkVersion="19" />
and you can compile with API level 19.
I do not know about AndEngine, but for using different API levels in your code, you need to download the required files for each platform using SDK manager. You can check in $SDK_ROOT/platforms folder which API levels are already downloaded on your machine. You need to download each API-level, before using them in your project. Downloading the highest one is not enough.
And yeah you need to download the version which you're going to target i.e. the version which is going to be used to compile the project (targetSdkVersion), not the one you want to use as minimum api level (minSdkVersion)
Related
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.
This is probably very basic but I have failed to find information on how to do this. On iOS I have a base SDK and a target SDK so I can use the latest features from the base SDK (of course check if they are available first) and at the same time make my app run on devices with the target SDK. How can I do the same thing with Android in Eclipse, how can I compile with Android 4.1 and at the same time make my app run on (deploy to) Android 2.3?
Im not asking about checking which version I am running at run time, but how do I configure Eclipse correctly.
Thank you
Søren
Start by reading backward compability on Android developer site. You are probably looking for "Set Minimum and Target API levels".
On your Androidmanifest.xml check for the uses-sdk tag
<uses-sdk android:minSdkVersion="8" android:targetSdkVersion="16" />
version 8 is Android 2.2 up to 16 for 4.1/4.1.1
from here
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.
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).
I've just started developing android apps and I am wondering about this right from the start.
Apparently it doesn't matter if you work with API 13 (3.2), you can still support Android 1.6. Is that true?
For AdMob to work, I had to start working with API 13 and have set
target=android-13
Someone please clarify this or point me somewhere to read it.
Apparently it doesn't matter if you work with API 13 (3.2), you can still support Android 1.6. Is that true?
That depends on what you mean by "work with API 13".
Having a build target of API Level 13, as you mention later in your question, simply means that is the version of the Android SDK you are compiling against. You will be able to reference classes and methods that exist on API Level 13 (and earlier). Your app can still run on any version of Android you want.
However:
You cannot call methods that do not exist in API Level 13 when you are not running on an API Level 13 device (and likewise for API Level 12, 11, 10, etc.).
If you wish to support Android 1.x, you cannot even reference classes or methods that do not exist on the device from a class that gets loaded by the VM.
In either of those cases, you will get a VerifyError, and your app will go "boom".
There are strategies for conditionally using newer-API stuff that allow you to avoid trying to use that stuff on older-API devices. Or, just stick to older-API stuff in the first place, even though you won't get compiler assistance to let you know when you are accidentally using newer-API stuff, given that you are using the newer build target.
Or, contact AdMob support and figure out why they need that build target.
In your Manifest file you can put the min sdk version you want to support and your target sdk version, they could be different, to support 1.6 specify android:minSdkVersion="4" as follows
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<uses-sdk android:minSdkVersion="4" android:targetSdkVersion="13" />