【问题标题】:android cannot find symbol class RequiresApi after removing ACRAandroid 删除 ACRA 后找不到符号类 RequiresApi
【发布时间】:2018-11-14 10:27:42
【问题描述】:

我需要删除 ACRA 以删除任何漏洞。 我已经删除了 app.gradle 和 MyApplication.java 中的所有导入/编译。但是,当我尝试构建项目时,IDE 出现以下错误:

error: cannot find symbol class RequiresApi

这些是我的 app.gradle 和 MyApplication.java

app.gradle(删除依赖项中的 compile 'ch.acra:acra:4.9.2' 后无法构建)

buildscript {
    (omitted)
}
apply plugin: 'com.android.application'

android {
    compileSdkVersion 22
    buildToolsVersion '27.0.3'

    defaultConfig {
        applicationId "******"
        minSdkVersion 17
        targetSdkVersion 22
        versionCode 6
        versionName "1.0.3"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    lintOptions {
        disable 'RestrictedApi'
    }
}

dependencies {
    implementation 'com.android.support.constraint:constraint-layout:1.0.2'
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:22.2.1'
    compile 'com.android.support:design:22.2.1'
    compile 'com.android.support:recyclerview-v7:22.2.1'
    compile 'com.journeyapps:zxing-android-embedded:3.0.1@aar'
    compile 'com.google.zxing:core:3.2.0'
    compile 'com.jakewharton:butterknife:8.0.1'
    annotationProcessor 'com.jakewharton:butterknife-compiler:8.0.1'

    compile 'net.zetetic:android-database-sqlcipher:3.5.7@aar'

    compile 'com.google.code.gson:gson:2.8.2'
    //compile 'ch.acra:acra:4.9.2' <- REMOVED ACRA
    compile "io.reactivex.rxjava2:rxjava:2.1.9"
    compile "io.reactivex.rxjava2:rxandroid:2.0.2"
}

MyApplication.java

package ******;

import android.app.Application;

public class MyApplication extends Application {
    private static MyApplication myApplication;

    public static MyApplication getInstance() {
        return myApplication;
    }

    public void onCreate() {
        super.onCreate();
        myApplication = this;
    }
}

我也尝试过清理我的项目并重建,但没有成功。当我把 ACRA 放回去时,项目照常构建。是IDE的问题吗?

【问题讨论】:

  • 你完成了干净的构建吗?
  • @GabeSechan 我已经通过选择“build”->“clean project”完成了干净的构建,甚至删除了“[project]/.gradle”文件夹,但在没有 ACRA 的情况下仍然无法构建
  • 您是否尝试从 gradle 中删除以下内容:lintOptions { disable 'RestrictedApi' }
  • @GabeSechan 出现同样的错误

标签: android gradle build dependencies acra


【解决方案1】:

@RequiresApicom.android.support:support-annotations 的一部分。您必须将其添加为依赖项

例如

dependencies {
    com.android.support:support-annotations:27.1.1
}

【讨论】:

  • 并确保为其指定一个版本,例如com.android.support:support-annotations:27.1.1 - 但并非所有版本都可以使用
猜你喜欢
  • 1970-01-01
  • 2016-03-02
  • 1970-01-01
  • 2014-04-11
  • 2015-01-06
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多