unexpected local path

Playing with Android Studio yesterday and migrating some of my previous projects, I received an annoying error that I thought was resolved by cleaning the project and importing it again. Unfortunately, the error came back again. The post will show how you can resolve the error.

unexpected local path2

When I review the file system, I have noticed that the apk is generated in a different location and with a different name.

However, it seems that Android studio doesn’t want to use the APK for debugging. After some tests and painful experimentation the error occured because there is an option that was not included in the “.iml” file and that you can configure and fix the problem. There are multiple “.iml” files, one is for the master project and one for the modules that produces the apk.

Steps to fix the error:

  1. Locate the inner .iml file ( for exampe ProjectName->Project ->ProjectName.iml) and open it with text editor.
  2. You need to add the following option with the path respective to you project
    <option name="APK_PATH" value="/build/apk/ProjectName-debug-unaligned.apk" />
  3. Build->Rebuild Project
  4. Done

You should now be able to debug again to any device with Android Studio.

Also read: