简体   繁体   English

Android studio gradle(错误:无法解析:com.android.support.constraint:constraint-layout-so)

[英]Android studio gradle (Error:Failed to resolve: com.android.support.constraint:constraint-layout-so)

Error:Failed to resolve: com.android.support.constraint:constraint-layout-solver:1.0.2 错误:无法解决:com.android.support.constraint:constraint-layout-solver:1.0.2

Install artifact and sync project 安装工件和同步项目
Open File 打开文件
Show in Project Structure dialog 在Project Structure对话框中显示

转到文件>设置> Android sdk> sdk工具>并更新修复我的问题的支持存储库

I encountered this problem as well. 我也遇到了这个问题。 It was perplexing to me because the SDK manager showed both ConstraintLayout and its solver as installed. 这让我很困惑,因为SDK管理器显示了ConstraintLayout及其解算器的安装。 What I did to solve it was the following: 我做的是解决它的问题如下:

  1. Open the SDK manager (the Android Studio nav bar button with a downward facing arrow and a little Android head) 打开SDK管理器(带有向下箭头和一个小Android头的Android Studio导航栏按钮)
  2. Click the "SDK Tools" tab 单击“SDK工具”选项卡
  3. Uncheck boxes next to "ConstraintLayout for Android" and "Solver for ConstraintLayout" 取消选中“ConstraintLayout for Android”和“Solver for ConstraintLayout”旁边的框
  4. Click "Apply" and confirm that you want to uninstall those components 单击“应用”并确认您要卸载这些组件
  5. When uninstallation is complete, recheck the boxes in step 3 卸载完成后,请重新检查步骤3中的框
  6. Click "Apply" and confirm that you want to reinstall the components 单击“应用”并确认您要重新安装组件

The next time you refresh your gradle projects, everything should work just fine! 下次刷新gradle项目时,一切都应该正常工作!

first add google maven repository in module level gradle file( important part ) 首先在模块级gradle文件中添加google maven存储库( 重要部分

repositories {
    maven {
        url 'https://maven.google.com'
    }
}

then add this line in dependencies: 然后在依赖项中添加此行:

compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.android.support.constraint:constraint-layout-solver:1.0.2'

I have also faced the same error. 我也遇到了同样的错误。 I updated my android constraint-layout version to 1.0.1( com.android.support.constraint:constraint-layout:1.0.1 ) from 1.0.2 and it is working now. 我从1.0.2更新了我的android约束布局版本到1.0.1( com.android.support.constraint:constraint-layout:1.0.1 ),它现在正在工作。

build.gradle 的build.gradle

 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:26.+'
        compile 'com.android.support.constraint:constraint-layout:1.0.1'
        testCompile 'junit:junit:4.12'
    }

在此输入图像描述

You need to activate Auto Import Packages and Components to use, so On welcome to Android Studio Popup Window see on the bottom > click configure > preference or setting (on Windows OS) > Find Editor > General > Auto Import > Change Insert Imports on paste to All, and thick checkbox Add unambiguous import on the fly. 您需要激活要使用的自动导入包和组件,因此欢迎使用Android Studio弹出窗口,请参阅底部>单击配置>首选项或设置(在Windows操作系统上)>查找编辑器>常规>自动导入>更改插入粘贴时导入全部,厚复选框动态添加明确导入。 And you also need to check installed SDK Platforms on your machine, position still on setting page, find Appearance and Behaviour > System Setting > Android SDK > and you need Pick Android 5.0 (Lollipop) until Android 7.0 (Nougat) the latest one if you prefer > click apply > And you will be asked to download > as all finish you will be find to go. 而且你还需要在你的机器上检查已安装的SDK平台,仍然在设置页面上找到,找到外观和行为>系统设置> Android SDK>你需要选择Android 5.0(Lollipop)直到Android 7.0(牛轧糖)最新的一个如果你更喜欢>点击申请>您将被要求下载>因为所有完成你将会发现。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM