简体   繁体   English

android 3rd party库

[英]android 3rd party library

I wanted to use gson in my android project so I followed a tutorial and done this 我想在我的android项目中使用gson,所以我按照一个教程进行了操作

  1. Create a new folder, libs, in your Eclipse/Android project. 在您的Eclipse / Android项目中创建一个新文件夹libs。
  2. Right-click libs and choose Import -> General -> File System, then Next, Browse in the filesystem to find the library's parent directory (ie: where you downloaded it to). 右键单击库,然后选择导入->常规->文件系统,然后单击下一步,在文件系统中浏览以找到库的父目录(即:将其下载到的目录)。
  3. Click OK, then click the directory name (not the checkbox) in the left pane, then check the relevant JAR in the right pane. 单击“确定”,然后在左窗格中单击目录名称(而不是复选框),然后在右窗格中检查相关的JAR。 This puts the library into your project (physically). 这会将库(实际)放入您的项目中。
  4. Right-click on your project, choose Build Path -> Configure Build Path, then click the Libraries tab, then Add JARs..., navigate to your new JAR in the libs directory and add it. 右键单击您的项目,选择“构建路径”->“配置构建路径”,然后单击“库”选项卡,然后单击“添加JAR ...”,导航到libs目录中的新JAR并将其添加。 (This, incidentally, is the moment at which your new JAR is converted for use on Android.) (顺便说一下,这是新的JAR转换为可在Android上使用的时刻。)

it worked perfectly in android 2.2 but with android 4.0.3 it is throwing an exception 05-06 19:12:18.946: E/AndroidRuntime(602): java.lang.NoClassDefFoundError: com.google.gson.Gson 它在android 2.2中完美地工作,但是在android 4.0.3中它引发了异常05-06 19:12:18.946:E / AndroidRuntime(602):java.lang.NoClassDefFoundError:com.google.gson.Gson

在android 4中,请务必将文件夹称为libs而不是lib或其他名称,否则它将无法正常工作。

  1. create a folder call 'lib' in your project root folder 在项目根文件夹中创建一个名为“ lib”的文件夹
  2. copy your Jar files into lib folder 将您的Jar文件复制到lib文件夹中
  3. now right click on the Jar file and Build Path > Add to Build Path, and your are done 现在,右键单击Jar文件,然后依次单击“构建路径”>“添加到构建路径”,即可完成操作

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

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