可Android的工作室被用于运行标准的Java项目?工作室、标准、项目、Android

2023-09-12 01:26:57 作者:另类导师

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

For those times when you want to isolate the Java and give it a quick test..

你能运行Android的工作室非Android的Java项目,在Eclipse?

Can you run non-Android Java projects in Android studio as in Eclipse?

推荐答案

测试在Android工作室0.8.6 - 1.2.2

使用这个方法,你可以拥有的Java模块和Android模块在同一个项目,也有编译和运行Java模块作为独立的Java项目的能力。

Using this method you can have Java modules and Android modules in the same project and also have the ability to compile and run Java modules as stand alone Java projects.

打开在Android的Studio中的Andr​​oid项目。如果你还没有一个,创建一个。 点击文件>新建模块。选择 Java库,然后点击下一步 填写包名等,并点击完成。您现在应该看到您的Andr​​oid项目内的Java模块。 添加您的code到你刚刚创建的Java模块。 点击下拉到运行按钮的左侧。点击修改配置... 在新窗口中,点击加号窗口的左上角并选择应用 在一个新的应用程序配置应该出现在细节上,输入如主类和你的模块的类路径中。 点击确定 Open your Android project in Android Studio. If you do not have one, create one. Click File > New Module. Select Java Library and click Next. Fill in the package name, etc and click Finish. You should now see a Java module inside your Android project. Add your code to the Java module you've just created. Click on the drop down to the left of the run button. Click Edit Configurations... In the new window, click on the plus sign at the top left of the window and select Application A new application configuration should appear, enter in the details such as your main class and classpath of your module. Click OK.

现在,如果你点击运行,这应该编译和运行Java模块。

Now if you click run, this should compile and run your Java module.

我的使用情况: 我的Andr​​oid应用程序依赖于某些precomputed文件的功能。通过一些Java code产生这些pcomputed $ P $文件。由于这两件事情齐头并进,这是很有道理的有这两个模块在同一个项目。

My usage case: My Android app relies on some precomputed files to function. These precomputed files are generated by some Java code. Since these two things go hand in hand, it makes the most sense to have both of these modules in the same project.