Import from Eclipse to Android Studio not working

Jean-François Côté

I have taken the following steps to migrate to Android Studio but right now I don't know what is wrong.

  1. In Eclipse I exported the gradle file. I did this because importing in Android Studio is not an option since it create a copy of the project and my project is under git.
  2. In Android Studio, I did "Open an existing Android Studio Project" and choose the gradle file.
  3. Since my original project used Maven for Maven dependencies, I add all of these to the gradle file.

Results: Most of the content in the build.gradle file is grayed out, telling me it cannot resolve symbol [name]. When I build, I have more than 100 errors, all of them related to dependencies not present (gradle not doing it's job). Also, I have been using gradle project in the last couple of days and the file is normally always asking to sync and it build the gradle file before building your project. In my case, nothing of that. It's like my project don't know he needs to use gradle or gradle is not configured the right way. Here is my gradle file and some screenshot to help you understand my problem. Any help is appreciated.

build.gradle:

buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:1.1.0'
    }
}
apply plugin: 'com.android.application'

android {
    compileSdkVersion 15
    buildToolsVersion "19.1.0"

    defaultConfig {
        applicationId "XXXXXX"
        minSdkVersion 15
        targetSdkVersion 15

        testApplicationId "XXXXXXX"
        testInstrumentationRunner "android.test.InstrumentationTestRunner"
    }

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_7
        targetCompatibility JavaVersion.VERSION_1_7
    }

    buildTypes {
        release {
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-project.txt'
        }
    }

    packagingOptions {
        exclude 'META-INF/notice.txt'
        exclude 'META-INF/NOTICE.txt'
        exclude 'META-INF/license.txt'
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/ASL2.0'
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/NOTICE'
    }

    sourceSets {
        main {
            manifest.srcFile 'AndroidManifest.xml'
            java.srcDirs = ['src/main/java']
            resources.srcDirs = ['src/main/java']
            aidl.srcDirs = ['src/main/java']
            renderscript.srcDirs = ['src/main/java']
            res.srcDirs = ['res']
            assets.srcDirs = ['assets']
        }
    }
}

dependencies {
    compile group: 'com.google.android', name: 'android', version: '4.1.1.4'  //provided
    compile group: 'org.springframework.android', name: 'spring-android-core', version: '1.0.1.RELEASE'
    compile group: 'commons-io', name: 'commons-io', version: '1.4'
    compile group: 'org.springframework.android', name: 'spring-android-rest-template', version: '1.0.1.RELEASE'
    compile group: 'org.codehaus.jackson', name: 'jackson-core-asl', version: '1.9.13'
    compile group: 'org.codehaus.jackson', name: 'jackson-mapper-asl', version: '1.9.13'
    compile group: 'com.google.code.gson', name: 'gson', version: '2.3'
    compile group: 'org.java-websocket', name: 'Java-WebSocket', version: '1.3.0'
    compile group: 'joda-time', name: 'joda-time', version: '2.3'
    compile group: 'net.erdfelt.android', name: 'apk-parser', version: '1.0.2'
    compile group: 'org.apache.commons', name: 'commons-compress', version: '1.9'
    testCompile group: 'junit', name: 'junit', version: '4.12'
    testCompile group: 'org.mockito', name: 'mockito-core', version: '1.10.8'
    testCompile group: 'org.powermock', name: 'powermock-module-junit4', version: '1.6.1'
    testCompile group: 'org.powermock', name: 'powermock-api-mockito', version: '1.6.1'
}

Screenshot of what it looks like in android studio:

androidstudio

No gradle subfolder in Android View? Is it normal?!enter image description here

Thank you!

EDIT I did like suggested in the comment. I seem to be a step further but I'm having the message: "Gradle project sync failed. Basic functionality will not work properly". In the message below, I have this. What can I do?

Error:Unable to load class 'org.codehaus.groovy.runtime.typehandling.ShortTypeHandling'.
Possible causes for this unexpected error include:<ul><li>You are using JDK version 'java version "1.7.0_75"'. Some versions of JDK 1.7 (e.g. 1.7.0_10) may cause class loading errors in Gradle.
Please update to a newer version (e.g. 1.7.0_67).
<a href="open.project.structure">Open JDK Settings</a></li><li>Gradle's dependency cache may be corrupt (this sometimes occurs after a network connection timeout.)
<a href="syncProject">Re-download dependencies and sync project (requires network)</a></li><li>The state of a Gradle build process (daemon) may be corrupt. Stopping all Gradle daemons may solve this problem.
<a href="stopGradleDaemons">Stop Gradle build processes (requires restart)</a></li></ul>In the case of corrupt Gradle processes, you can also try closing the IDE and then killing all Java processes.
Jean-François Côté

If this can help anyone out there, here are the steps I followed to do the migration.

Exportation of the build.gradle file

  • Go in the Eclipse ADT project and click on File/Export. Choose the "Android" folder and the option "Generate Gradle build files".
  • Follow the wizard and only select the project you want to export.
  • You should have your original project with a new build.gradle file at the root.

Converting Maven dependencies to gradle

If you are using Maven dependencies, all of your dependencies looks like that:

