简体   繁体   English

将github项目导入android studio

[英]Import github project into android studio

I want to use this library in my android application which has been developed in android studio IDE. 我想在已在android studio IDE中开发的android应用程序中使用此库 I downloaded the zip file from githup and extracted, then paste the unzip file in a optional folder called 'subProject' in application root. 我从githup下载了zip文件并解压缩,然后将解压缩文件粘贴到应用程序根目录中名为“ subProject”的可选文件夹中。 image . 形象 Next I added this line to setting.gradle: 接下来,我将此行添加到setting.gradle:

include ':app', ':subProject:rtree-3d'

and then change my application build.gradle to this as new dependency: 然后将我的应用程序build.gradle更改为新的依赖项:

compile project(':subProject:rtree-3d')

But after cleaning and rebuilding my project I have this error: Error:Configuration with name 'default' not found. 但是在清理并重建我的项目后,我出现以下错误:错误:找不到名称为“默认”的配置。

I also change top line to compile fileTree(dir: 'subProject', include: ['rtree-3d']) but there was no succeed. 我还更改了顶行以compile fileTree(dir: 'subProject', include: ['rtree-3d'])但没有成功。

How can I add this github project to my android application to use? 如何将这个github项目添加到我的android应用程序中使用? Any help will be appreciated. 任何帮助将不胜感激。

This isn't a gradle-project (but Maven (see the pom.xml ?)), so the gradle build won't succeed, because it is looking for build.gradle -files. 这不是gradle-project(而是Maven(请参阅pom.xml吗?)),所以gradle构建不会成功,因为它正在寻找build.gradle -files。

You could build it with Maven, and add the resulting .jar file to your lib -folder of your project, in order to let gradle pick it up. 您可以使用Maven构建它,然后将生成的.jar文件添加到项目的lib文件夹中,以便gradle对其进行拾取。

Or, even better, just add it as a dependency to your apps build.gradle 或者,甚至更好,只需将其添加为您的应用程序build.gradle的依赖build.gradle

// https://mvnrepository.com/artifact/com.github.davidmoten/rtree
compile group: 'com.github.davidmoten', name: 'rtree', version: '0.8-RC10'

latest stable version is 最新的稳定版本是

compile group: 'com.github.davidmoten', name: 'rtree', version: '0.7.6'

Edit Oh! 编辑哦! my bad, actually rtree und rtree-3d istn't the same thing! 我不好,实际上rtree和rtree-3d都不一样! So you would need to fork the rtree-3d project from github, build it with maven (clean install). 因此,您需要从github派生rtree-3d项目,并使用maven进行构建(全新安装)。 Depending on your configuration gradle can access your local maven repo and pick the installed artifact from there. 根据您的配置,gradle可以访问您的本地Maven存储库,并从此处选择已安装的工件。 But for builds on different machines you would need something like a shared Sonatype Nexus. 但是对于在不同机器上构建的产品,则需要共享Sonatype Nexus之类的东西。 This is something to do, so you could just copy the rtree-3d.jar from your local maven repo to the lib-folder of your gradle project and add it to your subversion/git. 这是要做的事情,因此您可以将rtree-3d.jar从本地Maven存储库复制到gradle项目的lib文件夹中,并将其添加到您的subversion / git中。

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

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