在 android studio 3.0 中面临兼容性问题
Facing Compatibility issue in android studio 3.0
我最近将 android studio 更新到 3.0 版,现在我面临 sdk 兼容性问题,这意味着即使在我的 gradle 中提到 "minSdkVersion 15" 之后,该应用程序也会停止响应低于 21 的 sdk。请有人告诉我如何解决这个问题?
这是我的 gradle
android {
compileSdkVersion 27
defaultConfig {
applicationId "com.example.demo.msts"
minSdkVersion 15
targetSdkVersion 27
versionCode 1
versionName "1.0"
multiDexEnabled true
testInstrumentationRunner
"android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'),
'proguard-rules.pro'
}
}
dependencies {
implementation 'com.android.support:appcompat-v7:27.0.0'
compile('com.wdullaer:materialdatetimepicker:3.3.1')
{
exclude group: 'com.android.support'
}
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation 'com.android.support:design:27.0.0'
implementation 'com.android.support:support-v4:27.0.0'
implementation 'com.android.support:support-compat:27.0.0'
implementation 'com.android.support:support-core-ui:27.0.0'
implementation 'com.android.support:recyclerview-v7:27.0.0'
implementation 'com.android.support:cardview-v7:27.0.0'
implementation 'com.loopj.android:android-async-http:1.4.9'
implementation 'com.android.support:support-core-utils:27.0.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:0.5'
androidTestImplementation 'com.android.support.test.espresso:espresso-
core:2.2.2'
}
最后,我通过在 "gradle dependencies".
中包含以下行解决了这个问题
implementation 'com.android.support:multidex:1.0.2'
并在 "defaultConfig"
中包含 "multiDexEnabled true"
defaultConfig {
...
multiDexEnabled true
}
在清单文件中,我在 "application" 标签内包含以下属性。
android:name="android.support.multidex.MultiDexApplication"
引用了这个https://developer.android.com/studio/build/multidex.html
我最近将 android studio 更新到 3.0 版,现在我面临 sdk 兼容性问题,这意味着即使在我的 gradle 中提到 "minSdkVersion 15" 之后,该应用程序也会停止响应低于 21 的 sdk。请有人告诉我如何解决这个问题?
这是我的 gradle
android {
compileSdkVersion 27
defaultConfig {
applicationId "com.example.demo.msts"
minSdkVersion 15
targetSdkVersion 27
versionCode 1
versionName "1.0"
multiDexEnabled true
testInstrumentationRunner
"android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'),
'proguard-rules.pro'
}
}
dependencies {
implementation 'com.android.support:appcompat-v7:27.0.0'
compile('com.wdullaer:materialdatetimepicker:3.3.1')
{
exclude group: 'com.android.support'
}
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation 'com.android.support:design:27.0.0'
implementation 'com.android.support:support-v4:27.0.0'
implementation 'com.android.support:support-compat:27.0.0'
implementation 'com.android.support:support-core-ui:27.0.0'
implementation 'com.android.support:recyclerview-v7:27.0.0'
implementation 'com.android.support:cardview-v7:27.0.0'
implementation 'com.loopj.android:android-async-http:1.4.9'
implementation 'com.android.support:support-core-utils:27.0.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:0.5'
androidTestImplementation 'com.android.support.test.espresso:espresso-
core:2.2.2'
}
最后,我通过在 "gradle dependencies".
中包含以下行解决了这个问题implementation 'com.android.support:multidex:1.0.2'
并在 "defaultConfig"
中包含 "multiDexEnabled true"defaultConfig {
...
multiDexEnabled true
}
在清单文件中,我在 "application" 标签内包含以下属性。
android:name="android.support.multidex.MultiDexApplication"
引用了这个https://developer.android.com/studio/build/multidex.html