96

I am new to Android development and I want first to get the Hello World application running. I am using Eclipse IDE and the Android 4.0.3 version 15 SDK. I copied everything from a tutorial site, but when I try to run the application on the virtual device I get this error:

[2012-02-01 11:31:23 - Android_test] Installation error: INSTALL_FAILED_OLDER_SDK
[2012-02-01 11:31:23 - Android_test] Please check logcat output for more details.
[2012-02-01 11:31:23 - Android_test] Launch canceled!

Here is my class in the com.maze.app package: package com.maze.app;

import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;

public class HelloAndroid extends Activity{
  @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        TextView tv = new TextView(this);
        tv.setText("Hello, Android");
        setContentView(tv);

    }

}

and the AndroidManifest.xml:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.maze.app"
android:versionCode="1"
android:versionName="1.0" >

<uses-sdk android:minSdkVersion="15" android:targetSdkVersion="@string/app_name"/>

<application
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name" >
    <activity android:name="HelloAndroid" android:launchMode="standard" android:enabled="true"></activity>
</application>

Here is the configuration of the Virtual Device:

Name: AndroidVD
CPU/ABI: ARM(armeabi-v7a)
Path: path\to\avd
Target: Android 4.0.3(API level 15)
Skin: WVGA800
hw.lcd.density: 240
hw.cpu.model: cortex-a8
vm.heapSize: 48
hw.ramSize:512

What is the problem?

EDIT: The application is not running on the Virtual Device: Here is what I get on LogCat(some of the lines):

D/PackageManager(92): New package installed in /data/app/com.maze.app-2.apk
D/dalvikvm(92): GC_CONCURRENT freed 660K, 9% free 11935K/12999K, paused 18ms+72ms
I/ActivityManager(92): Force stopping package com.maze.app uid=10040
D/BackupManagerService(92): Received broadcast Intent { act=android.intent.action.PACKAGE_REPLACED dat=package:com.maze.app flg=0x10000010 (has extras) }
V/BackupManagerService(92): updatePackageParticipantsLocked: com.maze.app
Dragos
  • 2,911
  • 12
  • 39
  • 55

21 Answers21

119

It is due to android:targetSdkVersion="@string/app_name" in your manifiest file.
Change it to:

<uses-sdk android:minSdkVersion="15" android:targetSdkVersion="15"/>

The targetSdkVersion should be an integer, but @string/app_name would be a string. I think this causing the error.

EDIT:
You have to add a default intent-filter in your manifiest file for the activity. Then only android can launch the activity. otherwise you will get the below error in your console window.

[2012-02-02 09:17:39 - Test] No Launcher activity found!
[2012-02-02 09:17:39 - Test] The launch will only sync the application package on the device!

Add the following to your <activity> tag.

<activity android:name="HelloAndroid" android:launchMode="standard" android:enabled="true">  
  <intent-filter>
    <action android:name="android.intent.action.MAIN" />
    <category android:name="android.intent.category.LAUNCHER" />
  </intent-filter>
