对于那些时候,当你想要隔离Java并给它一个快速测试。

你能像在Eclipse中一样在Android studio中运行非Android Java项目吗?


当前回答

我从http://www.jetbrains.com/idea/download/安装了IntelliJ IDEA社区版

I tried opening my project that I started in Android studio but it failed when at gradle build. I instead opened both android studio and intellij at same time and placed one screen next to the other and simply drag and dropped my java files, xml layouts, drawables, and manifest into the project hiearchy of a new project started in IntelliJ. It worked around the gradle build issues and now I can start a new project in IntelliJ and design either an android app or a basic Java app. Thankfully this worked because I hated having so many IDEs on my pc.

其他回答

如果你做File>Open…然后选择pom.xml文件。确保将侧边栏左上角的“Android”下拉框改为“Project”,以查看所有文件。此外,我认为如果你的pom.xml文件在一个名为“app/”的文件夹中,这将会有所帮助。

免责声明:我的java项目是由谷歌应用程序引擎生成的。

我从http://www.jetbrains.com/idea/download/安装了IntelliJ IDEA社区版

I tried opening my project that I started in Android studio but it failed when at gradle build. I instead opened both android studio and intellij at same time and placed one screen next to the other and simply drag and dropped my java files, xml layouts, drawables, and manifest into the project hiearchy of a new project started in IntelliJ. It worked around the gradle build issues and now I can start a new project in IntelliJ and design either an android app or a basic Java app. Thankfully this worked because I hated having so many IDEs on my pc.

要在Android中运行java文件,请确保类具有main方法。在Android Studio 3.5中,只需右键单击文件内部并选择“运行'Filename.main()'”或单击菜单上的“运行”,并从产生的下拉菜单中选择“运行文件名”。

这就是具体的设置。

编辑配置> '+' >

我已经能够使用以下步骤做到这一点:

打开Android Studio,选择“Import Project”。 在浏览窗口中浏览到您的项目文件夹并选择它。