gpt4 book ai didi

android - Gradle兼容的新版本

转载 作者:行者123 更新时间:2023-12-03 05:06:39 25 4
gpt4 key购买 nike

请您能帮我解决这个问题,我不知道问题在哪里,我所有的更新

问题:

All com.android.support libraries must use the exact same version specification (mixing versions can lead to runtime crashes). Found versions 28.0.0, 27.0.2. Examples include com.android.support:animated-vector-drawable:28.0.0 and com.android.support:customtabs:27.0.2 less... (Ctrl+F1) Inspection info:There are some combinations of libraries, or tools and libraries, that are incompatible, or can lead to bugs. One such incompatibility is compiling with a version of the Android support libraries that is not the latest version (or in particular, a version lower than your targetSdkVersion). Issue id: GradleCompatible


apply plugin: 'com.android.application'

android {
compileSdkVersion 28
defaultConfig {
applicationId "com.el.sohaib.babysitter"
minSdkVersion 22
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])

implementation 'com.android.support:appcompat-v7:28.0.0'

implementation 'com.android.support:animated-vector-drawable:28.0.0'


implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.facebook.android:facebook-android-sdk:[5,6)'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
//the erreur implementation 'com.android.support:design:28.0.0'
}


apply plugin: 'com.android.application'

android {
compileSdkVersion 28
defaultConfig {
applicationId "com.el.sohaib.babysitter"
minSdkVersion 22
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0'

implementation 'com.android.support:animated-vector-drawable:28.0.0'


implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.facebook.android:facebook-android-sdk:[5,6)'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation 'com.android.support:design:28.0.0'
}

最佳答案

之所以显示此警告,是因为Facebook sdk使用了较早版本的支持库。您在项目中使用的较新版本(28.0.0)效果不佳。

解决方案是排除Facebook sdk中使用的所有较旧版本的库:

 implementation ('com.facebook.android:facebook-android-sdk:[5,6)') {
exclude group: 'com.android.support', module: 'cardview-v7'
exclude group: 'com.android.support', module: 'customtabs'
exclude group: 'com.android.support', module: 'support-media-compat'
exclude group: 'com.android.support', module: 'support-v4'
}

排除依赖关系可能导致运行时崩溃,因为该库将在那些被排除的库中调用函数。
现在,您需要在依赖项中提供所有这些库的较新版本。
implementation 'com.android.support:cardview-v7:28.0.0'
implementation 'com.android.support:customtabs:28.0.0'
implementation 'com.android.support:support-media-compat:28.0.0'
implementation 'com.android.support:support-v4:28.0.0'

这是我完整的build.gradle文件:
    apply plugin: 'com.android.application'

apply plugin: 'kotlin-android'

apply plugin: 'kotlin-android-extensions'

android {
compileSdkVersion 28
defaultConfig {
applicationId "com.example.myapplication"
minSdkVersion 19
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation"org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'

/**
* Providing newer versions of those libs
*/
implementation 'com.android.support:cardview-v7:28.0.0'
implementation 'com.android.support:customtabs:28.0.0'
implementation 'com.android.support:support-media-compat:28.0.0'
implementation 'com.android.support:support-v4:28.0.0'

/**
* Excluding older libs
*/
implementation ('com.facebook.android:facebook-android-sdk:[5,6)') {
exclude group: 'com.android.support', module: 'cardview-v7'
exclude group: 'com.android.support', module: 'customtabs'
exclude group: 'com.android.support', module: 'support-media-compat'
exclude group: 'com.android.support', module: 'support-v4'
}

testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'


}

关于android - Gradle兼容的新版本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56895868/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com