正确的构建版本以使用Google API

时间:2017-02-03 16:48:54

标签: android google-api build.gradle

我想在我的项目中使用com.android.future.usb.UsbManager;。此类附带谷歌api。我创建了一个新项目,从项目结构设置(我使用android studio)我将编译SDK版本更改为 Google API(API 19),将构建工具版本更改为 19.1.0 < / strong>

我的build.gradle文件如下,但我遇到了几个错误。

我的问题是:如何找到使用Google API(API 19)或Google API(API 17)的正确组合? 哪个构建工具版本(我在UI中尝试过所有版本)?

  

错误:(9)检索项目的父项时出错:找不到与给定名称匹配的资源&#39; Theme.AppCompat.Light.DarkActionBar&#39;。&#34;

     

错误:任务&#39;:app:processDebugResources&#39;执行失败。   com.android.ide.common.process.ProcessException:无法执行aapt

compileSdkVersion 'Google Inc.:Google APIs:19'
buildToolsVersion '19.1.0'
defaultConfig {
    applicationId "com.example.cihan.myapplication"
    minSdkVersion 10
    targetSdkVersion 19
    versionCode 5
    versionName "5.0"
    testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}

编辑:我重新安装了Android Studio,并选择了最新的Google API版本和版本(两个版本现在都是24)

1 个答案:

答案 0 :(得分:1)

  

检索项目的父项时出错:找不到与给定名称“Theme.AppCompat.Light.DarkActionBar”匹配的资源。“

您需要编译appcompat库

dependencies {
    compile 'com.android.support:appcompat-v7:19+'
}

注意:我只使用版本19+,因为这似乎是您要编译的内容。那是在2014年发布的,所以我建议升级。

您可以使用最新的SDK进行编译,并且仍然可以在API 19上的设备上运行(大多数)代码

请参阅 - Android Material Design | Maintaining Compatibility