2

I rename my output apk file with gradle:

buildTypes {
    debug {
        ...
        applicationVariants.all { variant ->
            variant.outputs.each { output ->
                output.outputFile = new File(output.outputFile.parent,
                        output.outputFile.name.replace("-debug", "-GGG-" + getDate())
                )
            }
        }
    }
}

def getDate() {
    def date = new Date()
    def formattedDate = date.format('yyyyMMddHHmm')
    return formattedDate
}

But i get error when try to install app to phone through Android Studio:

The APK file C:\...\app\build\outputs\apk\app-GGG-201604191416.apk does not exist on disk.
Error while Installing APK

However, file what should install named app-GGG-201604191431.apk. Why Android Studio try to install early apk, and how i can solve it?

Gogi Bobina
  • 1,086
  • 1
  • 8
  • 25

2 Answers2

1

Had the same problem. Hit the "Refresh all Gradle Projects" button in the Gradle pane and do a project clean.

Johann
  • 27,536
  • 39
  • 165
  • 279
0

android studio's installation command is still referring to previous apk app-GGG-201604191416.apk but on assemble you generated an apk with different name app-GGG-201604191431.apk. you are making the apk name prone to date-time. So the script which is run for installation is not taking that change.

check this or this Something similar is in those links that you can relate to get your problem solved.

Community
  • 1
  • 1
srv_sud
  • 647
  • 1
  • 9
  • 26