Example of Android uploading AAR to a private Maven server
It took a long time to do this. It was mainly caused by being unfamiliar with the groovy language in gradle. Write it down in case you enter the pit again next time
Create a new task in gradle
If you need to package a module into AAR and upload it to maven, you need to add the following code to the build.gradle file under the module:
Where code:
Represents the plug-in we want to apply.
MAVEN_ LOCAL_ Path indicates the Maven server address, packaging indicates the type to be packaged, and groupid: artifactid: version is the field we need to rely on.
Upload AAR to Maven server
Open the console in studio and execute the command
You can see that the log keeps running until 99% upload AAR. If you are prompted to build successful, congratulations. You have uploaded the AAR file to the Maven server.
Problems encountered while uploading
In fact, many problems are encountered when performing the upload task. Remember to write down a few here ~
fail to resolve: TestProject:datalibrary:unspecified
Solution: put
Change to
For details, see http://stackoverflow.com/questions/36114259/errorfailed-to-resolve-android-iconicslibrary-coreunspecified
return Code 401
Solution: the uploaded account and password are incorrect. Please carefully verify the applied account and password with the Maven warehouse administrator.
Fix the issues identified by lint
The specific screenshot of this error is as follows:
According to the log prompt, we need to add code in the Android field in the build.gradle file of each module
Remember, you have to add every module, or you will make mistakes. It's a bloody lesson
Declare the Maven server that needs to be referenced
Add the following code to build.gradle, the outermost layer of our main project:
Note: since the jcenter, binary, nexus and AAR packages commonly used now are all public, it is not necessary to set the account and password when declaring the Maven server, but for some with the account and password set, you have to add the code for authentication ~
PS: These are bloody lessons. Because I am not familiar with groovy language, I have searched for the keyword credentials for a long time before I know that this product is used to authenticate the account password...
Reference AAR
This is simple. You should be familiar with the code. Add the following code to the build.gradle file in the module that needs to reference this AAR:
The above is the whole content of this article. I hope it will be helpful to your study, and I hope you can support programming tips.