Java – Android studio does not recognize the import statement

I have a problem that stems from a core problem: Android studio does not recognize import

For example, in my class "activityabout", I have the following import statement:

import android.content.Intent;
import android.os.Bundle;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
import android.view.View;
import android.support.design.widget.NavigationView;
import android.support.v4.view.GravityCompat;
import android.support.v4.widget.DrawerLayout;
import android.support.v7.app.ActionBarDrawerToggle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.Menu;
import android.view.MenuItem;
import android.view.animation.AnimationUtils;
import android.widget.ViewFlipper;

However, in the IDE (taking the first import statement as an example), importing android.content. Appears gray. When I hover over it, it displays "unused import statement", and the intention part is displayed in red. When I hover over this part, it indicates "unable to resolve the symbol intention". This happens for each import statement, and the first part is displayed in gray, The last part is displayed in red

Now, this presents a lot of problems in my code, because anything related to these import statements is displayed in red, and when I hover over it, I receive the message "unable to resolve the symbol _"

This is the kicker - my app is still compiling and running when I open it on my phone

I think my main problem is incredible trouble, and car import doesn't work. (I've checked the "display import pop-up window" in the setting, which is the answer to the problem that automatic import can't solve for others I find). My other concern is that this will make my app ineligible to be released in the play store. I'm still investigating the release process, So I don't know if this is really a problem

My question (if no one has an answer to how to solve this problem) is: is this the problem with IDE itself or code?

Editing: adding additional import statements

resolvent:

I just had this problem. I solved this problem by clicking File > invalid cache / restart... > invalid and restart. When Android studio restarts and indexes all my code again, the problem disappears

I don't know what caused it

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>