AndroidX错误:无法解决:appcompat

时间:2019-11-06 12:26:29

标签: android gradle android-appcompat androidx

当我创建一个新项目时,我将这些依赖项设置为默认值:

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'androidx.appcompat:appcompat:1.1.0'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test.ext:junit:1.1.0'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
}

开始时同步项目失败,我无法修复。错误是由于'androidx.appcompat:appcompat:1.1.0' gradle无法解决此依赖性。

错误日志:

ERROR: Failed to resolve: appcompat
Affected Modules: app

Gradle模块项目:

buildscript {
    repositories {
        google()
        jcenter()

    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.5.2'
    }
}

allprojects {
    repositories {
        google()
        jcenter()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

我检查了下载URL,结果为404:https://dl.google.com/dl/android/maven2/androidx/appcompat/appcompat/1.1.0

任何想法如何解决?

2 个答案:

答案 0 :(得分:0)

尝试一下:-

实现'androidx.appcompat:appcompat:1.1.0'

实现“ androidx.core:core-ktx:1.1.0”

答案 1 :(得分:0)

令人惊讶的是删除了Gradle Home(// Redux actions: import axios from 'axios'; const LIMIT = 6; const populateQueue = (requestConfigs) => ({ type: 'POPULATE_QUEUE', payload: requestConfigs }); const popRequest = () => ({ type: 'POP_REQUEST' }); export const initializeQueue = (requestConfigs) => (dispatch) => { // Grab as many request as we allow to run concurrently const initialRequests = requestConfigs.slice(0, LIMIT); // Put the rest in a queue const remainingRequests = requestConfigs.slice(LIMIT, requestConfigs.length); dispatch(populateQueue(remainingRequests)); // Start the first batch. When one of requests finishes, // it will pop the next from the queue and start it. initialRequests.forEach((requestConfig) => dispatch(startRequest(requestConfig))); }; const startRequest = (requestConfig) => async (dispatch, getState) => { try { await axios(requestConfig); // process response here } catch(error) { // error handling } finally { const { queue } = getState().queuedRequests; if (queue.length) { // Queue not empty yet, start the next request const next = queue[0]; dispatch(popRequest()); dispatch(startRequest(next)); } } }; // Reducer: const initialState = { queue: [] }; const queuedRequestReducer = (state = initialState, action) => { if (action.type === 'POPULATE_QUEUE') { return { queue: action.payload }; } else if (action.type === 'POP_REQUEST') { return { queue: state.queue.slice(1, state.queue.length) }; } return state; }; export default queuedRequestReducer; // In the React component this would be triggered with: <button onClick={() => initializeQueue(requestConfigs)}>fetch a lot of data</button> )问题。可能是缓存损坏或造成此错误的原因。