如何在 Android Studio 中导入 java 包

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/20179181/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-12 23:46:33  来源:igfitidea点击:

How to import a java package in Android Studio

javaandroidimportandroid-studiofftpack

提问by user3027891

I'm new in android, and I want to import the jfftpack to my project in android studio anda i don't know how to import it.

我是 android 新手,我想将 jfftpack 导入到我在 android studio 中的项目中,但我不知道如何导入它。

The original code was import ca.uol.aig.realdoublefft and I'don't know where to put the java files. I've tried to put them to a libs folder.

原始代码是 import ca.uol.aig.realdoublefft ,我不知道将 java 文件放在哪里。我试图将它们放到 libs 文件夹中。

here's the jfftpack source code:

这是 jfftpack 源代码:

采纳答案by Scott Barta

If it's an existing code library, I'd recommend adding a module for it. Probably the easiest way is to use the File menu command to add a new module, let it create a plain Java (non-Android) module for you, remove the sample class it puts into the module, and then copy your files over into it and tweak it. The module wizard will take care of setting up the directories and build files for you, and you can look at it later and see what did.

如果它是一个现有的代码库,我建议为它添加一个模块。可能最简单的方法是使用 File 菜单命令添加一个新模块,让它为您创建一个普通的 Java(非 Android)模块,删除它放入模块中的示例类,然后将您的文件复制到其中并调整它。模块向导将负责为您设置目录和构建文件,您可以稍后查看它并查看做了什么。

回答by ebianco

If you have the sources import them in the src folder. Is the simple thing that you can do.

如果您有源,请将它们导入 src 文件夹中。是你可以做的简单的事情。

回答by Manikanta Reddy

Without pressing Alt + enter to import the Packages?

不按 Alt + Enter 来导入包?

There is some steps like 1)File --->Settings --from left pane we find editor---->General--->Auto Import

有一些步骤,如 1) 文件 ---> 设置 -- 从左窗格中我们找到编辑器 ----> 常规 ---> 自动导入

There Insert imports on paste as ALLnot ask

在粘贴时插入导入,因为ALL

And put check mark for all the Above three Fields

并为以上三个字段打勾

1)Show import popup

1)显示导入弹出窗口

2)Optimize the imports on fly

2) 实时优化导入

3)Add unambiguous imports on the fly

3) 动态添加明确的导入

Click Apply and ok

单击应用并确定

Happy Coding......

快乐编码......

回答by Alston

I suggest you to use the command line rather than Android Studio interface. If you work on Linux or MacOS, try to copy the package to your working direcotry like:

我建议您使用命令行而不是 Android Studio 界面。如果您在 Linux 或 MacOS 上工作,请尝试将软件包复制到您的工作目录,例如:

cp -r PACKAGE_NAME PATH_TO/AndroidStudioProjects/PROJECT_NAME/app/src/main/java/