我想使用sdk版本22編譯我的項目,但android studio使用版本23,所以它給出了一些錯誤。我使用Android Studio 1.3,我不想使用sdk 23(我有一些不贊成使用的方法,我不想在這時替換它們)。這是我的gradle這個文件:Android工作室拉錯sdk版本編譯項目
apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "ir.mhealth.healthnotation"
minSdkVersion 16
targetSdkVersion 22
versionCode 2
versionName "1.0.0.1"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.2.0'
compile 'com.android.support:recyclerview-v7:22.2.0'
compile 'com.jjoe64:graphview:4.+'
compile 'com.afollestad:material-dialogs:0.7.+'
compile 'com.google.android.gms:play-services-analytics:7.8.0'
}
當我運行gradle這個依賴報告中,我得到這樣的響應:
------------------------------------------------------------
Project :app
------------------------------------------------------------
_debugAndroidTestApk - ## Internal use, do not manually configure ## No dependencies
_debugAndroidTestCompile - ## Internal use, do not manually configure ## No dependencies
_debugApk - ## Internal use, do not manually configure ##
+--- com.android.support:appcompat-v7:22.2.0 -> 23.0.0
| \--- com.android.support:support-v4:23.0.0
| \--- com.android.support:support-annotations:23.0.0
+--- com.android.support:recyclerview-v7:22.2.0 -> 23.0.0
| +--- com.android.support:support-annotations:23.0.0
| \--- com.android.support:support-v4:23.0.0 (*)
+--- com.jjoe64:graphview:4.+ -> 4.0.1
| \--- com.android.support:support-v4:21.0.3 -> 23.0.0 (*)
+--- com.afollestad:material-dialogs:0.7.+ -> 0.7.9.1
| +--- com.android.support:support-v4:23.0.0 (*)
| +--- com.android.support:appcompat-v7:23.0.0 (*)
| +--- com.android.support:recyclerview-v7:23.0.0 (*)
| \--- com.android.support:support-annotations:23.0.0
\--- com.google.android.gms:play-services-analytics:7.8.0
\--- com.google.android.gms:play-services-base:7.8.0
\--- com.android.support:support-v4:22.2.0 -> 23.0.0 (*)
debugCompile - ## Internal use, do not manually configure ##
+--- com.android.support:appcompat-v7:22.2.0 -> 23.0.0
| \--- com.android.support:support-v4:23.0.0
| \--- com.android.support:support-annotations:23.0.0
+--- com.android.support:recyclerview-v7:22.2.0 -> 23.0.0
| +--- com.android.support:support-annotations:23.0.0
| \--- com.android.support:support-v4:23.0.0 (*)
+--- com.jjoe64:graphview:4.+ -> 4.0.1
| \--- com.android.support:support-v4:21.0.3 -> 23.0.0 (*)
+--- com.afollestad:material-dialogs:0.7.+ -> 0.7.9.1
| +--- com.android.support:support-v4:23.0.0 (*)
| +--- com.android.support:appcompat-v7:23.0.0 (*)
| +--- com.android.support:recyclerview-v7:23.0.0 (*)
| \--- com.android.support:support-annotations:23.0.0
\--- com.google.android.gms:play-services-analytics:7.8.0
\--- com.google.android.gms:play-services-base:7.8.0
\--- com.android.support:support-v4:22.2.0 -> 23.0.0 (*)
-debugUnitTestApk - ## Internal use, do not manually configure ##
no dependencies
-debugUnitTestCompile - ## Internal use, do not manually configure ##
no dependencies
_releaApk - ## Internal use, do not manually configure ##
+--- com.android.support:appcompat-v7:22.2.0 -> 23.0.0
| \--- com.android.support:support-v4:23.0.0
| \--- com.android.support:support-annotations:23.0.0
+--- com.android.support:recyclerview-v7:22.2.0 -> 23.0.0
| +--- com.android.support:support-annotations:23.0.0
| \--- com.android.support:support-v4:23.0.0 (*)
+--- com.jjoe64:graphview:4.+ -> 4.0.1
| \--- com.android.support:support-v4:21.0.3 -> 23.0.0 (*)
+--- com.afollestad:material-dialogs:0.7.+ -> 0.7.9.1
| +--- com.android.support:support-v4:23.0.0 (*)
| +--- com.android.support:appcompat-v7:23.0.0 (*)
| +--- com.android.support:recyclerview-v7:23.0.0 (*)
| \--- com.android.support:support-annotations:23.0.0
\--- com.google.android.gms:play-services-analytics:7.8.0
\--- com.google.android.gms:play-services-base:7.8.0
\--- com.android.support:support-v4:22.2.0 -> 23.0.0 (*)
-releaseCompile - ## Internal use, do not manually configure ##
+--- com.android.support:appcompat-v7:22.2.0 -> 23.0.0
| \--- com.android.support:support-v4:23.0.0
| \--- com.android.support:support-annotations:23.0.0
+--- com.android.support:recyclerview-v7:22.2.0 -> 23.0.0
| +--- com.android.support:support-annotations:23.0.0
| \--- com.android.support:support-v4:23.0.0 (*)
+--- com.jjoe64:graphview:4.+ -> 4.0.1
| \--- com.android.support:support-v4:21.0.3 -> 23.0.0 (*)
+--- com.afollestad:material-dialogs:0.7.+ -> 0.7.9.1
| +--- com.android.support:support-v4:23.0.0 (*)
| +--- com.android.support:appcompat-v7:23.0.0 (*)
| +--- com.android.support:recyclerview-v7:23.0.0 (*)
| \--- com.android.support:support-annotations:23.0.0
\--- com.google.android.gms:play-services-analytics:7.8.0
\--- com.google.android.gms:play-services-base:7.8.0
\--- com.android.support:support-v4:22.2.0 -> 23.0.0 (*)
.
.
.
wearApp - Link to a wear app to embed for object 'main'.
No dependencies
BUILD SUCCESSFUL
爲什麼它試圖用23來替換SDK 22 ???我該如何解決它?
(我應該提到,我沒有任何問題,直到我決定將我的android studio升級到版本1.4。更新後,它下載了sdk 23,雖然我沒有更改我的gradle文件,但是android studio試圖編譯項目與sdk 23,你可以看到我卸載android studio和安裝舊版本,但問題並沒有解決,我知道版本1.4使用sdk 23爲新項目,但我的項目並不新,也使用舊版本的Android工作室現在它並沒有解決我的問題)
我沒有更改我的gradle文件或庫,並且它們在sdk 22中沒問題。在將android studio更新到新版本之前,我的系統上沒有sdk版本23!或者我沒有使用support-v4。 – Taher
@Taher更好地閱讀我的答案。問題在於您在使用支持庫v23時正在使用api 22。而且,您正在使用support-v4,因爲您正在使用具有此依賴性的外部庫。 Android Studio不使用api 23! –
你是對的,我從gradle中刪除了'com.afollestad:material-dialogs:0.7。+',它工作正常,但現在我在使用該庫的類中出現了一些錯誤。我無法理解爲什麼我的項目在我更新我的android studio之前很好。這些庫是一樣的。看來我應該用另一個庫替換那個庫。 – Taher