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

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

问题描述

将项目升级到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后,支持注释不存在的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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