Implementation method of one click packaging and uploading to dandelion of Android apk project

  • 2021-12-04 11:26:17
  • OfStack

Item 1 key package and upload to dandelion

Reason: The test process is composed of

Packing Find a package to upload Fill in the update information Then upload

Too complicated to simplify development

Note: Readers need to know how to create an empty gradle plugin in the project, otherwise this article is not suitable for you

Begin analysis

The effect I want is to simplify the steps, such as typing a command.\ gradlew xxxx
You can accomplish the effect I want
Then first we must be familiar with or complete the following points:

Packet path Packaging completed callbacks Entry setting parameters set the parameters to be transferred Use gradle to develop

Start development based on the above points

The most important point is that the callback after packing is completed. Because the order is that you can do anything else before packing first, the subsequent event callback should occur after packing is completed
eg: I want to make an debug package. Our 1 gradlew assembleDebug
Then let's just write the callback like this


task.dependsOn("assembleDebug")
task.actions.add{
	//todo  Subsequent operations 
}

This way, you can finish the package and call back the subsequent events

Start uploading packets

Question? Where's the bag? How do I know where the bag is
Get the packet path by getting outputs in AppExtension
Code on (written by kotlin)


val android = project.extensions.getByType(AppExtension::class.java)

        android.applicationVariants.forEach {
          it.outputs.forEach {output->
              output.name
              output.outputFile
          }
        }

output. name is the first name (String)
output. outputFile is a file (File)

Upload

You can use your familiar api to upload files when you get the files. This is the basic operation

Set up the operation entry

Upper code


project.task("oneKeyPackaged") {task->
	//todo  Packaging operation 
}

Happy package upload

./gradlew oneKeyPackaged
oneKeyPackaged This is the task name you set above

Summarize


Related articles: