life evader
life evader

Reputation: 988

Android Studio Imports not working

So today I was working on my App, everything was working okay until all the sudden Universal Image Loader and MultiDex stopped working, all my other imports were ok but just these two, I try removing the imports and re-imported them they could not work, here is my Application class that is suffering from the import issue:

public class App extends Application {

private static App instance;
public static Context applicationContext=null;
public static volatile Handler applicationHandler = null;
public static Point displaySize = new Point();
public static float density = 1;
public Bitmap cropped = null;
public Uri imgLocation = null;
public String imgePath = null;

@Override public void onCreate() {
super.onCreate();

  initImageLoader();
  instance = this;
  mInstance = this;
  applicationContext = getApplicationContext();
  applicationHandler = new Handler(applicationContext.getMainLooper());
  checkDisplaySize();
  density = App.applicationContext.getResources().getDisplayMetrics().density;
  DisplayImageOptions defaultDisplayImageOptions = new DisplayImageOptions.Builder() //
          .considerExifParams(true)
          .resetViewBeforeLoading(true)
          .showImageOnLoading(R.drawable.nophotos)
          .showImageOnFail(R.drawable.nophotos)
          .delayBeforeLoading(0)
          .build(); //
  ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(
          getApplicationContext())
          .defaultDisplayImageOptions(defaultDisplayImageOptions)
          .memoryCacheExtraOptions(480, 800).threadPoolSize(5).build();
  ImageLoader.getInstance().init(config);
 }

@Override
protected void attachBaseContext(Context base) {
    super.attachBaseContext(base);
    MultiDex.install(base);

}

And my Gradle File:

 dependencies {
    compile project(':ImageViewTouch')
    compile project(':Gpu-Image')
    compile project(':fastjson-1.2.5')
    compile project(':android-support-multidex')
    compile project(':universal-image-loader-1.9.4')
  }

Upvotes: 0

Views: 9011

Answers (2)

Miguel Tomás
Miguel Tomás

Reputation: 1911

Many times, this error appears when there is an error on the file to be imported. So open the file to be imported and correct any errors in there first.

If the error still persists, right click on the project and select the option 'Analyse' > 'Code Cleanup'

also, make sure your package directory structure does not have any uppercase letters

Upvotes: 0

Ruchir Baronia
Ruchir Baronia

Reputation: 7551

This answer is based off of the fact that you said:

Everything was working okay until all the sudden

Okay, so if everything was working before, it is not your fault, but android-studios fault.

Here are some things that you can try to do to fix it:

  • Clean project

  • Rebuild Project

  • Restart IDE

  • Update SDK tools

This is probably not an issue with your code, so you don't have to worry about it much. If cleaning and rebuilding doesn't work, just wait for some time.

Give android studio a while to set up, and this could take a few minutes. Often times, it fixes itself without even having to do any of the steps I listed above.

IMPORTANT:

ONLY update your SDK or mess with files AS THE LAST STEP. If you do that, I HIGHLY suggest you take a backup first.

Upvotes: 4

Related Questions