7

I imported my Eclipse project into Android using Gradle. At first I had problems with R.java but I resolved them by adding 'gen' folder as sources in Project Settings.

However, even though Android Studio doesn't show any errors any more, when I'm trying to deploy the project onto my Android device, I get the error:

Waiting for device.
Target device: 01c47c94e112d5fb
Uploading file
local path: C:\Users\Szymon\Eclipse\Android App\build\apk\Android App-debug-unaligned.apk
remote path: /data/local/tmp/szym1000.androidapp
Local path doesn't exist.`

I checked my Android App folder and there is no build folder, that's true. But why didn't Android Studio generate it?

I found someone had a similar problem here. However, I have no idea how to run the gradlew packageDebug in Android Studio. Any ideas?

Community
  • 1
  • 1
Szymon Przedwojski
  • 181
  • 2
  • 4
  • 12
  • Ok of course I had to run it from `cmd.exe`. Then I had to add JAVA_HOME as the environmental variable. But it still doesn't work properly. In the cmd it says: `The TaskContainer.add() method has been deprecated (...). Please use the create method instead.` And later on: `Execution failed for task ':compileDebugAidl'. >failed to parse SDK!` Any ideas guys? – Szymon Przedwojski Jun 16 '13 at 11:53
  • 1
    possible duplicate of [Android Studio - local path doesn't exist](http://stackoverflow.com/questions/18256177/android-studio-local-path-doesnt-exist) – Eron Villarreal Oct 29 '13 at 20:13
  • Where do you actually see the path? – committedandroider Dec 21 '14 at 21:57

9 Answers9

23

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. Don't worry about the deprecated method statement - it seems to be a generic notice to developers.

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 now be able to find the apk when you navigate the local path -- and even better, your program should install/run on the device/emulator!

alikonda
  • 1,186
  • 9
  • 7
13

You should try this little button in the toolbar: Sync with Graddle files icon

It should fix your problem.

if not, make sure your settings in build.gradle are set to 0.6.+

buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:0.6.+'
    }
}

And then click on the button again.

Distwo
  • 11,569
  • 8
  • 42
  • 65
  • Funny. Right clicking on the project and syncing didn't do anything, but the button sure did. Thanks! – leenephi Dec 12 '13 at 02:44
  • This answer helped a lot! I've upgraded from 0.2.11 to 0.4 and I could not run my app on device. Changing the gradle wrapper settings and using the button mentioned in answer solved everything! THANKS! – Krystian Dec 23 '13 at 23:44
  • What does that button do? I don't have it in my toolbar and I'm not sure how to add it. – CACuzcatlan Nov 24 '14 at 08:53
  • This button sync your project with your gradle configuration. – Distwo Nov 24 '14 at 16:55
5

Try: Android Studio menu "File", "Invalidate Caches / Restarts..." For me "gradle clean packageDebug" don't works...

(I develop on two Pc and paths of src/build are different)

Manzolo
  • 1,909
  • 12
  • 13
2

This is because you have "spaces" in your folder name!!!

Please remove the "spaces" and try again!!!

The Finest Artist
  • 3,150
  • 29
  • 34
1

If you are on windows, to run gradlew:

  1. Open a command prompt and navigate to your project folder

  2. Run gradlew batch using the following command:

    start gradlew clean packageDebug

Hope that help.

Distwo
  • 11,569
  • 8
  • 42
  • 65
0

You need to run the assemble task before you can export any apk file.

From the right hand side, open the gradle task

To export debug apk file:

  1. Open Build Variants form the left bottom corner. Select Build variant as "debug".
  2. Open Gradle tasks from right hand side. Run assembleDebug
  3. Generate the apk file using Build > Generate signed apk file. Note that though the option says "signed" apk it will generate a debug apk as the build variant selected is debug

To export release apk file:

  1. Open Build Variants form the left bottom corner. Select Build variant as "release".
  2. Open Gradle tasks from right hand side. Run assembleRelease
  3. Generate the apk file using Build > Generate signed apk file. Note that signed apk will not generate a signed apk if you have build variant selected as debug. Make sure that the build variant is selected as release
anirus
  • 1,597
  • 2
  • 18
  • 24
0

follow these steps. This worked for me...

  1. Go to your project directory.In that directory search for .apk file....
  2. You will find a apk with name of your project+debug-unalighned.apk.
  3. Open .iml file insideyour project folder that contain project source directory.
  4. Open it.add

    write <option name="APK_PATH" value="/build/apk/(apk file name that was found earlier with apk extension)" /> inside <configration> <configration/> tags.

    Now go and run your project...

PROBLEMO SOLVED....:)

Minto
  • 2,004
  • 1
  • 15
  • 19
0

if you use adb, just restart your device (Phone, Tablet, ...), That works for me.

Hamidreza Sadegh
  • 2,155
  • 31
  • 33
-1

Check permissions on your SDK directory

Dežo
  • 51
  • 4