Author: Hong Yang

The original link: https://mp.weixin.qq.com/s/GdDkzR8AvgHROUiGwYtfOg

preface

When writing the Android project, will introduce a variety of Google’s library, for example viewpager2, livedata, viewmodel, etc…

I have a question, how many people, to be able to remember these libraries complete group: artifactName: version.

I don’t remember any of them anyway…

So every time you need to add a dependency, either go to Google Repo or do something like this in Android Studio:


Then you get to the built-in search screen:

Input keywords, and then search, if you have a better network is good, poor network, may be a lot slower, and I have encountered a long search did not come out of the situation.

The whole is not too complicated, but there is always a bit of discomfort.

1. Here comes the plug-in

However, we are wondering if there is a way that when I edit build.gradle, I can type in a keyword, which will show me the library, and then I can select the specific version.

Just as we would write code:

Yes, that’s what we’re going to introduce today.

First look at the effect:

The measured:

Open source address: https://github.com/wuyr/GoogleLibraryVersionQuerier

Effect introduction:

1. When editing build.gradle, there is a code prompt:


2. Move the cursor to the line where the target class library is located and right-click to quickly view and replace a version:

Plug-in installation:

The local installation: https://github.com/wuyr/GoogleLibraryVersionQuerier/releases

Download the latest version, unzip it, and drag the zip into Android Studio.

Drag and unzip the zip inside:

Currently plugin has not been approved, so it cannot be installed online.

Right, this plug-in is small edge write, for such a guy, I anyway.

2. I want to study

Since it is open source, in addition to use, but also can directly learn the source code.

Everyone knows the hardest part about writing plugins is that many apis don’t know.

One thing to mention here is that in the beginning, the keyword prompt was not the same as the code prompt is now, but the popbox selection.

Later I mentioned this idea, but xiao Yuan realized it. It is extremely difficult to find this API, so if you have similar needs in the future, you can refer to it.

Source address: https://github.com/wuyr/GoogleLibraryVersionQuerier

Android Senior Architects learn advanced materials

Click on me [programmer advanced learning] to join our circle to receive information and we learn to communicate!

Other needs can also be viewed on my Github

  • Android advanced learning complete manual

  • Advanced Knowledge Body diagram for Android Senior Architect
  • Android to standard Ali P7 learning video

  • BATJ Android high-frequency interview questions


3. I’m going to write plug-ins

This plug-in relies on the stability of the query interface, so I provided an interface for keywords to return Google Repo query results.

You can refer to:

I developed another “sand sculpture” feature!

Or directly visit: https://wanandroid.com/maven_pom/index?k=viewpager2

I’ve opened up json query data for Google Repo, and it basically returns query results on data requests in 100ms.

Hopefully this plugin will help you in both your coding experience and your learning.

Hope you can support hongyang God more!! Come on, come on!