Android 升级更新时出错:预期版本>;=21但发现1
我的项目昨天正在完美地构建和运行。现在我更新了Gradle,因为Android Studio为我提供了这个选项。现在它无法运行我的项目。每次尝试时,都会提示以下错误:Android 升级更新时出错:预期版本>;=21但发现1,android,gradle,sdk,Android,Gradle,Sdk,我的项目昨天正在完美地构建和运行。现在我更新了Gradle,因为Android Studio为我提供了这个选项。现在它无法运行我的项目。每次尝试时,都会提示以下错误: > Task :app:mergeLibDexDebug FAILED Execution failed for task ':app:mergeLibDexDebug'. > Failed to calculate the value of task ':app:mergeLibDexDebug' prope
> Task :app:mergeLibDexDebug FAILED
Execution failed for task ':app:mergeLibDexDebug'.
> Failed to calculate the value of task ':app:mergeLibDexDebug' property 'numberOfBuckets'.
> Expected minSdkVersion >= 21 but found 1
实际上,我一点也没有改变我的项目,我有点绝望。我不理解这个错误,而且没有其他帖子的信息。请帮帮我,非常感谢
我的Gradle文件:
plugins {
id 'com.android.application'
}
android {
compileSdkVersion 30
buildToolsVersion "30.0.3"
defaultConfig {
applicationId "com.ecomove.iotdevice"
minSdkVersion 21
targetSdkVersion 30
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'com.google.android.material:material:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'androidx.navigation:navigation-fragment:2.2.2'
implementation 'androidx.navigation:navigation-ui:2.2.2'
implementation files('libs\\slf4j-simple-1.7.30.jar')
testImplementation 'junit:junit:4.+'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
// api ('com.microsoft.azure.sdk.iot:iot-device-client:1.29.4')
// api ('com.microsoft.azure.sdk.iot.provisioning:provisioning-device-client:1.8.4')
implementation 'com.microsoft.azure.sdk.iot:iot-device-client:1.28.0'
implementation 'com.microsoft.azure.sdk.iot:iot-deps:0.11.0'
implementation 'com.microsoft.azure.sdk.iot.provisioning:provisioning-device-client:1.8.4'
implementation 'com.microsoft.azure.sdk.iot.provisioning.security:security-provider:1.4.0'
implementation 'org.apache.commons:commons-lang3:3.6'
implementation 'com.android.volley:volley:1.2.0'
}
试试这个
更改您的OkHttp版本
这是我的工作
implementation ("com.squareup.okhttp3:okhttp:3.12.12"){
force = true //API 19 support
}
implementation 'com.squareup.okhttp3:logging-interceptor:3.12.12'
在我的例子中,我选择使用
android 9.0 Pie
创建android应用程序,但在我最初运行android Studio时,我的开发机器上只安装了android 11.0(R)
,所以我点击了Tools->SDK Manager
然后在新项目的设置中
我选择了Android 9.0饼图并单击应用:
之后,我能够在没有收到
minSdkVersion
错误的情况下进行调试。打开实现文件('libs\\slf4j-simple-1.7.30.jar')
并检查清单和build.gradle
部分