簡體   English   中英

Android Studio 導入不起作用

[英]Android Studio Imports not working

所以今天我正在開發我的應用程序,一切正常,直到Universal Image LoaderMultiDex突然停止工作,我所有其他導入都正常,但只有這兩個,我嘗試刪除導入並重新導入它們,但它們無法工作,這是我遇到導入問題的應用程序類:

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

}

還有我的 Gradle 文件:

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

該答案基於您所說的事實:

一切正常,直到突然之間

好的,如果以前一切正常,那不是你的錯,而是android-studios的錯。

您可以嘗試執行以下操作來修復此問題:

  • 清潔項目

  • 重建項目

  • 重新啟動IDE

  • 更新SDK工具

這可能與您的代碼無關,因此您不必為此擔心。 如果清理和重建不起作用,請等待一段時間。

給機器人工作室,同時成立,這可能需要幾分鍾的時間 通常,它甚至無需執行我上面列出的任何步驟即可進行自我修復。

重要:

僅在最后一步更新您的SDK或將文件弄亂。 如果這樣做,我強烈建議您先備份。

很多時候,當要導入的文件有錯誤時,就會出現這個錯誤。 因此,首先打開要導入的文件並更正其中的任何錯誤。

如果錯誤仍然存​​在,請右鍵單擊該項目並選擇“分析”>“代碼清理”選項

另外,請確保您的包目錄結構沒有任何大寫字母

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM