简体   繁体   English

Android Studio - 包 java.awt.image 不存在

[英]Android Studio - package java.awt.image does not exist

I have a problem running my project on Android Studio.我在 Android Studio 上运行我的项目时遇到问题。 I am working on an Android project that has a native Java library inside it.我正在开发一个内置 Java 库的 Android 项目。 It was running fine all the time.它一直运行良好。 But suddenly when I open Android Studio, I find this error:但是突然当我打开Android Studio时,我发现了这个错误:

在此处输入图片说明

There is also an error in the .gradle of the project:项目的.gradle也有错误:

在此处输入图片说明

It says that URI is not registered.它说 URI 未注册。

When Android Studio is started, I find this message:当 Android Studio 启动时,我发现此消息:

在此处输入图片说明

It seems that there is something wrong in Java configuration, but I can't find out what is the problem?好像是Java配置有问题,但是查不出来是什么问题?

It was running fine all the time它一直运行良好

Not on Android, it wasn't.不是在 Android 上,不是。

It seems that there is something wrong in Java configuration Java配置好像有问题

No. You are using classes that are not part of the Android SDK.不可以。您使用的类不是 Android SDK 的一部分。

The java Swing and AWT API are not part of the Android SDK and thus aren't including with it. java Swing 和 AWT API 不是 Android SDK 的一部分,因此不包含在其中。 You must find an Android equivalent image library to use in your app.您必须找到要在您的应用中使用的 Android 等效图像库。 There are few good ones around just depends on what functionality you need to have available to you in you app.很少有好的东西取决于您需要在您的应用程序中使用哪些功能。 Try searching Picasso and or Volley .尝试搜索Picasso和或Volley Picasso is very popular and well known.毕加索非常受欢迎和知名。 it has a lot of feature including networking functionality for loading images from the web.它有很多功能,包括从网络加载图像的网络功能。 The Volley library isn't an image library but an networking library that contains some predefined classes for loading images over the internet. Volley 库不是图像库,而是一个网络库,其中包含一些用于通过 Internet 加载图像的预定义类。

So this just happened to me.所以这只是发生在我身上。 I'm not 100% on the details of how I got it working again, but its roughly this (on my Mac):我不是 100% 了解如何让它再次工作的细节,但大致是这样的(在我的 Mac 上):

  1. Quit Android Studio退出 Android Studio
  2. I went to ~/Library/Application%20Support/ and deleted the AndroidStudio3.2 directory我去~/Library/Application%20Support/删除AndroidStudio3.2目录
  3. I relaunched Android Studio and I got some warning dialog about plugins not existing.我重新启动了 Android Studio,我收到了一些关于插件不存在的警告对话框。
  4. Chose the button that is something about reinstalling or fixing (or whatever isn't deleting or ignoring)选择与重新安装或修复有关的按钮(或任何未删除或忽略的按钮)
  5. Another dialog comes up.出现另一个对话框。 There are a bunch of plugins that are in red.有一堆红色的插件。 Deselect all the red ones.取消选择所有红色的。 Then reselect all those ones that were previously red.然后重新选择所有以前是红色的。
  6. Android Studio asks you something and if you want to restart Android Studio. Android Studio 会询问您是否要重新启动 Android Studio。 Pick the thing that includes restarting.选择包括重新启动的事情。

And once Android Studio restarts, chose to rebuild your project, and then it worked.一旦 Android Studio 重新启动,选择重建您的项目,然后它就可以工作了。

Good Luck and I hope this works for you too.祝你好运,我希望这也适用于你。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM