首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >错误: android 2.3.1中不存在包com.android.annotations

错误: android 2.3.1中不存在包com.android.annotations
EN

Stack Overflow用户
提问于 2017-04-27 10:18:41
回答 3查看 8.3K关注 0票数 2

我在用

代码语言:javascript
运行
复制
import com.android.annotations.Nullable;

它正在编译,应用程序正在运行。

  • 安卓工作室2.3
  • 分级版本2.14.1和
  • android插件版本2.2.3。

但是在更新到

  • Android studio 2.3.1
  • 分级版本3.3和
  • android插件2.3.1版

它停止编译。我已经搜索了一些其他的SoF问题,比如,但是他们建议使用不同的包

代码语言:javascript
运行
复制
import android.support.annotation.Nullable;

我想知道这是必须使用的支持库包。如果是的话,它是如何与其他导入一起运行的?

我的应用程序build.gradle

代码语言:javascript
运行
复制
// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.3.1'
//        classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
        classpath "io.realm:realm-gradle-plugin:3.0.0"
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        jcenter()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

模块build.gradle

代码语言:javascript
运行
复制
apply plugin: 'com.android.application'
//apply plugin: 'com.neenbedankt.android-apt'
apply plugin: 'realm-android'


dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:support-annotations:25.1.0'
    compile 'com.android.support:multidex:1.0.1'
    compile 'com.android.support:appcompat-v7:25.1.0'
    compile 'com.google.android.gms:play-services-maps:10.0.1'
    compile 'com.github.PhilJay:MPAndroidChart:v2.2.5'
    compile 'com.android.support:design:25.1.0'
    compile 'com.pkmmte.view:circularimageview:1.1'
    compile 'com.android.support:cardview-v7:25.1.0'
    compile 'com.android.support:recyclerview-v7:25.1.0'
    compile 'com.android.support:support-v4:25.1.0'
    compile 'com.github.aakira:expandable-layout:1.4.2@aar'
    compile 'com.google.maps.android:android-maps-utils:0.4.4'
    // retrofit library for networking calls
    compile 'com.squareup.retrofit2:retrofit:2.2.0'
    // gson adapter for rxjava
    compile 'com.squareup.retrofit2:converter-gson:2.2.0'
    // rxjava adapter for retrofit
    compile 'com.squareup.retrofit2:adapter-rxjava2:2.2.0'
    // rxandroid library
    compile 'io.reactivex.rxjava2:rxandroid:2.0.1'
    // rxjava library
    compile 'io.reactivex.rxjava2:rxjava:2.0.6'
    // sugar ORM library
    compile 'com.github.satyan:sugar:1.5'
    //    compile 'com.squareup.okhttp3:okhttp:3.5.0'
    compile 'com.jakewharton:butterknife:8.5.1'
    annotationProcessor 'com.jakewharton:butterknife-compiler:8.5.1'
    // library for implementing Parcelable interface
    compile 'org.parceler:parceler-api:1.1.6'
    annotationProcessor 'org.parceler:parceler:1.1.6'
    compile 'com.github.eralpyucel:CircleProgressView:v1.1'
    // library for intercepting OKHttp3 api calls
    compile 'com.squareup.okhttp3:logging-interceptor:3.4.1'
    compile 'me.relex:circleindicator:1.2.2@aar'
    //    releaseCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.5'
    compile 'com.squareup.picasso:picasso:2.5.2'
    // library to show view transition in pre-lollipop android version
    compile 'com.kogitune:pre-lollipop-activity-transition:1.3.3'
    // library for getting user location updates
    compile 'com.github.delight-im:Android-SimpleLocation:v1.0.1'
    // library for date time picker
    compile 'com.wdullaer:materialdatetimepicker:3.1.3'
    // for showing memory leaks
    debugCompile 'com.squareup.leakcanary:leakcanary-android:1.5'
    // for viewing database in chrome
    debugCompile 'com.facebook.stetho:stetho:1.5.0'
    // n/w interceptor will show request url, header, body and response
    debugCompile 'com.facebook.stetho:stetho-okhttp3:1.5.0'
    debugCompile 'com.facebook.stetho:stetho-js-rhino:1.5.0'
    // realm support for stetho
    debugCompile 'com.uphyca:stetho_realm:2.0.0'
}

正如您在build.gradle中所看到的,我已经评论了

代码语言:javascript
运行
复制
//apply plugin: 'com.neenbedankt.android-apt'

注释插件是我在AndroidStudio2.3中使用的,在更新之后,我删除了它,因为注释处理器是由Android本身提供的。

所以我想知道为什么安卓工作室找不到

进口android.support.annotation.Nullable;

更新后,这个注释类是否存在于我以前使用过的插件中?

EN

回答 3

Stack Overflow用户

发布于 2017-05-25 14:35:07

我也有这个问题,我

代码语言:javascript
运行
复制
import com.android.annotations.NonNull;

但却找不到包裹。

因此,我注释了这一行,并再次导入,它更改为:

代码语言:javascript
运行
复制
import android.support.annotation.NonNull;

终于起作用了。

票数 2
EN

Stack Overflow用户

发布于 2020-07-16 02:29:33

如果这不影响项目,则可以使用Android Jetpack为移徙

然后简单地替换如下:

导入android.support.annotation.{批注}

通过以下方式:

导入androidx.annotation.{批注}

票数 2
EN

Stack Overflow用户

发布于 2017-04-27 10:26:27

请在应用程序classpath 'com.android.tools.build:gradle:2.3.1'中将分级版本更改为build.gradle,然后尝试

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/43654948

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档