android.compileSdkVersion is missing

13,548

Solution 1

You are missing critical components of your manifest. The SDK error you are receiving is because the compiler doesn't know at what SDK level to compile your app - you're missing <uses-sdk.

And while we're at it, you're also missing your package name, version name, and version code. These are all critical components to your app. Here's an example of a well-formed manifest:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.exampleapp"
    android:versionCode="2"
    android:versionName="v0.2-Alpha" >

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

<uses-permission android:name="android.permission.GET_TASKS" />

<application
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >
    <activity
        android:name="com.example.exampleapp.MainActivity"
        android:label="@string/app_name" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>

    <service android:enabled="true" android:name="com.example.exampleapp.MyService" />

</application>

</manifest>

Notice at the very top: the sections that read package, android:versionCode, and android:versionName. And also, below those, the entire section that starts with <uses-sdk... These are all required.

Solution 2

Add this to your build.gradle:

android {
    compileSdkVersion 20
    buildToolsVersion '20.0.0'
}

Solution 3

I had the same issue and fixed it next way: in build.gradle file of module (usually in app, not in root project directory) I set

android {
    defaultConfig {
        minSdkVersion 19
        targetSdkVersion 19
        // your application version and id settings
    }

where 19 - is and SDK I have completely loaded in Android SDK Manager

(same values checked in Studio module settings, Properties and Flavors tabs).

So, may be your problem is a cause of minSdkVersion 8 value, when you don't have 8 API installed.

Share:
13,548
Golan Kiviti
Author by

Golan Kiviti

Updated on September 02, 2022

Comments

  • Golan Kiviti
    Golan Kiviti almost 2 years

    Im using AndroidStudio and Im trying to put some ads on my app, according to the setting up google play API - https://developer.android.com/google/play-services/setup.html

    Adter i sync the project with the grandle files i get this error:

    Error:Failed to find: com.google.android.gms:play-services:5.0.77
    <a href="install.m2.repo">Install Repository and sync project</a><br><a href="openFile">Open File</a><br><a href="open.dependency.in.project.structure">Open in Project Structure dialog</a>
    

    This is my gradle.build:

    apply plugin: 'com.android.application'
    apply plugin: 'android'
    android {
        compileSdkVersion 19
        buildToolsVersion "20.0.0"
    
    defaultConfig {
        applicationId "com.pachu.fartsounds"
        minSdkVersion 8
        targetSdkVersion 19
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            runProguard false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    }
    dependencies {
        compile fileTree(dir: 'libs', include: ['*.jar'])
        compile 'com.android.support:appcompat-v7:19.+'
        compile 'com.google.android.gms:play-services:5.0.77'
    }
    

    My Manifest:

    <?xml version="1.0" encoding="utf-8"?>
    <manifest xmlns:android="http://schemas.android.com/apk/res/android"
        package="com.pachu.fartsounds">
    
    <application
        android:allowBackup="true"
        android:icon="@drawable/fart_icon"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name=".FartActivity"
            android:label="@string/app_name"
            android:screenOrientation="portrait">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
    
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>
    

    Any ideas? Thanks !

  • Golan Kiviti
    Golan Kiviti almost 10 years
    Yeah, I know that but when I used eclipse it automaticlly done it for me, but on AndroidStudio it never did so I thought it didnt matter. But anyways, I changed my Manifest(updated it on the main question also) but I still get the same error : Error:Cause: android.compileSdkVersion is missing.
  • IAmTheSquidward
    IAmTheSquidward almost 10 years
    Interesting. Check this question/answer here, and see if anything there is useful, and report back! stackoverflow.com/questions/22343013/…
  • Golan Kiviti
    Golan Kiviti almost 10 years
    does it matter where to add it?
  • Golan Kiviti
    Golan Kiviti almost 10 years
    I just found out that i got confused between 2 build.gradle files, ill update the question, since now i got a different error
  • Michele
    Michele almost 10 years
    i see you have problem with com.google.android.gms:play-services:5.0.77, check in folder /path/to/your/sdk/extras/google/m2repository/com/google/andr‌​oid/gms/play-service‌​s/ the correct version of play services. The last is 5.2.08 but there is still no update on the play store and I use version 5.0.89
  • Golan Kiviti
    Golan Kiviti almost 10 years
    so just to change it to 5.0.89?
  • Michele
    Michele almost 10 years
    try to change play services version to 5.0.89, if you get error again try a different version (check inside sdk folder for correct version)
  • Drusantia
    Drusantia about 9 years
    You don't need to specify the sdk version in the manifest file, if you have it in the module's build.grade file, since gradle generates this into the manifest on build.