简体   繁体   English

如何编辑gradle依赖项

[英]How to edit a gradle dependency

I'm working on an android project that uses the following dependency in my gradle file; 我正在研究一个在我的gradle文件中使用以下依赖项的android项目;

compile 'com.mapzen:on-the-road:1.1.1'

I would like to edit one of the files in order to add some missing features and contribute to the project. 我想编辑其中一个文件,以便添加一些缺少的功能并为项目做出贡献。

How can I download this project and test edits in my android studio project? 如何在我的android studio项目中下载此项目并测试编辑?

I just found out that the project is open-source and is available in Github. 我刚刚发现该项目是开源的,可以在Github上找到。

Please follow these simple steps - 请按照以下简单步骤 -

1) Go to this page and click on "Clone or Download" and then click on "Download ZIP". 1)转到页面并单击“克隆或下载”,然后单击“下载ZIP”。

2) This will give you the ZIP file which you need to extract to get the entire project. 2)这将为您提供需要提取的ZIP文件以获取整个项目。

3) Now you are free to edit any files in the project you want to. 3)现在您可以自由编辑项目中的任何文件。

4) To include this custom project into your parent project, you need to paste this project into your mail project, include it in the settings.gradle file like this, 4)要将此自定义项目包含到您的父项目中,您需要将此项目粘贴到您的邮件项目中,将其包含在settings.gradle文件中,如下所示,

include ':app', ':customLibrary'

and then you need to compile the library from your app's build.gradle file, 然后你需要从app的build.gradle文件中编译库,

compile project(':customLibrary')

NOTE - Make sure you remove this from the build.gradle file, 注意 - 确保从build.gradle文件中删除它,

compile 'com.mapzen:on-the-road:1.1.1'

When you use dependency, when you build, it downloads the library to : 当您使用依赖项时,在构建时,它会将库下载到:

build -> intermediates -> exploded-aar -> THE_LIBRARY. build - > intermediates - > explosion-aar - > THE_LIBRARY。

If THE_LIBRARY isn't obfuscated, you can take it from there, copy it, and import it as a module to your project(and then edit the class) 如果THE_LIBRARY未被混淆,您可以从那里获取它,复制它,并将其作为模块导入您的项目(然后编辑该类)

On The Road is indeed open source and available on GitHub at https://github.com/mapzen/on-the-road_android . On The Road确实是开源的,可以通过https://github.com/mapzen/on-the-road_android在GitHub上获得。 I am a maintainer for the project. 我是该项目的维护者。 Contributions are always welcome! 欢迎捐款!

Some tips for getting started: 入门的一些提示:

  • Make a fork of the project using your GitHub account. 使用您的GitHub帐户创建项目的分支。
  • Clone the project to your local machine using git clone git@github.com:[YOUR_GITHUB_USERNAME]/on-the-road_android.git . 使用git clone git@github.com:[YOUR_GITHUB_USERNAME]/on-the-road_android.git将项目克隆到本地计算机git clone git@github.com:[YOUR_GITHUB_USERNAME]/on-the-road_android.git
  • Open the project in Android Studio and make local edits (please try to adhere to the code style used by the rest of the library). 在Android Studio中打开项目并进行本地编辑(请尝试遵循库的其余部分使用的代码样式)。
  • The project includes a sample application you can use to test your changes. 该项目包括一个示例应用程序 ,可用于测试您的更改。
  • You can also deploy a SNAPSHOT to your local Maven repo using ./gradlew install . 您还可以使用./gradlew install将SNAPSHOT部署到本地Maven ./gradlew install This will allow you to test in your app by updating the dependency to compile 'com.mapzen:on-the-road:1.2.0-SNAPSHOT . 这将允许您通过更新依赖项来测试应用程序,以compile 'com.mapzen:on-the-road:1.2.0-SNAPSHOT If you do this also make sure your app includes the mavenLocal() repository in your the repositories section of the build.gradle file for your app. 如果这样做,还要确保您的应用程序在应用程序的build.gradle文件的repositories部分中包含mavenLocal()存储repositories
  • Commit your changes and push to your fork on GitHub. 提交您的更改并在GitHub上推送您的分支。 Then create a pull request to the upstream repository. 然后为上游存储库创建一个pull请求。

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

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