This article takes about 3.6 minutes to read.

I believe that many people have fallen in love with GitHub since reading my GitHub tutorial. Some of them have stopped using weibo and Zhihu, but they have switched to GitHub instead, and they are enjoying it very much. This is a good thing, as exposure to open source projects can greatly improve your development efficiency in future projects. However, I want to tell you that you read open source projects in a low posture, today I will teach you the best posture.

First of all, “read” is a generic term. For Android, you can run a demo to see what the project looks like.

Here’s how the average person reads an open source project:

1. Find the project address

2. Click download Zip.

3. Decompress the package to a directory

4. Open Android Studio

5. Import projects

6. Sync gradle

7. Run the project

8. Select the running device

9. Delete the downloaded ZIP file

Compare that to you, don’t you? It’s also inefficient.

On the one hand, the steps are tedious, of course, some people may use Git instead of downloading, slightly reduce the steps, on the other hand, Android Stduio eats a lot of memory, light start takes a lot of time, not to mention import, compile, run, we have to use in the actual development, but if just to read the source code, Look at the effect and running Android Stduio is overemployed, consuming a lot, and often is a lot of time may read multiple projects at the same time, then open multiple Android Stduio Windows is a big test for the computer.

Here are my steps to read the source code:

Git Clone project address;

Open the source code with sublime (or Atom, vim) lightweight editor;

3. Run gradle command line to view the result.

Are steps drastically simplified? There’s also no need to open Android Studio’s in-memory machine, and it’s cool to open as many projects as you want with this lightweight editor, then compile and run directly from the command line.

A lot of people will definitely ask about the process of the third step, and this is the key point. The key points of this step are listed below without explaining them in detail. If you have read my Gradle article before, you will understand.

  • First check the gradle version, buildTools version and compile SDK version of the open source project.

  • Compile and wrap using gradle Wrapper built into the project:

        ./gradlew clean

        ./gradlew assembleDebug

These two steps can be compiled, packaged, and installed manually yourself;

  • Compilation packaging and installation can actually be combined:

        ./gradlew clean

        ./gradlew installDebug

These two steps can be installed directly on your device without manual installation, isn’t it more convenient and fast?

Then someone asked, is there a one step download, compile, package, run can be done? Oh, my God, you are so lazy, but I have to tell you there is!

There is a project on GitHub called dryrun, which translates as “dryrun”. Address:

https://github.com/cesarferreira/dryrun

Simply install the tool and execute a command directly:

    $ dryrun [email protected]:cesarferreira/android-helloworld.git

The Android demo above can be installed directly on your device. The biggest dick ever!

But it’s essentially the same as my own steps, except it’s combined with a Ruby script.

It is worth noting:

  • Dryrun is a gem that is based on Ruby. If you are not familiar with Ruby and have not installed Ruby locally, it is quite difficult to install dryRun:

        gem install dryrun

  • If the gradle version, buildTools version, and compile SDK version of the Android project you want to run on GitHub are different from those of your local directory, it will fail to run.

  • Its practical value is not so high, is used to install force, suitable for me this kind of Ruby and understand Android and like to install force;

  • Interested might as well toss about, not interested in you should learn my second way, very practical, high efficiency, you deserve to have!

Yeah, that’s it! You’re done!