</activity>
Karthik
  • 3,509
  • 1
  • 20
  • 26
  • Thank you! Now I don't get the error anymore. But The Virtual Device starts and it doesn't show me `Hello Android`. Do I have to start it somehow? If yes, how? If not, why isn't it working? – Dragos Feb 01 '12 at 10:48
  • if you run from eclipse, the app will be automatically started after installation. So the activity should show up on the AVD screen. When the AVD starts, it would be in Locked state (screen lock), once you unlock the screen you can see the `Hello Android` text. – Karthik Feb 01 '12 at 11:19
  • Yes, it starts in Lock state, but when I unlock it, it just shows me the wallpaper and some icons at the bottom. There is no `Hello Android`. – Dragos Feb 01 '12 at 11:31
  • any errors on the Logcat? you can add some [Log](http://developer.android.com/reference/android/util/Log.html) statements in onCreate() and see if they are shown in the Logcat window. – Karthik Feb 01 '12 at 11:33
  • If by `Logcat` you mean the `Console` in Eclipse, then the answer is no. I don't get any errors. If that's not what you meant by Logcat, please tell me where I can find it. – Dragos Feb 01 '12 at 11:36
  • It is not console. Logcat is a window where we can view log messages. In Eclipse, open `Window->Show View->Others`, under `Android`, you will see `LogCat`. click it, it will open a window. – Karthik Feb 01 '12 at 11:41
  • I edited the question and added some lines from LogCat. What do they mean? – Dragos Feb 01 '12 at 13:01
  • Thank you! It works. It starts very very slow, but it works. Is it normal to be so slow(5 min)? – Dragos Feb 02 '12 at 11:35
  • you are welcome. yea, AVD is very slow. It depends on the PC configuration also. – Karthik Feb 02 '12 at 12:50
  • @Karthik I set neither minSdk nor targetSdk. But I get this error during install APK. I even decompiled final APK, and there is no min/target attribute. – Dr.jacky Dec 08 '16 at 08:39
  • @Mr.Hyde Could you give me some more details, like what is the exact error, steps you are following, dev environment (Android studio?). – Karthik Dec 10 '16 at 07:12
  • @Karthik I'm working on AOSP, with gcc 4.2 I think, and JDK 1.6. What information you need more? – Dr.jacky Dec 10 '16 at 08:33
30

This means the version of android of your avd is older than the version being used to compile the code

Rajdeep Dua
  • 11,190
  • 2
  • 32
  • 22
  • You build AVD's (Android Virtual Devices) given a certain set of features (Screen size, code version, camera status). Build one that is the same as your target API version. Also build an older one for compatibility testing. – Bryce Jun 13 '13 at 17:20
18

This error occurs when the sdk-version installed on your device (real or virtual device) is smaller than android:minSdkVersion in your android manifest.

You either have to decrease your android:minSdkVersion or you have to specify a higher api-version for your AVD.

Keep in mind, that it is not always trivial to decrease android:minSdkVersion as you have to make sure, your app cares about the actual installed API and uses the correct methods:

AsyncTask<String, Object, String> task = new AsyncTask<String, Object, String>() {
    @Override
    protected Boolean doInBackground(String... params) {
        if (params == null) return "";
        StringBuilder b = new StringBuilder();
        for (String p : params) {
             b.append(p);
        }
        return b.toString();
    }
};
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
    task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR,"Hello", " ", "world!");
} else {
    task.execute("Hello", " ", "world!");
}

Using the android-support-library and/or libraries like actionbar-sherlock will help you dealing especially with widgets of older versions.

AlexS
  • 5,295
  • 3
  • 38
  • 54
15

I am using Android Studio 0.8.1. I have a project's gradle file like below:

