2

I am using

import com.android.annotations.Nullable;

it was compiling and app was running on

  • Android studio 2.3
  • gradle version 2.14.1 and
  • android plugin version 2.2.3.

But after updating to

  • Android studio 2.3.1
  • gradle version 3.3 and
  • android plugin version 2.3.1

it stop compiling. I have searched some other SoF question like this but they are suggesting to use different package

import android.support.annotation.Nullable;

I want to know that is compulsory to use support lib package. If yes the how it was running with other import ?

My application build.gradle

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

module build.gradle

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

As you can see in build.gradle I have commented

//apply plugin: 'com.neenbedankt.android-apt'

annotation plugin which I was using in Android studio 2.3 and after updating I have removed it because annotation processor is provided by Android studio itself.

So I want to know why android studio is not able to find

import android.support.annotation.Nullable;

after update is this annotation class is present in plugin which I was using previously ?

Community
  • 1
  • 1
prateek
  • 858
  • 2
  • 10
  • 28

3 Answers3

2

I'm also got this problem, I had

import com.android.annotations.NonNull;

but wouldn't find the package.

So I commented that line and imported again, it changed to:

import android.support.annotation.NonNull;

wich finally worked.

Eliseo Ocampos
  • 2,473
  • 4
  • 20
  • 32
Eric Wijaya
  • 291
  • 3
  • 12
2

If that does not affect your project you can use Android Jetpack. For migration

Then simply replace this:

import android.support.annotation.{annotation}

with:

import androidx.annotation.{annotation}

Shivam Agarwal
  • 133
  • 1
  • 6
0

please change your gradle version to classpath 'com.android.tools.build:gradle:2.3.1' in your application build.gradle and then try

Bhupat Bheda
  • 1,968
  • 1
  • 8
  • 13