Android Studio import Eclipse Project and some common issues

Source: Internet
Author: User

Android Studio version

Eclipse Project Engineering: A master project, a Emojicon dependent library.

There are two ways to import Eclipse projects:

1. Compatible with Eclipse

2. New Android Gradle Project

Google recommends a completely new approach, so compatibility mode import is not covered here.

Please close the current project in Android Studio, or you won't see import project.

Select Import Project (Eclipse ADT, Gradle, etc) to navigate to the home directory of the project you need to import. Because the home directory and Emojicon have dependencies, Android Studio automatically associates it in. Then specify a saved directory and click Next.

By default, the following options are ticked (if not ticked, manually ticked), the direct finish is OK.

After a period of conversion, you will see the following structure

I have hidden the name of the main project, and now I can see that Emojicon is indeed in the lead. However, the Java directory under the Emojicon is added in the following, the default import when this folder does not exist, why? Look down.

When Android Studio is finished importing, the Import-summary.txt file is opened by default in the window, which records some of the import considerations. This file has several nodes that need attention, as follows:

Manifest Merging

Ignored Files

Replaced Jars with Dependencies

Manifest merging in the text below, that is, describe your manifest file, basically no tube.

Your Project uses libraries that provide manifests, and Your eclipseproject do not explicitly turn on manifest mergin G. in Android gradleprojects, manifests is always merged (meaning this contents from Yourlibraries' manifests would b E merged into the app manifest.  If you hadmanually copied contents from the library manifests into your app manifestyou could need to Remov for The app to build correctly.

Ignored Files, this part is very important. It means that Android studio has ignored these files when importing the project, and you have to copy them manually if needed. Because the main project relies on Emojicon, copy this file to the appropriate location.

The following files were *not* copied into the new Gradle project; youshould evaluate whether these is still needed in your project and ifSo manually move Them:from Emojicon:*. Gitignore*Java*java\com*Java\com\rockerhieu*Java\com\rockerhieu\emojicon*Java\com\rockerhieu\emojicon\emojiadapter.java*Java\com\rockerhieu\emojicon\emojiconedittext.java*Java\com\rockerhieu\emojicon\emojicongridfragment.java*Java\com\rockerhieu\emojicon\emojiconhandler.java*Java\com\rockerhieu\emojicon\emojiconspan.java*Java\com\rockerhieu\emojicon\emojicontextview.java*Java\com\rockerhieu\emojicon\emojiconsfragment.java*Java\com\rockerhieu\emojicon\emoji*Java\com\rockerhieu\emojicon\emoji\emojicon.java*Java\com\rockerhieu\emojicon\emoji\nature.java*Java\com\rockerhieu\emojicon\emoji\objects.java*Java\com\rockerhieu\emojicon\emoji\people.java*Java\com\rockerhieu\emojicon\emoji\places.java* Java\com\rockerhieu\emojicon\emoji\symbols.java

Replaced Jars with Dependencies to indicate how your original jar package will exist in the Android studio project.

Import Wizard and try again:android-support-v4.jar = com.android.support:support-v4:22.2.1

Where did the old Libs folder go?

Right-click on your Module,open Module Settings, which appears as follows:

In fact, Android Studio can add online libraries and jars, see the MAVEN central word it? The corresponding jar will be downloaded on demand.

At this point, the project can build. It's not that easy to run successfully.

Error:duplicate files during packaging of APK .....

Said to be duplicate files copied in APK Meta-inf/notice.txt

Duplicate files copied in APK Meta-inf/license.txt

Workaround: Add packagingoptions to the Android node in the Build.gradle under your module

Android {    ...    packagingoptions{        ' meta-inf/notice.txt        ' meta-inf/license.txt '}    

There is also a bug tip:Manifest merger failed with multiple errors, see logs

Suggestion:add ' tools:replace= ' Android:icon ' to <application> element @ androidmanifest.xml:24:5 to override

Cause: Android Studio uses the manifest merger Tool by default, and if the library project also defines the same properties as the main project (such as the default generated Android:icon, Android:theme), the merge fails.

Resolution 1: Introduced in androidmanifest.xml node manifest

Xmlns:tools= "Http://schemas.android.com/tools"

Then add the application node

Tools:replace= "Android:icon"

Or you need to mask the theme, separated by commas in the middle.

Tools:replace= "Android:icon, Android:theme"

Resolution 2: Add Useoldmanifestmerger True to the Build.gradle root tag, but in Android Studio 2.0 you are prompted not to find this useoldmanifestmerger, I do not know whether the improvement or the use of other fields (this method has a problem, who knows why?) )。

Android {     true  }

Please refer to the official introduction: Manifest merger

Well, that's basically the two problems, and then you can run.

Android Studio import Eclipse Project and some common issues

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.