There is a nice Gradle plugin called Gradle Witness which can solve this issue.
When gradle retrieves the artifact, it will also retrieve the md5sum and sha1sums to verify that they match the calculated md5sum and sha1sum of the retrieved files. The problem, obviously, is that if someone is able to compromise the remote maven repository and change the jar/aar for a dependency to include some malicious functionality, they could just as easily change the md5sum and sha1sum values the repository advertises as well
This gradle plugin simply allows the author of a project to statically specify the sha256sum of the dependencies that it uses.
Moreover, take a look at this SO question about dependency authenticity, it could interest you too.