android studio无法解析导入org.json.JSONObject [英] android studio cannot resolve import org.json.JSONObject

查看:601
本文介绍了android studio无法解析导入org.json.JSONObject的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用libgdx构建我的项目,并且遇到了使用 JSONObject 类的问题。当我添加 import org.json.JSONObject 时,它说它无法解析。如何将该库添加到我的项目中?

I used libgdx to build my project and I am having issues using the JSONObject class. When I add import org.json.JSONObject, it says it cannot resolve. How do I add that library to my project?

以下是我未尝试成功的原因:

Here is what I have tried without success:


  1. 我下载了 json-simple-1.1.jar 并将其放入core / build / libs文件夹中。无法使用 import.org.json.simple.JSONObject

  2. 当在Android Studio中浏览树作为Packages下拉列表时,我可以在>Core - > Libraries - > org - > ; json但我不能将它们添加到我的项目中。我得到一个不能折射,类在一个jar文件错误。
  1. I downloaded the json-simple-1.1.jar and put it in core/build/libs folder. Could not use import.org.json.simple.JSONObject either.
  2. When browsing the tree in Android Studio as "Packages" dropdown, I can see the classes I want under "Core -> Libraries -> org -> json" but I cannot add them to my project. I get a "cannot refractor, class is in a jar file" error.

有没有我还没有尝试过解决这个问题问题?当我试图使用其他外部库时,我觉得我会再次遇到这个问题。

Is there something I have not tried yet to solve this issue? I feel I will run into this again as I try to use other external libraries.

谢谢。

推荐答案

如果您使用的是LibGdx,不带有Gradle设置,使得multy项目的构建更加简化。

If you are using LibGdx, it not comes with a Gradle setup making multy project builds streamlined.

请看这里: http://mvnrepository.com/artifact/org.json/json/

您需要添加 compile'org.json:json:20160212'到您的顶部 build.gradle ,例如:

You need to add compile 'org.json:json:20160212' to your top build.gradle, like:

dependencies {
   compile 'org.json:json:20160212'
}

这篇关于android studio无法解析导入org.json.JSONObject的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