【问题标题】:Unable to compile Android App: platform 'android-7' not found无法编译 Android 应用程序:找不到平台“android-7”
【发布时间】:2014-05-10 02:12:55
【问题描述】:

我是 Android 应用程序开发的新手。我下载并安装了android studio。我创建了一个新项目。我想针对 minsdkversion 7(又名 android 2.1 aka eclair)进行构建。我从构建系统收到此错误:

Failed to set up SDK
Error:Module 'app': platform 'android-7' not found.
Information:Double-click here to open Android SDK Manager and install all missing platforms.

我已验证我的电脑上确实安装了 android 7 sdk:

C:\Program Files (x86)\Android\android-studio\sdk\platforms\android-7

还有:

build.gradle 的内容:

apply plugin: 'android'

android {
    compileSdkVersion 7
    buildToolsVersion "19.0.3"

    defaultConfig {
        minSdkVersion 7
        targetSdkVersion 7
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            runProguard false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
        }
    }
}

dependencies {
    compile 'com.android.support:appcompat-v7:19.+'
    compile fileTree(dir: 'libs', include: ['*.jar'])
}

我尝试过的事情:
- 重新安装安卓工作室
- 如果我将compileSdkVersion 更改为 19,它可以工作

请问我该如何解决?有没有人能够使用 android studio 成功构建带有 compileSdkVersion = 7 的 android 应用程序?

【问题讨论】:

    标签: android gradle android-studio


    【解决方案1】:

    这是 android studio 0.5.3 的问题。我降级到 0.4.6,这个问题就消失了。另见Android Studio update 0.5.3 - platform 'android-19' not found

    以下注释只是关于单独问题的注释:

    此外,如果您的目标是 api level 7,您可能需要执行以下操作: 如果您遇到此错误:No resource found that matches the given name '@android:TextAppearance.Holo.SearchResult.Subtitle'。 在src\main\res\values\styles.xml中注释掉这段代码:

    <style name="AppTheme" parent="Theme.AppCompat">-->
            <!-- Customize your theme here. -->
    
        </style>-->
    

    build.gradle中注释掉这一行:
    compile 'com.android.support:appcompat-v7:19.+'

    如果 MainActivity 继承自 ActionBarActivity,则将其删除 (ActionBarActivity)

    【讨论】:

      【解决方案2】:

      如您所见,here 这似乎是 Android Studio 的一个常见错误

      答案说您应该创建指向此文件的符号链接

      ln -s ../build-tools/17.0.0/aapt aapt
      ln -s ../build-tools/17.0.0/lib lib
      

      如果您在 Windows 中,您可以搜索这两个文件并将它们复制到您的目录,它也应该可以工作

      【讨论】:

        猜你喜欢
        • 2021-11-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2011-06-25
        • 1970-01-01
        • 2015-09-15
        • 1970-01-01
        相关资源
        最近更新 更多