简体   繁体   English

在Android Studio中导入库

[英]Importing library in Android Studio

I have little experience with importing libraries. 我几乎没有导入库的经验。 I am using Android Studio, and am trying to use parse.com's library with no luck. 我正在使用Android Studio,并且尝试使用parse.com的库没有任何运气。 I followed these instructions , and tried a few other things when that didn't work. 我遵循了这些说明 ,并在无法解决问题时尝试了其他一些操作。 Please help me out. 请帮帮我。 Let me know if you need any more information. 让我知道您是否需要更多信息。 Thanks for your time. 谢谢你的时间。

This is my MainActivity where I would initialize my Parse client key: 这是我的MainActivity,用于初始化我的Parse客户端密钥: 主要活动

Project Structure showing I have imported the libraries: 显示我已导入库的项目结构: 项目结构在此处输入图片说明

UPDATE Gradle: UPDATE Gradle: 在此处输入图片说明 UPDATE: When I try to Build, I get this error: Gradle: error: package com.parse does not exist When I try cleaning through command prompt 更新:当我尝试生成时,出现此错误: Gradle: error: package com.parse does not exist当我尝试通过命令提示符进行清理时 在此处输入图片说明

  1. Put the jar into the libs folder 将罐子放入libs文件夹
  2. Right click it and hit 'Add as library' 右键单击它,然后单击“添加为库”
  3. Ensure that compile files('libs/~~~~~~~~.jar') is in your build.gradle file 确保编译文件('libs / ~~~~~~~~~ .jar')在build.gradle文件中
  4. Do a clean build (You can do this easily in android studio but just as a better method, go to your project folder using windows explorer and open a Command window there by right clicking the folder while holding shift and type gradlew build. 进行干净的构建(您可以在android studio中轻松完成此操作,但作为一种更好的方法,使用Windows资源管理器转到项目文件夹,并在按住shift的同时右键单击该文件夹并键入gradlew build,在其中打开“命令”窗口。

To add to the answer of @ThePoloDoc and for your update Command Prompt image, you need to do the following to clear that error: 要添加到@ThePoloDoc的答案以及更新的命令提示符图像,您需要执行以下操作以清除该错误:

  1. Go to Control Panel -> System -> Right Side see for Advanced System settings 转到控制面板->系统->右侧,查看高级系统设置
  2. Select Environmental Variables 选择环境变量
  3. In the new window, search for the PATH variable. 在新窗口中,搜索PATH变量。 Add the java installation folder something similar to C:\\PATH_TO_JDK\\bin 添加类似于C:\\PATH_TO_JDK\\bin的Java安装文件夹

Replace the PATH_TO_JDK with the installation of your java directory Try opening the command prompt and you'll see the error gone. 用Java目录的安装替换PATH_TO_JDK尝试打开命令提示符,您将看到错误消失了。

UPDATE: I have got a doubt in your question. 更新:我对你的问题有疑问。 Why do you manually compile gradle? 为什么要手动编译gradle? I use Android Studio. 我使用Android Studio。 But I always click the Sync Project with Gradle Files button on the top. 但是我总是单击顶部的Sync Project with Gradle Files按钮。 It does everything for me 它为我做一切

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

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