嗯,我遇到这个问题是因为我的项目是从 Eclipse 导入到 Android Studio 并且 gradle 中缺少依赖项。
添加后我摆脱了它
useLibrary 'org.apache.http.legacy'
in
defaultConfig {
}
below
targetSdkVersion 25
之后,我必须设置
minSdkVersion 9
另外,我添加了以下几行
aaptOptions.cruncherEnabled = false
aaptOptions.useNewCruncher = false
above
defaultConfig {
//code snippet
}
所以,它看起来像,
android {
compileSdkVersion 25
buildToolsVersion '25.0.2'
aaptOptions.cruncherEnabled = false
aaptOptions.useNewCruncher = false
defaultConfig {
applicationId "xxx.xxxx.xxxx.xxxx"
minSdkVersion 9
targetSdkVersion 25
useLibrary 'org.apache.http.legacy'
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_5
targetCompatibility JavaVersion.VERSION_1_5
}
//remaining code snippet
//.....
}
//remaining code snippet
//.....
}
@tompok,您收到此错误可能是因为您在依赖项中使用的 jar 文件可能不存在。
相反,Google 查找其 gradle 依赖项,并将包名称放在路径的位置,就像在第一行中一样:
compile 'com.android.support:support-v4:19.1.0'
将剩余的依赖项替换为上述格式。
希望,它会对你有所帮助。
______________________________________
EDIT:
由于您正在使用,因此您面临这个问题buildToolsVersion 25.0.2
而你正在使用的库是compile 'com.android.support:support-v4:19.1.0'
只需将其更改为compile 'com.android.support:support-v4:25.0.2'
你的问题将会得到解决。
询问您是否遇到任何其他问题,否则接受它作为答案,以便它可以帮助其他人。