3

I'm trying to migrate my Eclipse ADT project to Android Studio and it's not working.

Here is the thing:

  • My project include android support v4 and v7, and play services and other .jars

What do I use:

  • ADT 22.0.1
  • Android Studio 0.3.6

What have I done:

  • Set my ANDROID_HOME var to my android sdk path
  • Exported ADT project to Gradle (as explained on Android website)
  • Replace some parameters, like absolute path to relative path (see below in gradles)
  • Some Stack Overflow answers tricks (but not useful for now)

Here are the Gradle specs:

  • settings.gradle

    include ':Project'

  • gradle\wrapper\gradle-wrapper.properties

    distributionBase=GRADLE_USER_HOME
    distributionPath=wrapper/dists
    zipStoreBase=GRADLE_USER_HOME
    zipStorePath=wrapper/dists
    distributionUrl=http\://services.gradle.org/distributions/gradle-1.8-all.zip
    
  • Project\build.gradle

    buildscript {
        repositories {
            mavenCentral()
        }
        dependencies {
            classpath 'com.android.tools.build:gradle:0.6.+'
        }
    }
    apply plugin: 'android'
    
    dependencies {
        compile 'com.android.support:support-v4:18.0.0'
        compile 'com.android.support:appcompat-v7:18.0.+'
        compile 'com.google.android.gms:play-services:3.1.36'
        compile fileTree(dir: 'libs', include: '*.jar')
    }
    
    android {
        compileSdkVersion 17
        buildToolsVersion "19.0.0"
    
        sourceSets {
            main {
                manifest.srcFile 'AndroidManifest.xml'
                java.srcDirs = ['src']
                resources.srcDirs = ['src']
                aidl.srcDirs = ['src']
                renderscript.srcDirs = ['src']
                res.srcDirs = ['res']
                assets.srcDirs = ['assets']
            }
    
            instrumentTest.setRoot('tests')
        }
    }
    

Now when I (try to) import the project in Android Studio, I got an error message:

Could not execute build using Gradle distribution 'http://services.gradle.org/distributions/gradle-1.8-all.zip'. Task 'wrapper' not found in project ':Project'.

What now ?:

How can I progress this further?

halfer
  • 19,824
  • 17
  • 99
  • 186
Quentin Klein
  • 1,263
  • 10
  • 27

4 Answers4

0

Update your Android Studio from Help > "Check For updates"

Takermania
  • 1,345
  • 2
  • 12
  • 20
0

This is not a great solution, is not a clean one, but it worked for me: Create a new project from scratch and copy all the files do you need from eclipse to android studio. This was the way I did it and it worked. It is a pain in the ass to migrate from eclipse to android studio and vice-versa

Hitman
  • 588
  • 4
  • 10
  • Yeah, it's the final solution I think, the thing is that we have a complete git history and we would like to keep it. But I'm gonna try this anyway – Quentin Klein Dec 02 '13 at 10:01
  • Yes, I know... you can try to link the .git folder of the eclipse project in android studio, maybe it is a way to do that :-? – Hitman Dec 02 '13 at 10:03
  • if you managed to link the .git as well please tell me how you did it :) – Hitman Dec 03 '13 at 06:34
  • Hum ok I've done the git linking but there is not enought characters to explain on a comment :/ I used 3 folders -1st is the old ADT Repo -2nd is a swap folder -3rd is AS Repo. Copy .git from ADT Repo to AS Repo, add everything, commit (lot of rename) If you have another branch the tricks is to use SWAP for keeping AS tree structure. Copy AS Repo to SWAP (except .git), checkout on AS (got an ADT tree structure). Then copy SWAP to AS Repo, in order to get your src changes, on ADT repo, checkout and copy your src/res/manifest on AS Repo, add everything and commit. Hope it helped :) – Quentin Klein Dec 03 '13 at 16:46
  • I know it's a bit confused but in a comment it's not easy. Tell me if you get the trick or what :) – Quentin Klein Dec 03 '13 at 16:47
  • ok, interesting.. I think I get it, thanks for explanations :) – Hitman Dec 04 '13 at 06:08
0

Open eclipse and right click on your project. Then Select Export. It will open in which you have to click on Android then select generate Gradle build file.

Jitesh Dalsaniya
  • 1,917
  • 3
  • 20
  • 36
0

In Project Settings, go to Gradle and select "Use default gradle wrapper (recommended)". Be sure to do this for every project at the top of that dialog window.

If the option is disabled for any of the projects, what I had to do to enable it was to copy the gradle/wrapper files (gradle-wrapper.jar and gradle-wrapper.properties) into a gradle/wrapper subdirectory under each project.

Eric Pabst
  • 536
  • 4
  • 12