After upgrading my Android Studio, I got this error whenever I wanted to generate a signed Apk (without any detail of where the problem is). There was no problem when I just built Apk.
The Host name may not be empty
Check your Gradle scripts root. If there is this file: gradle.properties (Global Properties), check that values are correct.
In my case, I removed all these properties and my problem solved
systemProp.http.proxyHost=
systemProp.http.proxyPort=80
systemProp.https.proxyHost=
systemProp.https.proxyPort=80