-2

I get this error message after I moved my project folder to another location on my pc and tried to run my app.

Error Message

Installation failed with message Invalid File:
C:\Users\Zhong\AndroidStudioProjects\HappyBirthday\app\build\intermediates\split-apk\debug\slices\slice_1.apk.
It is possible that this issue is resolved by uninstalling an existing version of the apk if it is present, and then re-installing.
WARNING: Uninstalling will remove the application data!
Do you want to uninstall the existing application?

But actually my project folder is currently under D:\\

Everything works fine with instant run disabled, but if I enable instant run and click the run button, this error message will appear again.

It seems that the paths of those files are not automatically changed in some files.

I've tried to find some settings to fix that but no luck. I'm new to android developing, please help me with this simple problem.

Blasanka
  • 21,001
  • 12
  • 102
  • 104
AlumiK
  • 57
  • 6

1 Answers1

0

If you turn off Instant Run, you won't lose anything :)

But if you want, you can try to rebuild the project. Click Build > Clean project. Also you may go to a project folder, then in "app" folder, delete a folder "build" and then again rebuild a project in Android Studio.

CoolMind
  • 26,736
  • 15
  • 188
  • 224
  • Actually I've already tried that one (Clean Project). This particular error does go away, but after I successfully install the app on my phone, it won't run.Log: – AlumiK May 24 '17 at 10:48
  • 05-24 18:48:53.841 21967-21967/top.aluminumk.happybirthday E/AndroidRuntime: FATAL EXCEPTION: main Process: top.aluminumk.happybirthday, PID: 21967 java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{top.aluminumk.happybirthday/top.aluminumk.happybirthday.MainActivity}: java.lang.ClassNotFoundException: Didn't find class "top.aluminumk.happybirthday.MainActivity" on path:...... – AlumiK May 24 '17 at 10:50
  • I can't understand, have you deleted the apk from a smartphone? – CoolMind May 24 '17 at 10:50
  • no. but once i disable instant run everything will go back to normal again. – AlumiK May 24 '17 at 10:53
  • But why don't you want to uninstall the apk? Instant Run saves some information there. – CoolMind May 24 '17 at 10:54
  • Maybe read something like https://stackoverflow.com/questions/32718044/android-studio-application-installation-failed or https://stackoverflow.com/questions/40757663/i-getting-error-when-i-install-my-android-studio-project-in-device-redmi-3s-prim? – CoolMind May 24 '17 at 10:56
  • i attached a new smartphone to my computer and i still get something like java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{top.aluminumk.happybirthday/top.aluminumk.happybirthday.MainActivity}: java.lang.ClassNotFoundException: Didn't find class "top.aluminum again, if i disable instant run and re-run the app from android studio everything works fine – AlumiK May 24 '17 at 10:57
  • Post your AndroidManifest, please. Also maybe a MainActivity. – CoolMind May 24 '17 at 10:58
  • thank you for your answer but i think this problem has nothing to do with these files, for if i create a new project and paste these files to my new project folder, i can use instant run normally. but, if i move the new project folder to another location, this kind of error will appear again. so i suppose i just need to find a way to change my project folder path manually for instant run. – AlumiK May 24 '17 at 11:06