android {
    compileSdkVersion 19
    buildToolsVersion "20.0.0"

    defaultConfig {
        applicationId "com.omersonmez.widgets.hotspot"
        minSdkVersion 15
        targetSdkVersion 19
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            runProguard false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

My emulator was android 4.0. So i modified my emulator and made api level 4.0.3(apilevel 15). It worked.

Stunner
  • 12,025
  • 12
  • 86
  • 145
Omer Sonmez
  • 1,168
  • 2
  • 20
  • 31
5

I tried all the responses described here but my solution was changing inside my build.gradle file minSdkVersion from 8 to 9 because some libraries in my project can´t work with API 8, that´s was the reason for the message INSTALL_FAILED_OLDER_SDK:

apply plugin: 'com.android.application'

    android {
        compileSdkVersion 22
        buildToolsVersion "22.0.1"

        defaultConfig {
            applicationId "com.tuna.hello.androidstudioapplication"
            minSdkVersion 9
            targetSdkVersion 22
            versionCode 1
            versionName "1.0"
        }
...
...
...
Jorgesys
  • 124,308
  • 23
  • 334
  • 268
2

You will see the same error if you are trying to install an apk that was built using

compileSdkVersion "android-L"

Even for devices running the final version of Android 5.0. Simply change this to

compileSdkVersion 21
friederbluemle
  • 33,549
  • 14
  • 108
  • 109
2

Fix for new Android 6.0 Marshmallow Fixed my issue when I updated to API 23 (Android 6.0 Marshmallow) by updating the build tools version to 23.0.0 as follows:

android {
    buildToolsVersion '23.0.0'
...

And went to File > Project Structure , chose Properties tab then updated the Compile Sdk version to "API 23: Android 5.X (MNC)" and the Build tools version to "23.0.0"

yehyatt
  • 2,295
  • 3
  • 28
  • 31
1

In my case I edited a project having this in the AndroidManifest.xml file, and which was ginving me the above error, at runtime:

<uses-sdk
    android:minSdkVersion="17"
    android:targetSdkVersion="17" />

What I did just, was to change minSdkVersion="17", to minSdkVersion="16". My resulting tag was:

<uses-sdk
    android:minSdkVersion="16"
    android:targetSdkVersion="17" />

Now I'm not getting the error anymore..

Hope this helps

user9869932
  • 6,571
  • 3
  • 55
  • 49
1

Received the same error , the problem was difference in the version of Android SDK which AVD was using and the version in AndroidManifest file. I could solve it by correcting the

android:minSdkVersion="16"

to match with AVD.

Hari Palappetty
  • 539
  • 6
  • 14
0

I am on Android Studio. I got this error when min/targetSDKVersion were set to 17. While looking thro this thread, I tried to change the minSDKVersion, voila..problem fixed. Go figure.. :(

    android:minSdkVersion="17"
    android:targetSdkVersion="17" />
Mr. B
  • 261
  • 3
  • 7
0

Make sure to check your build.gradle and that it doesn't use a newer SDK version than what is installed on your AVD. That's only if you use Android Studio though.

janex
  • 497
  • 4
  • 14
0

If you are totally new like me, you must install the minimum SDK at first. Check the link.

This worked out perfectly for me:

Same problem other post with a good solution

cigien
  • 57,834
  • 11
  • 73
  • 112
Khaled
  • 93
  • 13
0

My solution was to change the run configurations module drop-down list from wearable to android. (This error happened to me when I tried running Google's I/O Sched open-source app.) It would automatically pop up the configurations every time I tried to run until I changed the module to android.

You can access the configurations by going to Run -> Edit Configurations... -> General tab -> Module: [drop-down-list-here]

Rock Lee
  • 9,146
  • 10
  • 55
  • 88
0

I found that making the recommended change in the manifest didn't solve my problem.

The fix was found in the GradleScripts folder, in the build.gradle file for the Module:app.

Inside this file (build.gradle) the following line was modified. minSdkVersion 22 I changed this '22' value to '19' for my particular phone and the build completed without error.

jdosser
  • 143
  • 1
  • 7
0

Mate, my advice is to change virtual device. Download "Genimotion" application, its easy to use and there are a lot of any devices you need

Shell Scott
  • 1,679
  • 18
  • 28
0

Go in your project's build.cradle file and add

defaultConfig {
    minSdkVersion versions.minSdk

}`

This makes it that your application conforms to the minimum SDK your device is running.

0

In our case using Flutter, some of our plugins required minimum API level 23 (Android 6.1) due to which several old devices could not install our app . For example, a Huawei Android 5.1 device could not install the app as the Flutter project's several plugins demanded minimum API 23 or Android version 6.1 .

To make a solution in such a case:

  1. Either, remove those plugins to make your app compatible with old phones
  2. Or, keep using high-API-required Flutter plugins that may lose old-device users .

Installed_Failed_Older_SDK

Farial Mahmod
  • 61
  • 1
  • 4
-1

Ionic Android emulator error INSTALL_FAILED_OLDER_SDK

So, basically it means that the installation has failed due to having an older SDK version than the targetSdkVersion specified in your app (it's a Gradle issue). Just edit the AndroidManifest.xml file and add the following code:

<uses-sdk android:minSdkVersion="19" android:targetSdkVersion="14"/>

After days looking for the solution, that's it.

Works fine for me!

Tom Costa
  • 7
  • 3
-1

If the error "Installation error: INSTALL_FAILED_OLDER_SDK" appears, you must change the version of minSdkVersion in AndroidManifest to the one specified in the android emulator: see Settings -> About phone -> Android version.

-1

<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.17/vue.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/16.6.3/umd/react.production.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react-dom/16.6.3/umd/react-dom.production.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/knockout/3.4.2/knockout-min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/d3/5.7.0/d3.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.7.5/angular.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<uses-sdk android:minSdkVersion="19" android:targetSdkVersion="14"/>
  • 1
    As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Feb 12 '23 at 10:23
-2

I've changed my android:minSdkVersion and android:targetSdkVersion to 18 from 21:

uses-sdk android:minSdkVersion="18" android:targetSdkVersion="18" 

Now I can install my app successfully.

Remi Guan
  • 21,506
  • 17
  • 64
  • 87
Veena
  • 31
  • 7