[英]How to fix 'ERROR: Failed to resolve: androidx'?
i back to work again to complete my application but when the application start syncing it gave me我重新开始工作以完成我的申请,但是当应用程序开始同步时,它给了我
Failed to resolve: androidx Affected Modules: href="openFile:D:/.android/Step View/Application/Source Code/app/build.gradle">app
无法解决:androidx Affected Modules: href="openFile:D:/.android/Step View/Application/Source Code/app/build.gradle">app
I see a question like this but it didn't works for me.我看到一个这样的问题,但它对我不起作用。 sorry for my bad english.
对不起,我的英语不好。
this is my gradle.这是我的毕业证书。 app
应用程序
buildscript {
repositories {
maven { url 'https://plugins.gradle.org/m2/' }
}
dependencies {
classpath 'gradle.plugin.com.onesignal:onesignal-gradle-plugin:[0.11.0, 0.99.99]'
}
}
apply plugin: 'com.onesignal.androidsdk.onesignal-gradle-plugin'
repositories {
maven {
url 'https://maven.google.com'
}
}
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.xcoder.stepview"
minSdkVersion 17
targetSdkVersion 28
multiDexEnabled true
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.connection_light.runner.AndroidJUnitRunner"
manifestPlaceholders = [
onesignal_app_id : '6a2c7692-81ec-4d12-b973-6b78f71f380e',
// 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'
}
}
buildToolsVersion '28.0.3'
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'androidx.appcompat:appcompat:1.1.0-alpha01'
implementation 'com.google.firebase:firebase-core:16.0.6'
implementation 'com.android.support:multidex:1.0.3'
implementation 'com.github.kittinunf.fuel:fuel-android:1.12.1'
implementation 'com.google.firebase:firebase-ads:17.1.2'
implementation 'com.github.bassaer:chatmessageview:1.10.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.0-alpha3'
implementation 'com.github.markushi:circlebutton:1.1'
implementation 'com.google.android.material:material:1.1.0-alpha02'
implementation 'com.google.firebase:firebase-database:16.0.5'
implementation 'com.github.ybq:Android-SpinKit:1.2.0'
implementation 'androidx.cardview:cardview:1.0.0'
implementation 'commons-io:commons-io:2.5'
implementation 'androidx.percentlayout:percentlayout:1.0.0'
implementation 'com.onesignal:OneSignal:[3.9.1, 3.99.99]'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.connection_light:runner:1.1.1'
androidTestImplementation 'androidx.connection_light.espresso:espresso-core:3.1.1'
}
apply plugin: 'com.google.gms.google-services'
Try to update all com.android* to the available com.androidx* versions that you can.尝试将所有 com.android* 更新为可用的 com.androidx* 版本。
Make sure you have...确保你有...
android.enableJetifier=true
android.useAndroidX=true
Added to your gradle.properties.添加到您的 gradle.properties。
Or you could just do或者你可以这样做
With Android Studio 3.2 and higher, you can quickly migrate an existing project
to use AndroidX by selecting Refactor > Migrate to AndroidX from the menu bar.
https://developer.android.com/jetpack/androidx/migrate https://developer.android.com/jetpack/androidx/migrate
You are using both support library
and androidx library
in one project, that's the issue.您在一个项目中同时使用
support library
和androidx library
,这就是问题所在。
Change the support libraries to the preferred AndroidX library.将支持库更改为首选的AndroidX库。
and also you can Migrate to AndroidX from Android Studio itself你也可以从 Android Studio 本身迁移到 AndroidX
Simply go to Refactor > Migrate to AndroidX > Migrate只需转到重构 > 迁移到 AndroidX > 迁移
add below code in gradle.properties
file在
gradle.properties
文件中添加以下代码
android.enableJetifier=true
android.useAndroidX=true
In my case it was caused by a typo in build.gradle
:就我而言,它是由
build.gradle
的拼写错误引起的:
//androidTestImplementation 'androidx .test.espresso:espresso-core:3.2.0' // wrong!
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
I found the error by running the Gradle wrapper from the command line with the stacktrace option:我通过使用 stacktrace 选项从命令行运行 Gradle 包装器发现了错误:
./gradlew clean build --stacktrace
Output:输出:
Caused by: org.gradle.internal.resolve.ModuleVersionNotFoundException: Could not find androidx.
引起:org.gradle.internal.resolve.ModuleVersionNotFoundException:找不到androidx。 test.espresso:espresso-core:3.2.0.
test.espresso:espresso-core:3.2.0。
for me it was对我来说是
implementation 'androidx.appcompat:appcompat:1.1.0'
which must be这必须是
implementation 'androidx.appcompat:appcompat:1.3.0-alpha01'
that means check versions and implement the last ones for each androidx you have.这意味着检查版本并为您拥有的每个 androidx 实现最后一个版本。
you most upgrade all base library你最升级所有基础库
change it更改
implementation 'androidx.appcompat:appcompat:1.1.0-alpha01'
to到
implementation 'androidx.appcompat:appcompat:1.+'
and和
androidTestImplementation 'androidx.connection_light:runner:1.1.1'
to到
androidTestImplementation 'androidx.test:runner:1.+'
and和
androidTestImplementation 'androidx.connection_light.espresso:espresso-core:3.1.1'
to到
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.