I recently attempted to migrate my Eclipse project over to Android Studio. All went well until I attempted to run the project and an error came up:
Uploading
Please verify if JAVA_HOME is OK.
https://confluence.atlassian.com/display/DOC/Setting+the+JAVA_HOME+Variable+in+Windows
It was my problem here and fixed after insert JAVA_HOME i
I just ran into this problem, even without transferring from Eclipse, and was frustrated because I kept showing no compile or packageDebug errors. Somehow it all fixes itself if you clean and THEN run packageDebug.
Open up a commandline, and in your project's root directory, run:
./gradlew clean packageDebug
Obviously, if either of these steps shows errors, you should fix those...But when they both succeed you should be able to find the apk when you navigate the local path -- and even better, your program should install/run on the device/emulator!
You can also check your project .iml file to see that the correct APK_PATH is set
I used these steps:
Go to your project folder. Open ProjectName folder.
In file Your_Project_name.iml add
<option name="APK_PATH" value="/build/apk/your_app_name-debug-unaligned.apk" />
Or
<option name="APK_PATH" value="/build/outputs/apk/your_app_name-debug-unaligned.apk"/>
In new versions of Android studio
I've encountered this problem after migrating from Eclipse to Android Studio. As shantanu said,
gradlew packageDebug
helped to point out that I need local.properties
file, so I've created it in the project root with just one line, and after that all works fine.
local.properties
contain only one property - sdk.dir
, and looks like (in Windows):
sdk.dir=c:\\path-to-android-studio\\sdk
Don't forget to change \
in your path to \\
(there's no need to escape /
in Linux or Mac).
Wrote this answer only to gather all info about common problem after migrating from Eclipse to Android Studio to help many people get rid of this little trouble faster without googling every step.