<dependency>
    <groupId>org.springframework.android</groupId>
    <artifactId>spring-android-core</artifactId>
    <version>1.0.1.RELEASE</version>
</dependency>

You need to convert it to this format:

dependencies {
    compile group: 'com.google.android', name: 'android', version: '4.1.1.4'
    testCompile group: 'junit', name: 'junit', version: '4.12'
}

As you can see, if the dependency is needed to compile, put the keyword "compile" in front of it. If it's for the testing, use the keyword "testCompile". Keep that in a temporary file for the moment.

Installing Android Studio and configuring it Install Android Studio from this location: http://developer.android.com/sdk/index.html While it download/install, open your previously generated build.gradle file and change the following things. Replace

apply plugin: 'android'

With

apply plugin: 'com.android.application'

Be sure that your "buildScript" code-block looks like that

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

Finally, add the repositories and dependencies information outside of the android code block.

repositories {
    mavenCentral()
}
dependencies {
   compile 'com.google.android:android:4.1.1.4'
   ...
}

Now that Android Studio is installed, open it. Choose "Import Project (Eclipse ADT, Gradle, etc)" and navigate to the build.gradle file. Android Studio should now create all the metadata and file needed to run the project. If there is an error regarding the version of the tool on your compute, go back to the intro screen of Android Studio and choose "Configure/SDK Manager". Download whatever is necessary for your project to work. When in the project, Go in "File/Project Structure". In the project tab, be sure that the gradle version is 2.2.1 and that the android plugin is 1.1.0. The next step should be to create a configuration and run it on the USB device available or Emulator.

You are good to go!

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Android studio:import NDK project from eclipse

From Dev

Import all settings from Eclipse to Android Studio

From Dev

Android studio Gradle build import from eclipse

From Dev

Import key store from eclipse to android studio

From Dev

import error from eclipse to android studio

From Dev

Android studio:import NDK project from eclipse

From Dev

Android Studio import shortcuts from Eclipse

From Dev

Android Studio Eclipse Import

From Dev

How to import eclipse library project from github to android studio project?

From Dev

How to import eclipse project from git to Android Studio?

From Dev

How to import eclipse project from git to Android Studio?

From Dev

Android Studio / Eclipse import error

From Dev

Android Studio from Eclipse

From Dev

Android Studio from Eclipse

From Dev

Auto import not working for Android classes in Android studio

From Dev

Auto import not working for Android classes in Android studio

From Dev

Unable to import Eclipse project to Android Studio

From Dev

Cannot import Eclipse project into Android Studio

From Dev

Can't import an eclipse project into android studio?

From Dev

Import Eclipse project to Android studio project

From Dev

How to import eclipse project into android studio?

From Dev

Import Eclipse Project from Github to Android Studio - Parse.com tutorial

From Dev

After import from Eclipse to Android Studio cannot run Execution failed for task ':app:dexDebug"

From Dev

Import from Eclipse to Android Studio: Can't find bundle messages.AndroidJpsBundle, locale pl_PL

From Dev

Moving from Eclipse to Android Studio

From Dev

Scandit not working in Android Studio (only works in Eclipse)

From Dev

import to eclipse from android developer tools

From Dev

Import an eclipse android project with version control system into Android Studio

From Dev

python import not working eclipse

Related Related

  1. 1

    Android studio:import NDK project from eclipse

  2. 2

    Import all settings from Eclipse to Android Studio

  3. 3

    Android studio Gradle build import from eclipse

  4. 4

    Import key store from eclipse to android studio

  5. 5

    import error from eclipse to android studio

  6. 6

    Android studio:import NDK project from eclipse

  7. 7

    Android Studio import shortcuts from Eclipse

  8. 8

    Android Studio Eclipse Import

  9. 9

    How to import eclipse library project from github to android studio project?

  10. 10

    How to import eclipse project from git to Android Studio?

  11. 11

    How to import eclipse project from git to Android Studio?

  12. 12

    Android Studio / Eclipse import error

  13. 13

    Android Studio from Eclipse

  14. 14

    Android Studio from Eclipse

  15. 15

    Auto import not working for Android classes in Android studio

  16. 16

    Auto import not working for Android classes in Android studio

  17. 17

    Unable to import Eclipse project to Android Studio

  18. 18

    Cannot import Eclipse project into Android Studio

  19. 19

    Can't import an eclipse project into android studio?

  20. 20

    Import Eclipse project to Android studio project

  21. 21

    How to import eclipse project into android studio?

  22. 22

    Import Eclipse Project from Github to Android Studio - Parse.com tutorial

  23. 23

    After import from Eclipse to Android Studio cannot run Execution failed for task ':app:dexDebug"

  24. 24

    Import from Eclipse to Android Studio: Can't find bundle messages.AndroidJpsBundle, locale pl_PL

  25. 25

    Moving from Eclipse to Android Studio

  26. 26

    Scandit not working in Android Studio (only works in Eclipse)

  27. 27

    import to eclipse from android developer tools

  28. 28

    Import an eclipse android project with version control system into Android Studio

  29. 29

    python import not working eclipse

HotTag

Archive