Search code examples
androidgradlebuilddependenciesacra

android cannot find symbol class RequiresApi after removing ACRA


I need to remove ACRA for removing any vulnerabilities. I had removed all imports/compiles in app.gradle and MyApplication.java. However, when I tried to build the project, the IDE gives below error:

error: cannot find symbol class RequiresApi

These are my app.gradle and MyApplication.java

app.gradle (I could not build after I removed compile 'ch.acra:acra:4.9.2' in dependencies)

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;
    }
}

I had also tried cleaning my project and rebuild, but did not work. When I put ACRA back, the project builds as usual. Is it the problem of IDE?


Solution

  • @RequiresApi is part of androidx.annotation:annotation. You have to add that as a dependency

    e.g.

    dependencies {
        implementation("androidx.annotation:annotation:1.3.0")
    }