0

Problem

I am trying to run my android studio app on my samsung phone on an ubuntu computer. Whenever I try to run the app on my phone, it will say installing APK, then instantly give me the error:

 INSTALL_PARSE_FAILED_BAD_PACKAGE_NAME: Invalid manifest package: must have at least one '.' separator.

I have never ran my app on an emulator, so this is the first time running my app.

What I think the problem is

The APK that is being built is called app-dev19-debug.apk, and I think android doesn't allow dashes in their apk names. I have tried to change the name by putting this code into my build.gradle (Module: app and Project: android):

   def appendVersionNameVersionCode(variant, defaultConfig) {
  //check if staging variant
  if(variant.name == android.buildTypes.staging.name){
    if(variant.zipAlign) {
      def file = variant.outputFile
      def fileName = file.name.replace(".apk", "-" + defaultConfig.versionName + "-" + defaultConfig.versionCode + ".apk")
      variant.outputFile = new File(file.parent, fileName)
    }

    def file = variant.packageApplication.outputFile
    def fileName = file.name.replace(".apk", "-" + defaultConfig.versionName + "-" + defaultConfig.versionCode + ".apk")
    variant.packageApplication.outputFile = new File(file.parent, fileName)
  }
}

I got this code from this answer: https://stackoverflow.com/a/22126638/8749566

I know this is probably a really basic question, but I am really new to android studio, and don't really understand much yet. I would love some help fixing the error.

GIISE
  • 743
  • 3
  • 9
  • 24

0 Answers0