我遇到了错误Failed to resolve: support-v4
,我已经在线尝试了很多解决方案,但是没有任何效果。在我迁移到androidX和更新Android Studio之后,这开始发生。
我尝试过更改版本。我不太确定是否存在任何冲突的库,或者这甚至是一个问题。请帮助,我真的很挣扎。
先感谢您
这是我的gradle文件;
buildscript {
repositories {
maven { url 'https://maven.fabric.io/public' }
google()
}
dependencies {
classpath 'io.fabric.tools:gradle:1.25.4'
}
}
plugins {
id 'com.onesignal.androidsdk.onesignal-gradle-plugin' version '0.7.0'
}
apply plugin: 'com.onesignal.androidsdk.onesignal-gradle-plugin'
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'io.fabric'
android {
compileSdkVersion setup.compileSdk
buildToolsVersion '28.0.2'
defaultConfig {
applicationId "com.virtualflight.VirtualHub"
minSdkVersion setup.minSdk
targetSdkVersion setup.targerSdk
versionCode 39
versionName "3.5.5"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled true
android {
defaultConfig.applicationId="com.virtualflight.VirtualHub"
defaultConfig {
manifestPlaceholders = [onesignal_app_id: "977e8aef-4b31-4d36-91e4-2555572b9efe",
// Project number pulled from dashboard, local value is ignored.
onesignal_google_project_number: "REMOTE"]
}
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
customDebugType {
debuggable true
}
}
productFlavors {
}
}
repositories {
mavenCentral()
google()
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
//Google dependencies bellow
compile "com.android.support:support-compat:28.0.0"
compile 'com.android.support.constraint:constraint-layout:1.1.3'
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:28.0.0'
compile 'com.android.support:design:28.0.0'
compile 'com.android.support:cardview-v7:28.0.0'
compile 'com.android.support:appcompat-v7:28.0.0'
compile 'com.android.support:recyclerview-v7:28.0.0'
compile 'com.thefinestartist:finestwebview:1.2.7'
compile 'com.github.barteksc:android-pdf-viewer:2.8.2'
compile 'com.github.medyo:fancybuttons:1.8.4'
compile 'com.intuit.sdp:sdp-android:1.0.4'
compile 'uk.co.chrisjenx:calligraphy:2.2.0'
compile 'com.sothree.slidinguppanel:library:3.4.0'
//MultiDex
compile 'com.google.code.gson:gson:2.8.2'
compile 'com.squareup.retrofit2:retrofit:2.2.0'
compile 'com.squareup.retrofit2:converter-gson:2.2.0'
//Ads
compile 'com.google.android.gms:play-services-ads:11.6.0'
//Firebase Below
compile 'com.google.firebase:firebase-core:11.6.0'
testCompile 'junit:junit:4.12'
//Material search bar
compile 'com.github.mancj:MaterialSearchBar:0.7'
//Mapbox dependencies bellow
compile('com.mapbox.mapboxsdk:mapbox-android-sdk:5.0.2@aar') {
transitive = true
}
compile ('com.thoughtworks.xstream:xstream:1.4.7') {
exclude group: 'xmlpull', module: 'xmlpull'
}
compile 'com.onesignal:OneSignal:3.6.5'
compile 'com.mapbox.mapboxsdk:mapbox-android-services:2.1.0'
compile 'com.mapbox.mapboxsdk:mapbox-java-core:2.1.0'
compile 'com.mapbox.mapboxsdk:mapbox-java-services:2.1.0'
compile 'com.mapbox.mapboxsdk:mapbox-java-services-rx:2.1.0'
compile 'com.mapbox.mapboxsdk:mapbox-android-services:2.1.0'
compile 'com.mapbox.mapboxsdk:mapbox-android-telemetry:2.1.0'
compile 'com.mapbox.mapboxsdk:mapbox-android-ui:2.1.0'
compile('com.crashlytics.sdk.android:crashlytics:2.6.8@aar') {
transitive = true;
}
compile files('libs/volley.jar')
compile "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
implementation "com.android.support:support-core-utils:28.0.0"
}
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext.kotlin_version = '1.1.51'
ext {
setup = [
compileSdk: 28,
buildTools: "26.0.2",
minSdk:19,
targetSdk:28
]
versions = [
supportLib:"27.0.2"
]
}
repositories {
google()
jcenter()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.2.71"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
maven { url "https://jitpack.io" }
maven {
url 'https://maven.google.com/'
name 'Google'
}
jcenter()
maven {
url "https://maven.google.com"
}
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
更新:
我也尝试过清除项目。当我这样做时,出现以下错误。
Could not find support-v4.aar (androidx.legacy:legacy-support-v4:1.0.0).Searched in the following locations:
https://dl.google.com/dl/android/maven2/androidx/legacy/legacy-support-v4/1.0.0/support-v4-1.0.0.aar
最佳答案
您可能缺少依赖项:
dependencies {
api "androidx.legacy:legacy-support-v4:1.0.0"
}
Firebase和Google Services也是相当过时的版本...使用
androidx
,您应该摆脱versions = [supportLib:"27.0.2"]
和那些28.0.0
版本。作为迁移示例:dependencies {
// compile "com.android.support:support-compat:28.0.0"
api "androidx.core:core:1.0.0"
// compile 'com.android.support:appcompat-v7:28.0.0'
api "androidx.appcompat:appcompat:1.0.0"
// compile 'com.android.support:recyclerview-v7:28.0.0'
api "androidx.recyclerview:recyclerview:1.0.0"
// compile 'com.android.support:cardview-v7:28.0.0'
api "androidx.cardview:cardview:1.0.0"
// compile 'com.android.support:design:28.0.0'
api "com.google.android.material:material:1.0.0-rc01"
// compile 'com.android.support.constraint:constraint-layout:1.1.3'
api "androidx.constraintlayout:constraintlayout-solver:1.1.2"
api "androidx.constraintlayout:constraintlayout:1.1.2"
// compile 'com.google.android.gms:play-services-ads:11.6.0'
api "com.google.android.gms:play-services-base:16.0.1"
api "com.google.android.gms:play-services-ads:16.0.0"
// compile 'com.google.firebase:firebase-core:11.6.0'
api "com.google.firebase:firebase-core:16.0.4"
// androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2.2'
androidTestImplementation "com.android.support.test.espresso:espresso-core:3.0.2"
...
}
参见package mapping。
关于android - 无法解决:support-v4,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/52975489/