Adding Jar Files With Dependencies And Modules
来源:互联网 发布:酷狗无法连接网络 编辑:程序博客网 时间:2024/05/29 09:53
①.将要添加的jar文件复制到我们项目中的libs文件夹中,会弹出一个对话框,点击OK并添加jar文件到项目中。现在,还没有完成,jar文件不一定会被注册并可供编码和编译使用。因此下一步是右键单击jar文件,然后再到菜单的底部并选择Add As Library…添加为库,在弹出的对话框中点击OK,然后等待Gradle的同步。然后打开build.gradle文件,这个是在应用程序文件夹中的。然后看依赖关系部分,可以看到已添加一个新行编译特定的jar文件作为项目的一部分。这是最简单的一个方法。
消除这种依赖关系,在build.gradle就能做到这一点。不过,我们也可以在Project Stucture,去到app模块然后单击Dependencies选项。选中你的jar文件,点击右边的’-’号进行删除。也可以从这里添加依赖关系。然后单击OK,这会重新构建应用程序。如果还想删除jar文件本身,那么就在项目窗口中选择它,然后按Delete键,然后单击OK,之后该文件被完全除去。
②.第二种方法添加一个jar文件到自己的模块,然后使该模块与你的主应用程序有依赖关系。当前项目为打开状态时,去到菜单File —> New —> New Module…选择导入JAR或AAR,这将导入jar文件作为它自己的模块。然后点击Next,然后选择选择想要的jar文件,然后单击Finish。这样就会创建一个新的模块,然后我们去文件菜单File,Project Structure,我们会看到新的模块,在这里列出。回到app模块,到依赖关系选项卡Dependencies。点击加号图标选择一个模块依赖。然后点击OK,Gradle再次同步,在gradle.build文件,会看到新的依赖已添加到依赖关系里了。再次重新生成项目,菜单栏Build – > Rebuild Project,以确保一切仍能编译通过。
通过创建一个单独的模块,你现在就可以开始添加其他库到模块当中,它们就会自动成为你当前的应用程序的一部分。这就是以不同方式整合jar文件到你的Android应用程序并作为依赖。这是了解依赖的一个好的开始。这是一种连接一些代码到你要集成的应用程序中的方法。
- Adding Jar Files With Dependencies And Modules
- Drupal 6.X: Adding Modules and Themes and Slideshow Creator
- Adding your own exploits and modules in Metasploit
- call_rcu and synchronize_rcu with unloadable modules
- Android gradle build principles, dependencies, and so files, project directory
- Reading and writing .mat files with Python
- Working with iPhone files and folders
- Base64 encoding and decoding files with POCO
- Files and Exceptions: Dealing with Errors
- Rename files and folders with git
- read excel files with python and xlrd
- learning R with swirl-workspace and files
- building and installing openCV3 with extra modules on VS2013 win8
- Install OpenCV dependencies on Ubuntu 16.04 with python2 and python3
- Doing more with files with Java and PeopleCode
- ksoap2-android-assembly-3.2.0-jar-with-dependencies.jar的正确引入方法
- Adding Achievements with XLAST
- Introduction to DataSets and working with XML files
- 剑指offer13 调整数组顺序使奇数位于偶数前面
- ubuntu系统分区
- 关于matlab绘图中字体及图片大小等的设置
- 一步步构建Material Design风格App
- OpenJudge_P8462 大盗阿福
- Adding Jar Files With Dependencies And Modules
- Spring MVC 入门示例讲解
- centos6.5安装mysql
- Android之ActionBar遇到的问题
- 欢迎使用CSDN-markdown编辑器
- shell脚本调用方法及适用场景
- OpenDaylight的Helium(氦)版本安装
- ECMAScript 变量
- Spring cache资料(二 ,详解)