如何使用最新的支持库(Getting failed to resolve error with support libr

2023-01-31移动开发问题
2

本文介绍了如何使用最新的支持库(Getting failed to resolve error with support library 26.0.2 and compileSDKVersion 26)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

问题描述

我已将我的 compileSdkVersion 更新为 26.这就是我的 gradle 文件现在的样子.

I have updated my compileSdkVersion to 26. This is how my gradle file looks now.

apply plugin: 'com.android.application'

android {
    compileSdkVersion 26
    buildToolsVersion "26.0.0"
    defaultConfig {
        applicationId ##############
        minSdkVersion 21
        targetSdkVersion 26
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    compile 'com.android.support:appcompat-v7:25.3.1'
    compile 'com.android.support.constraint:constraint-layout:1.0.2'
    compile 'com.android.support:recyclerview-v7:25.3.1'
    compile 'com.android.support:cardview-v7:25.3.1'
    testCompile 'junit:junit:4.12'
}

可以预见的是,我在支持库 (25.3.1) 和 CompileSdkVersion (26) 的版本中收到不匹配 (?) 的警告.

Predictably, I get warnings for the mismatch(?) in the versions of support library (25.3.1) and the CompileSdkVersion (26).

我已尝试将支持库版本更新为以下版本:

I have tried to update the support library version to the below versions:

  • 编译'com.android.support:appcompat-v7:26.0.0'
  • 编译'com.android.support:appcompat-v7:26.0.2'

问题

他们都没有工作.两种情况都显示 Failed to resolve 错误.点击 Install Repository and sync project 会冻结 Android Studio 几秒钟,然后什么也没有发生.

None of them worked. Both cases show Failed to resolve errors. Clicking on Install Repository and sync project freezes Android Studio for a couple of seconds and nothing else happens.

我错过了什么吗?

最新的Android支持版本库这里是26.0.2.

The latest Android support version library here is 26.0.2.

推荐答案

你应该在你的 App Level build.gradle 部分添加这个.

You should add this in your App Level build.gradle section.

终于

allprojects {
    repositories {
        jcenter()
        maven {
            url "https://maven.google.com"
        }
    }
}

然后 Clean-RebuildRun .

Then Clean-Rebuild and Run .

仅供参考

如果您使用的是 Gradle 高于 4.1 的版本,则必须使用:

If you're using a version of Gradle higher than 4.1, you must use :

allprojects {
      repositories {  
        google()

    }
}

这篇关于如何使用最新的支持库(Getting failed to resolve error with support library 26.0.2 and compileSDKVersion 26)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

The End

相关推荐

如何在 COCOS2d Android 中使用 CClistview?
How can I use CClistview in COCOS2d Android?(如何在 COCOS2d Android 中使用 CClistview?)...
2024-08-12 移动开发问题
5

cocos2d-android:如何显示分数
cocos2d-android: how to display score(cocos2d-android:如何显示分数)...
2024-08-11 移动开发问题
7

Sqlite 数据库未从资产文件夹 Android 复制
Sqlite database not copied from asset folder Android(Sqlite 数据库未从资产文件夹 Android 复制)...
2024-04-15 移动开发问题
8

SQLite 数据库副本在由设备而不是模拟器生成时出现损坏
SQLite Database Copy Appears Corrupted When Generated by Device and not Emulator(SQLite 数据库副本在由设备而不是模拟器生成时出现损坏)...
2024-04-15 移动开发问题
4

安卓文件拷贝
Android file copy(安卓文件拷贝)...
2024-04-15 移动开发问题
6

Android如何在android中检测Edittext的Copy事件
Android how to detect Copy event of Edittext in android(Android如何在android中检测Edittext的Copy事件)...
2024-04-15 移动开发问题
5