Project migration from Eclipse to Android studio

Source: Internet
Author: User

All along, the company was developed with Eclipse, but as our application grew, the project structure grew larger, the dependencies between projects became complex, and the eclipse management looked very difficult, and often a colleague changed dependencies, and people were updating, and there was a problem. Because these things waste a lot of time. Finally decided to migrate to Android Studio. However, the migration process has encountered a lot of problems, through this blog, the migration process encountered problems, as well as the solution of each problem, and also hope to help the students with the same needs.

The process of importing from Eclipse into Android Studio is not covered in detail here.

1. Garbled characters

Using Eclipse Development-time coding is GBK, and Android Studio uses UTF-8, so the temperature symbols in the project and some Chinese comments are garbled when the build occurs.

Solution Solutions

Unified coding, we changed the code to UTF-8. Android Studio changes the encoding of the project and the file in the following ways:

Search file-----Settings, Default Settings---the Code for three places (IDE encoding,project Encoding,defaul T encoding for properties files)
2. Duplicate images We have a library is extracted from the main project, the process of extracting a lot of pictures from the main project after the copy, forget to delete, import into the Android studio, the build process will be wrong, but the error message is prompted to duplicate the file, We just need to delete the unused pictures according to the prompts. 3. Unable to execute Dex:method ID ' not ' in [0, 0xFFFF]: 65536 for this issue, Google official gave an explanation, Http://developer.android.com/tools/buil Ding/multidex.html, probably means: when your application and application-dependent libraries reach a certain size, this error will be prompted at build, stating that your app has reached the limit of the Android app build architecture. Android virtual machines limit the number of method 65536 that each Dex file can reference, including Android Framework,library, and the sum of methods in its own project.
The solution generates multiple Dex files for our application and needs to be configured in the Build.gradle, file:
Android {   Defaultconfig {      ...      Multidexenabled = True   }}
Also, to use the Multidexapplication class, if your application already has the application class, you need to let it inherit from Multidexapplication, and then implement the Attachbasecontext method, the code is as follows:
protected void Attachbasecontext (Context base) {Super.attachbasecontext (base); Multidex.install (this);}
4. OUTOFMEMORYERROR:GC overhead limit exceeded the following configuration in the Build.gradle file:
Android {... dexoptions {        incremental true        javamaxheapsize "4g"}    }
5. Java.util.zip.ZipException:duplicate entry during Packagealldebugclassesformultidex error message is as follows:
Error:execution failed for task ': Ezweather_original:packagealldebugclassesformultidex ' .> Java.util.zip.ZipException:duplicate Entry:android/support/annotation/colorres.class
Solution, add the following configuration in Build.gradle:
Configurations {all*.exclude group: ' Com.android.support ', module: ' Support-v4 '}

At this time the app can finally run up ...

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Project migration from Eclipse to Android studio

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.