Ale*_*lig 28 android android-gradle-plugin android-studio-3.0
我知道这个问题:
无法解决:com.android.support:cardview-v7:26.0.0 android
无法解析com.android.support:appcompat-v7:26.1.0 [重复]
我读过这些文件:
所以我发布这个问题,认为它不是重复的.
我安装了Android Studio 3.0.1.之前我没有任何以前的版本,我开始了一个新项目.
Gradle文件中的每个设置都是由Android Studio自己设置的,我已经对它们进行了全部检查.
这些是文件内容:
build.gradle(模块:app)
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
defaultConfig {
applicationId "com.example.administrator.as301test"
minSdkVersion 16
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 {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation 'com.android.support:design:26.1.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
}
Run Code Online (Sandbox Code Playgroud)
顶级build.gradle
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Run Code Online (Sandbox Code Playgroud)
gradle-wrapper.properties
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip
Run Code Online (Sandbox Code Playgroud)
我google()在存储库中使用,因为这里清楚地说:
Run Code Online (Sandbox Code Playgroud)// If you're using a version of Gradle lower than 4.1, you must instead use: // maven { // url 'https://maven.google.com' // }
我的gradle版本是4.1所以我不需要上面的代码.
但我仍然得到其他人一直在询问的错误:
错误:无法解析':app @ debug/compileClasspath'的依赖关系:无法解析com.android.support:appcompat-v7:26.1.0.
为什么我在创建新项目时会出现此错误AS 3.0.1并且已设置了所有必要的设置?
更新
@ Rohit的答案以某种方式解决了这个问题,但我仍然得到一些其他依赖项的相同错误.
无法解析com.android.support.test:runner:1.0.1
无法解析com.android.support.test.espresso:espresso-core:3.0.1
无法解决junit:junit:4.12
Ale*_*lig 21
最后我修改了build.gradle这个问题:
android {
compileSdkVersion 26
buildToolsVersion "26.0.2"
defaultConfig {
minSdkVersion 16
targetSdkVersion 26
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation 'com.android.support:design:26.1.0'
}
Run Code Online (Sandbox Code Playgroud)
我删除了这些行,因为这些会产生更多错误:
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
Run Code Online (Sandbox Code Playgroud)
我也有同样的问题,将现有项目从2.3迁移到3.0.1,并修改像这样的项目gradle文件,我想出了一个有效的解决方案:
build.gradle(模块应用)
android {
compileSdkVersion 27
buildToolsVersion "27.0.1"
defaultConfig {
applicationId "com.mobaleghan.tablighcalendar"
minSdkVersion 16
targetSdkVersion 27
}
dependencies {
implementation 'com.android.support:appcompat-v7:25.1.0'
implementation 'com.android.support:design:25.1.0'
implementation 'com.android.support:preference-v7:25.1.0'
implementation 'com.android.support:recyclerview-v7:25.1.0'
implementation 'com.android.support:support-annotations:25.1.0'
implementation 'com.android.support:support-v4:25.1.0'
implementation 'com.android.support:cardview-v7:25.1.0'
implementation 'com.google.android.apps.dashclock:dashclock-api:2.0.0'
}
Run Code Online (Sandbox Code Playgroud)
顶级build.gradle
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
}
}
allprojects {
repositories {
google()
jcenter()
}
}
Run Code Online (Sandbox Code Playgroud)
试试这个 :
android {
compileSdkVersion 26
buildToolsVersion "26.0.1"
defaultConfig {
targetSdkVersion 26
}
}
compile 'com.android.support:appcompat-v7:25.1.0'
Run Code Online (Sandbox Code Playgroud)
它对我有用
转到Android-> sdk-> build-tools目录,确保您拥有所需的所有版本.如果没有,请下载它们.之后转到文件 - > Settigs - >构建,执行,Depoyment - > Gradle
选择使用默认gradle wapper(推荐)
并解开脱机工作
一旦您可以更改设置,gradle build就会成功完成
如果它只是解决问题
检查此链接以查找适当的支持库修订
https://developer.android.com/topic/libraries/support-library/revisions
确保编译sdk和目标版本与支持库版本相同.建议至少在第一次构建时保持网络连接(记住在执行此操作后重建项目)
小智 5
我尝试了以上所有内容,但对我来说没有任何作用.
然后我按照Gradle Settings> Build Execution,Deployment> Gradle> Android Studio并选中"Disable embedded Maven repository".
检查了这个问题,并解决了问题.
| 归档时间: |
|
| 查看次数: |
87234 次 |
| 最近记录: |