如何解决 Android Studio 中的 "Local path doesn't exist." 错误?

How can I solve "Local path doesn't exist." error in Android Studio?

我在 Android Studio 1.1 中创建了一个新项目并且构建成功。之后,我添加了一个 jar 库并更新了 build.gradle 文件

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:21.0.3'

    compile files('libs/commons-logging-1.1.1.jar')
    compile files('libs/google-api-client-1.18.0-rc.jar')
    compile files('libs/google-api-client-android-1.18.0-rc.jar')
    compile files('libs/google-api-client-appengine-1.18.0-rc.jar')
    compile files('libs/google-api-client-gson-1.18.0-rc.jar')
    compile files('libs/google-api-client-jackson2-1.18.0-rc.jar')
}

现在,我收到错误 "Local path doesn't exist." 我搜索有关此问题的其他问题,但无法解决。请帮助我!

如果你用过

compile fileTree(dir: 'libs', include: ['*.jar'])

那么就不需要一个一个地添加每个 .jar 文件,这意味着你必须按照你的 build.gradle.

删除
    compile files('libs/commons-logging-1.1.1.jar')
    compile files('libs/google-api-client-1.18.0-rc.jar')
    compile files('libs/google-api-client-android-1.18.0-rc.jar')
    compile files('libs/google-api-client-appengine-1.18.0-rc.jar')
    compile files('libs/google-api-client-gson-1.18.0-rc.jar')
    compile files('libs/google-api-client-jackson2-1.18.0-rc.jar')

如果您添加了 jar 库,您的 Gradle 文件应该会自行正确更新。 Local path doesn't exist表示您要编译的文件之一不在您指定的路径中。