简体   繁体   English

如何在 Android Studio 中添加“libs”文件夹?

[英]How to add 'libs' folder in Android Studio?

I need help in creating the 'libs' folder in Android Studio for my project (It is not auto-generated in my project).我需要帮助在 Android Studio 中为我的项目创建“libs”文件夹(它不是在我的项目中自动生成的)。

When I want to create a folder, it gives me lots of options, like AIDL, Assets, JNI, Java, Java Resources, Renderscripts, and 'res' folders.当我想创建一个文件夹时,它给了我很多选项,比如 AIDL、Assets、JNI、Java、Java 资源、Renderscripts 和“res”文件夹。 I chose Res and added a libs folder but it didn't show up on my file structure on the left.我选择了Res并添加了一个 libs 文件夹,但它没有显示在我左侧的文件结构中。

Can anyone help me?谁能帮我?

I wanted to add a JAR file but I can't find libs to put in.我想添加一个 JAR 文件,但找不到要放入的库。

The solution for me was very simple (after 10 hours of searching).对我来说,解决方案非常简单(经过 10 个小时的搜索)。 Above where your folders are there is a combobox that says "android" click it and choose "Project".在您的文件夹上方有一个组合框,上面写着“android”,单击它并选择“Project”。

在此处输入图片说明

Click the left side dropdown menu单击左侧的下拉菜单"android" and choose "project" to see libs folders “android”并选择“project”以查看libs文件夹

在此处输入图片说明

*after choosing project you will see the libs directory *选择项目后,您将看到libs目录

libs and Assets folder in Android Studio: Android Studio 中的 libs 和 Assets 文件夹:

Create libs folder inside app folder and Asset folder inside main in the project directory by exploring project directory.通过探索项目目录,在 app 文件夹中创建 libs 文件夹,在项目目录中的 main 中创建 Asset 文件夹。

Now come back to Android Studio and switch the combo box from Android to Project.现在回到 Android Studio 并将组合框从 Android 切换到 Project。 enjoy...请享用...

Another strange thing.另一个奇怪的事情。 You wont see the libs folder in Android Studio, unless you have at least 1 file in the folder.您不会在 Android Studio 中看到 libs 文件夹,除非该文件夹中至少有 1 个文件。 So, I had to go to the libs folder using File Explorer, and then place the jar file there.因此,我必须使用文件资源管理器转到 libs 文件夹,然后将 jar 文件放在那里。 Then, it showed up in Android Studio.然后,它出现在 Android Studio 中。

also, to get the right arrow, right click and "Add as Library".此外,要获得右箭头,请右键单击并“添加为库”。 在此处输入图片说明

also you should click right button on mouse at your projectname and choose "open module settings" or press F4 button.您还应该在项目名称上单击鼠标右键,然后选择“打开模块设置”或按 F4 按钮。 Then on "dependencies" tab add your lib.jar to declare needed lib然后在“依赖项”选项卡上添加您的 lib.jar 以声明所需的库

您可以在应用程序中创建 lib 文件夹,然后按右键单击并选择您命名为libs 的目录,它将起作用

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

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