2017-02-03 97 views
0

我想在我的項目中使用com.android.future.usb.UsbManager;。這個課程附帶google api。我創建了一個新的項目,從項目結構的設置(我使用Android工作室),我改變了編譯SDK版本谷歌的API(API 19)和構建工具版本19.1.0使用Google API的正確版本版本

我的身材。 gradle文件如下,但我得到了一些錯誤。

我的問題是:如何才能找到使用Google API(API 19)或Google API(API 17)的正確組合?
哪個構建工具版本(我在UI中都嘗試過)?

Error:(9) Error retrieving parent for item: No resource found that matches the given name 'Theme.AppCompat.Light.DarkActionBar'."

Error:Execution failed for task ':app:processDebugResources'. com.android.ide.common.process.ProcessException: Failed to execute 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和選擇最新的谷歌API的版本和構建版本(兩個版本現在24)

+0

你爲什麼不使用只是最新的一個? –

+0

gui中的最大可用值是Google API(API 19),如果我同時選擇最大可用值,則最大可用構建工具版本爲24.0.3。 – Cozdemir

回答

1

Error retrieving parent for item: No resource found that matches the given name 'Theme.AppCompat.Light.DarkActionBar'."

您需要編譯的程序兼容性庫

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

注意:我只使用版本19+,因爲這似乎是你想要編譯。這是2014年發佈的,所以我建議升級。

您可以編譯使用最新的SDK,並仍然在設備上運行的API(大多數)代碼19

見 - Android Material Design | Maintaining Compatibility

+0

我改變了構建版本到24.0.3(最大我可以在gui中選擇)並添加了編譯'com.android.support:appcompat-v7:25.1.1' 但我仍然得到相同種類的錯誤。還我改變的build.gradle像下面 compileSdkVersion '谷歌Inc.:Google的API:19' buildToolsVersion '24 .0.3' defaultConfig { 的applicationID 「com.example.cihan.myapplication」 的minSdkVersion 19 targetSdkVersion 24 的versionCode 5 versionName「5.0」 testInstrumentationRunner「android.support.test.runner.AndroidJUnitRunner」 } – Cozdemir

+0

我不認爲buildToolsVersion應該大於compileSdkVersion。與targetSdkVersion相同。如果您無法選擇較高的號碼,則需要從SDK Manager中安裝 –

+0

我將立即更新並重試。你能否給我舉一個例子你的配置。例如谷歌API版本buid版本,並編譯'com.android.support:appcompat-v7:19+'屬性。 – Cozdemir