A tutorial to solve a general problem that occurs in android studio that is Gradle sync failed: Failed to find target with hash string
to solve this all you need to do is download the missing version of api from SDK manager and build the gradle again and its done.