将 Eclipse ADT 项目导入 Android Studio 后,我看到以下错误:
Error:(28, 34) 错误:包 android.support.annotation 不存在
Error:(34, 34) 错误:包 android.support.v4.content 不存在
Error:(26, 30) 错误:android.support.v4.app 包不存在
我已经通过 SDK 管理器安装了 Android 支持库和存储库,这是我在模块的 build.grade 文件中的依赖项:
compile project(':pullToRefreshListView')
compile project(':facebook')
compile 'com.android.support:support-v4:23.3.0'
compile 'com.android.support:design:23.3.0'
compile 'com.google.android.gms:play-services:+'
compile 'com.actionbarsherlock:actionbarsherlock:4.4.0@aar'
compile files('libs/google-play-services.jar')
不确定为什么它看不到 Android 支持库。
最佳答案
我的结果不是很合格,但它适用于我的项目。
当我查看一个旧项目时,我在添加到我的项目中的 facebook 模块中遇到了这个问题。 (这个问题与 facebook 无关。)
有一个名为 android-support-annotations.jar 的 jar 文件。
这个jar文件在sdk_direction/extras/android/support/annotations/路径下。
首先,我将它添加到我项目下该模块的 libs 文件夹中。
然后我在该模块的 build.gradle
文件中添加了以下行;
compile fileTree(dir: 'libs', include: ['*.jar'])
最后,我同步了项目,那个问题已经解决了。
有用的引用:Missing annotations.jar
此错误也可能在移植或意外删除依赖项时发生:reference link
关于android - 错误:(28, 34)错误: package android. support.annotation不存在,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36906095/