Suggestions for solving errors reported in the first few lines of activity_main. xml after Android Studio is installed

  • 2021-11-24 03:02:45
  • OfStack

After you have installed Android Studio, you start a new project and you find:

Errors are reported in the first few lines of activity_main. xml, such as "URI is not registered".

move refactoring is not available while indexing is in progress.

There is a problem with apply script build. gradle.

The "design" interface under activity_main. xml could not be loaded.

It may be because Android SDK (not JDK) is not installed properly, and the specific reason may be that Google can't get on, so it can't download related files.

The recommended solution is to download Android Studio from official website, and then create a new project according to its prompts. In the new project, it will remind you to install Android SDK, and it will automatically download it for you after clicking OK (it is very likely that "tools" are needed).

Another possible reason is that ". Gradle" is not installed properly, which is probably the reason why it can't get up. In fact, it will be downloaded automatically after you build a new project (relevant records can be seen in "Event Log"), but the download is not good.

The recommended method is to use the "tool" from installation to new project until it is configured.

Additional knowledge: How pictures in the Android Studio res directory are referenced in the xml file

The directory structure of android studio has changed greatly compared with that of eclipse android, among which drawable stores directory changes:

Eclipse Android Android Studio
drawable-hdpi mipmap-hdpi
drawable-mdpi mipmap-mdpi
drawable-xhdpi mipmap-xhdpi
drawable-xxhdpi mipmap-xxhdpi

Then there are three points to pay attention to when referencing picture resources in xml file:

1. Refer to the picture in the drawable directory android: src= "@ drawable/xxxx"

2. Refer to the picture android in mipmap directory: src= "@ mipmap/xxxx"

3. 9 Pictures need to be placed in the drawable folder, android: src= "@ drawable/xxxx"

Related articles: