2015-12-21 37 views
9
Failed to set up SDK: Error:Module 'app': platform 'Google Inc.:Google APIs:21' not found. 

完全喪失了爲什麼這不起作用。試圖更新我的SDK到23,但意識到我沒有準備處理所有新的棄用等,所以我恢復到舊版本的Mercurial。我完全沒有別的了,而且迴歸應該已經解決了一切。不幸的是,我無法連接我的應用程序並構建它。我甚至從頭重新安裝了Android Studio,但我仍然收到相同的警告,我的應用程序根本無法生成。什麼可能會出錯?無法設置SDK:錯誤:模塊'app':平臺'Google Inc.:Google API:21'找不到

這裏是我的gradle構建:

apply plugin: 'com.android.application' 

android { 
    compileSdkVersion 'Google Inc.:Google APIs:21' 
    buildToolsVersion '21.1.2' 

    defaultConfig { 
     applicationId "com.elgami.customizer" 
     minSdkVersion 14 
     targetSdkVersion 21 
    } 

    buildTypes { 
     release { 
      minifyEnabled false 
      //runProguard false 
      //proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt' 
     } 
    } 
} 

repositories { 
    mavenCentral() 
    maven { url "https://jitpack.io" } 
} 

dependencies { 
    compile 'com.ogaclejapan.smarttablayout:library:[email protected]' 
    compile 'com.github.antonyt:InfiniteViewPager:v1.0.0' 
    compile 'com.android.support:appcompat-v7:22.2.0' 
    // recyclerview 
    compile 'com.android.support:recyclerview-v7:23.1.1' 
    // google analytics 
    compile 'com.google.android.gms:play-services-analytics:8.3.0' 
    // pager sliding strip 
    compile 'com.astuetz:pagerslidingtabstrip:1.0.1' 
    // http library (for using beanstream REST) 
    compile 'org.apache.httpcomponents:httpclient-android:4.3.5.1' 
    // amaazon S3 uploads 
    compile 'com.amazonaws:aws-android-sdk-s3:2.1.+' 
    // paypal purchasing 
    compile files('libs/PayPalAndroidSDK-2.7.1.jar') 
    // Module dependency on ParseLoginUI library sources 
    compile project(':ParseLoginUI') 
    // Parse libs 
    compile files('libs/ParseCrashReporting-1.9.2.jar') 
    compile files('libs/Parse-1.9.1.jar') 
    compile files('libs/ParseFacebookUtilsV4-1.9.1.jar') 
    // android support v4 
    compile files('libs/android-support-v4.jar') 
    // facebook SDK 
    compile 'com.facebook.android:facebook-android-sdk:4.1.0' 
    //butterknife 
    compile 'com.jakewharton:butterknife:6.1.0' 
    // Subsampling-scale-image-view (for templating) 
    //compile 'com.davemorrissey.labs:subsampling-scale-image-view:3.1.4' 
    compile files('libs/AppRater.jar') 
} 

回答

9

您可以使用compileSdkVersion 21,而不是你的。

android { 
    compileSdkVersion 21 
    buildToolsVersion '21.1.2' 

    defaultConfig { 
     applicationId "com.elgami.customizer" 
     minSdkVersion 14 
     targetSdkVersion 21 
    } 

    buildTypes { 
     release { 
      minifyEnabled false 
      //runProguard false 
      //proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt' 
     } 
    } 
} 
+0

好吧,一些東西開始工作。現在我得到''錯誤:原因:未能找到目標21:D:\ Android \ sdk1 Install missing platform(s) and sync project'',但它不會讓我安裝它。有什麼辦法可以從某個地方手動下載嗎?我想在重新安裝Android Studio後,它下載了Sdk 23,但我現在確實需要保持在21。 ''忽略未知的包過濾器'android-21'Warning:包過濾器刪除所有包。沒有什麼可安裝的。請考慮嘗試在沒有包過濾器的情況下再次更新。'' – santafebound

+0

您是否在項目中執行了「清理 - 重建 - 重啓 - 同步」? –

+1

是的,我一直在收到同樣的問題。 – santafebound

5

暗示與21更換Google Inc.:Google APIs:21的(目前公認的)答案不適合,如果你有一些遺留的應用程序仍然使用谷歌地圖V1(例如)。

如果你在這種情況下,你真的需要進行編譯Google Inc.:Google APIs:21或23等...

這裏的解決方案是

步驟1

打開舊的SDK管理器界面點擊在Android Studio SDK Manager下啓動獨立SDK管理器鏈接,或者通過從命令行執行${ANDROID_SDK_DIR}/tools/android sdk直接打開它。

然後找到你需要的SDK版本谷歌的API並安裝:

screenshot of the SDK Manager

這包是隱藏的,由於某種原因,Android的工作室裏,我希望谷歌會在某個刪除點。目前SDK 24 one(棉花糖)可用,但25(牛軋糖)不是,它們可能在未來添加它,或者不是。我們將不得不等待觀察。

如果您處於這種情況,Google決定停止提供它,您將不得不使用maps v2重寫該功能。

步驟2

即使是這樣做的,清潔的gradle +後重新同步,你會得到這個錯誤在Android工作室:

Cannot find System Java Compiler. Ensure that you have installed a JDK (not just a JRE) and configured your JAVA_HOME system variable to point to the according directory. 

但是,如果你嘗試從做它會編譯命令行(./gradlew assembleDebug)。

原因顯然與Android Studio嵌入式Java JRE有關。 爲了讓編譯裏面的Android Studio中打開在Android Studio中項目結構並提供一個JDK您的系統上安裝(您必須安裝在計算機上的OpenJDK/OracleJDK)的自定義路徑。

注意:可能需要導航到該位置,而不是複製Android Studio的路徑以進行更改。不要選擇jre目錄,選擇JDK(包含jre的文件夾)。

警告:此更改不是特定於該項目,而是將應用於Android Studio本身並用於任何其他項目。

0

當我失敗時,我下載了Google API,就像@Daniel Segato解釋的那樣,這是正確的做法,我仍然一次又一次地收到了這個消息。

直到我做到了。我打開模塊的設置(Ctrl + Alt + Shift + S文件>項目結構),並且,對於我的模塊,我將編譯Sdk版本選項更改爲列表中的任何其他項。我使用了resynchornized gradle,然後將選項更改回Google API(API 23)。然後它工作! Android Studio確實非常令人討厭,除非您在該對話框中更改SDK,否則無法識別該SDK。但這隻發生在我身上一次。其他時候,只需下載適當的Google API即可。但這很討厭。

相關問題