Since the new small project want to rely on their own previously written library, always local copy and paste feel very troublesome, and then learn about the release of remote dependencies, in this record, also provide some experience to avoid the hole ~
Release the GitHub project
Skip this step if you already know how to publish a GitHub project.
Android Studio uploads projects to GitHub:
1. Download and install itGit 。
2. Configure Git on Android Studio:
File -> Settings -> Version Control -> Git.
3. Configure a GitHub account:
File -> Settings -> Version Control -> GitHub.
4. Select a project and create a local code repository:
VCS -> Import into Version Control -> Create Git Repository…
5. Right-click on the project and Add the file to the local repository. If you need to Add a single file, right-click on the file and Add:
Create GitHub remote repository:
- Enter the warehouse name and private and warehouse description, etc. :
6. Submit files to local repository and synchronize them to GitHub:
- Select the file to commit synchronization and enter the commit information:
- CommitOnly upload to local warehouse selection,Commit and PushThe project is synchronized to GitHub at the same time it is committed to the local repository, and then it can be seen on GitHub.
* Command line uploads can be found on Baidu or here: Command line uploads local projects to GitHub – Nuggets (juejin. Cn).
Release the GitHub project version
- When the project is uploaded, you need to publish the version on GitHub:
- Release the version and fill in the relevant information.
- After the release, you can view all the released versions of the project.
Release the GitHub version to JitPack
The JitPack is a remote repository that synchronizes project versions to the JitPack and can then be relied on remotely without auditing.
- Go to JitPack and log in to the JitPack using the GitHub account.
- Once logged in, you can see the existing GitHub project, with the existing version on the right. Click Get It and the JitPack will start compiling the project.
- You can determine whether the compilation is successful by the color of the Log. Red indicates failure and green indicates pass. When the Log is red, it cannot be found through remote dependence.
- After successful compilation, the root of the Android Studio project
build.gradle
Add the Maven path to the maven directory, and then add the dependency.
- If Gradle tool version is greater than or equal to 4.6.
- Add to the root build.gradle:
Buildscript {dependencies {classpath 'com. Making. Dcendents: android - maven - gradle - plugin: 2.1' / / Add this lineCopy the code
- To build. Gradle in the library, add,
${YourUsername}
Is the project name of a remote dependency:
apply plugin: 'com.github.dcendents.android-maven'
group='com.github.${YourUsername}'
Copy the code
- Just resubmit GitHub and release, and sync to JitPack.