Error importing Eclipse project to Android Studio

Asked

Viewed 1,775 times

1

Every time I import my project "Radio__santana" from Eclipse to Android Studio, returns this error:

* C:\Users\Cliente\AndroidImageSlideShow\AndroidManifest.xml:
Invalid XML file: C:\Users\Cliente\AndroidImageSlideShow\AndroidManifest.xml:
Premature end of file.

How to migrate correctly?

Android Manifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.rs.player"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk
        android:minSdkVersion="11"
        android:targetSdkVersion="21" />
    <uses-permission android:name="android.permission.INTERNET"/>
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
        <uses-permission
        android:name="android.permission.READ_CONTACTS"></uses-permission>

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@android:style/Theme.Black.NoTitleBar"
         >
        <activity
            android:name=".Home"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
                <activity android:theme="@android:style/Theme.Holo.NoActionBar" 
                    android:label="@string/app_name" 
                    android:name=".Listen" 
                    android:screenOrientation="portrait" class=".Ouvir" />
          <activity android:theme="@android:style/Theme.Black.NoTitleBar" 
                    android:label="@string/app_name" 
                    android:name=".SplashNews" 
                    android:screenOrientation="portrait" class=".SplashActivity" />
            <activity android:theme="@android:style/Theme.Holo.Light" 
                    android:label="@string/app_name" 
                    android:name=".DetailActivity" 
                    android:screenOrientation="portrait" class=".DetailActivity" />
              <activity android:theme="@android:style/Theme.Holo.Light" 
                    android:label="@string/app_name" 
                    android:name=".ListActivity" 
                    android:configChanges="orientation"
                    android:screenOrientation="portrait" class=".ListActivity" />
              <activity android:theme="@android:style/Theme.Holo.Light" 
                    android:label="@string/app_name" 
                    android:name=".SendMessage" 
                    android:configChanges="orientation"
                    android:screenOrientation="portrait" class=".SendMessageActivity" />
              <activity android:theme="@android:style/Theme.Holo.Light" 
                    android:label="@string/app_name" 
                    android:name=".FormActivity" 
                    android:configChanges="orientation"
                    android:screenOrientation="portrait" class=".FormActivity" />
              <activity android:theme="@android:style/Theme.Holo.Light" 
                    android:label="@string/app_name" 
                    android:name=".InviteActivity" 
                    android:configChanges="orientation"
                    android:screenOrientation="portrait" class=".InviteActivity" />
    </application>

</manifest>
  • You can put the text of AndroidManifest.xml so that we can help?

  • I don’t know what you’re saying?

  • I was comparing your manifest with a manifest from a project I did in a group, and I couldn’t find any flaw in yours. You made the files build.gradle by ADT to import to Studio?

  • I imported right through

  • This may be the problem. Use ADT to create the files .gradle and then import ADT projects from the archives .gradle

  • how do I do that?

  • Right click on the project, and go to the option Export..., then go on Android so what, Generate Gradle build files. Then just import the generated files, in Android Studio.

Show 2 more comments

1 answer

1


I managed to do the adaptation manually. First, I just opened the project. And in Android Studio itself I created a file called build.Gradle (what you needed in the project root folder). Code:

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

dependencies {
    compile fileTree(dir: 'libs', include: '*.jar')
}

android {
    compileSdkVersion 18
    buildToolsVersion "18.0.1"

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

        // Move the tests to tests/java, tests/res, etc...
        instrumentTest.setRoot('tests')

        // Move the build types to build-types/<type>
        // For instance, build-types/debug/java, build-types/debug/AndroidManifest.xml, ...
        // This moves them out of them default location under src/<type>/... which would
        // conflict with src/ being used by the main source set.
        // Adding new build types or product flavors should be accompanied
        // by a similar customization.
        debug.setRoot('build-types/debug')
        release.setRoot('build-types/release')
    }
}

I found an easier and faster way to migrate. As above, it is a little outdated. In case, I had to change the classpath for the minimum version of 1.0 (without the +sign). I changed tbm the build version, but this is particularity, because of my application, a newer version is needed. Here is the source:http://tools.android.com/tech-docs/new-build-system/migrating-from-intellij-projects which served basically in the initial stage of the change to the Intellij.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.