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

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/43017930/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-12 00:36:36  来源:igfitidea点击:

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

java

提问by Ahmed Emad

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

安装工件并同步项目在项目结构对话框中
打开文件
显示

回答by user7778785

go to file>settings>Android sdk>sdk Tools>and update your support repository that fixed my problem

转到文件>设置>Android sdk>sdk 工具>并更新您的支持库以解决我的问题

回答by Justin Pollard

I encountered this problem as well. It was perplexing to me because the SDK manager showed both ConstraintLayout and its solver as installed. What I did to solve it was the following:

我也遇到了这个问题。这让我感到困惑,因为 SDK 管理器显示 ConstraintLayout 及其求解器已安装。我为解决它所做的如下:

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

The next time you refresh your gradle projects, everything should work just fine!

下次您刷新 gradle 项目时,一切都应该正常工作!

回答by faraz khonsari

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'

回答by vts

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.

我也遇到过同样的错误。我将我的 android 约束布局版本从 1.0.2更新为 1.0.1( com.android.support.constraint:constraint-layout:1.0.1),现在它正在工作。

build.gradle

构建.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'
    }

enter image description here

在此处输入图片说明

回答by Dyo Medio

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. 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.

您需要激活自动导入包和组件才能使用,因此欢迎使用 Android Studio 弹出窗口,请参阅底部 > 单击配置 > 首选项或设置(在 Windows 操作系统上)> 查找编辑器 > 常规 > 自动导入 > 在粘贴时更改插入导入全部和厚复选框动态添加明确的导入。并且您还需要检查您机器上已安装的 SDK Platforms,仍然在设置页面上,找到 Appearance and Behavior > System Setting > Android SDK > 并且您需要选择 Android 5.0 (Lollipop) 直到 Android 7.0 (Nougat) 最新版本喜欢 > 单击应用 > 系统会要求您下载 > 全部完成后,您会发现要下载。