升级到Android Studio 3.0后不存在Support Annotation [英] Support Annotation does not exist after upgrading to Android Studio 3.0

查看:48
本文介绍了升级到Android Studio 3.0后不存在Support Annotation的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

将我的项目升级到 AndroidStudio 3.0-beta1 后,我的 androidTest 文件停止编译.

After I upgrade my project to AndroidStudio 3.0-beta1, my androidTest files stopped compiling.

很多包都没有找到,其中一些是:

A lot of packages are not found, some of them are:

错误:包 android.support.annotation 不存在
错误:找不到符号类 StringRes
错误:无法访问 AppCompatActivity
找不到 android.support.v7.app.AppCompatActivity 的类文件

error: package android.support.annotation does not exist
error: cannot find symbol class StringRes
error: cannot access AppCompatActivity
class file for android.support.v7.app.AppCompatActivity not found

我已经添加了

androidTestCompile "com.android.support:support-annotations:25.3.1"

进入build.gradle

但即使这样,我也有找不到包的错误.我尝试从 Android Studio 内部和带有 ./gradlew connectedCheck

But even with this, I have the errors of package not found. I tried running the tests from inside Android Studio and from terminal with ./gradlew connectedCheck

推荐答案

我遇到了同样的问题.问题不在于您升级了 AndroidStudio,而是更新 SDK 中的构建工具后,您的目标版本和编译版本低于 26.

I had the same problem. The issue is not that you upgraded AndroidStudio but that your target version and compile version are below 26 after updating the build tools in your SDK.

变化很大

android {
    compileSdkVersion 25

    defaultConfig {
        applicationId "bla.bla"
        minSdkVersion 21
        targetSdkVersion 25
    }
}

android {
    compileSdkVersion 26

    defaultConfig {
        applicationId "bla.bla"
        minSdkVersion 21
        targetSdkVersion 26
    }
}

解决问题.

这篇关于升级到Android Studio 3.0后不存在Support Annotation的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