Mobile development must understand the issue of "detailed Eclipse to Android Studio
Source: Internet
Author: User
<span id="Label3"></p><p><p></p></p><span class="spacer l"><span class="spacer l">2015-12-09 13:01:24<span class="spacer l spacer-2">4264 views 3 reviews</span> </span></span><p><p></p></p><p><p>As came out more than a year ago, only recently from eclipse to as, but I do not think that using eclipse how backward, they are just a tool, which is easy to use which, the use of good can improve productivity, not reasonable use, and the best tools are Disconsolate. Many Android programmers using eclipse do not know the shortcut keys for code refactoring, How to debug at run time, a workspace a lot of engineering ..., I think even moving to Android studio is not as good as Eclipse.</p></p><p><p>Here are some of the issues that you have encountered in the eclipse transfer as process and the understanding of each issue to facilitate follow-up REVIEW.</p></p><p><p><strong>1. Q: How is Eclipse's project imported into as?</strong></p></p><p><p><strong>answer:</strong> <span class="Apple-converted-space">My approach is to create a new project in as and then copy the files from the corresponding project in eclipse, and, of course, through eclipse, you can lead project to the Gradle version and import the project in AS. </span></p></p><p><p><strong>2, Q: How to handle the local code, how to compile the JNI code?</strong></p></p><p><p><strong>answer:</strong> as <span class="Apple-converted-space">on the same can be developed jni, but the process of configuration script is more troublesome, each gradle version, configuration of some different ways, my way is as on only Java development, JNI or eclipse in the development, easy to compile and debug;</span></p></p><p><p><strong>3. Q: Will development on as be like eclipse, card?</strong></p></p><p><p>a <strong>:</strong> will, card and your entire workspace complexity, if eclipse a work space works relatively little, is not card; as is also the same, if as a workspace has too many projects, the same will be very card, especially when compiling;</p></p><p><p><strong>4, Q: As there is a slow start problem, there is no eclipse that initialization progress has been in the state of 0%?</strong></p></p><p><p>a <strong>:</strong> So far I have not met, even if a workspace has 10 projects.</p></p><p><p><strong>5. Q: Is compilation faster than Eclipse or ant compilation?</strong></p></p><p><p>a <strong>:</strong> Not necessarily, This is also related to the complexity of your project, if your project dependencies are simple, compile with gradle will be very fast, of course, with Eclipse and Ant compilation, and if your engineering dependencies are complex, compile with gradle than with eclipse, Ant is still slow. My advice is: The main project does not rely on too many libproject, otherwise it will compile very slowly, you can package these libproject into aar, so that the same complex project with Gradle compiled with Eclipse and Ant compiler block many;</p></p><p><p><strong>6. What are the advantages of gradle compared to ant?</strong></p></p><p><p>a <strong>:</strong> The advantages are more, the main advantage is the simple configuration, especially in the continuous integration, if it is gradle, a command on the line, if it is ant, you have to write the compilation script.</p></p><p><p><strong>7. Q: How to Configure engineering dependencies in as?</strong></p></p><p><p>a <strong>:</strong> in eclipse, there are several dependencies:</p></p> <ul> <ul> <li>One is the jar package, put directly in the Libs folder (the previous Eclipse version needs to set the BuildPath dependency to calculate the configuration ok);</li> <li>The other is libproject, which requires a right-click main project-properties-android-clicking add to add a dependency, the dependency will be updated to the "project.properties" file under the project root when the configuration is Complete.</li> </ul> </ul><p><p>In the as will be very simple, right-click the main project-open Module setting-select a project, the right of the dependencies option, click "+", respectively Add Library/file/module dependency,library Dependency and file dependency are mostly add jar packages (file Dependency's jar package is placed under the Project's Libs folder), Module Dependency is added Libproject,so put in the project " Libs/the schema folder, You do not need to configure Dependencies. As the dependency configuration is complete, you can view it in the Project's "build.gradle" file. After the dependency configuration is complete, remember to add the following phrase under the Android tab of the Build.gralde file, and the dependency will take effect:</p></p><pre class="prettyprint"><pre class="prettyprint"><code style="margin: 0px; padding: 0px; border-radius: 3px; color: #c7254e; font-family: Menlo, Monaco, Consolas, ‘Courier New‘, monospace; font-size: 1em; font-style: normal; font-weight: 400; background-color: transparent;"><span class="pln">sourceSets <span class="pun">{<span class="pln"> main <span class="pun">{<span class="pln"> jniLibs<span class="pun">.<span class="pln">srcDirs <span class="pun">=<span class="pln"> <span class="pun">[<span class="str">‘libs‘<span class="pun">]<span class="pln"> <span class="pun">}<span class="pln"><span class="pun">}</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></code></pre></pre><p><p><strong>8. Q: What are the similarities and differences between the main projects in Eclipse and as in other projects?</strong></p></p><p><p><strong>For:</strong></p></p> <ul> <ul> <li><strong>same Point:</strong> <span class="Apple-converted-space">both eclipse and as can rely on so, jar packages, and libproject, and the organizational structure is the same, so and jar packages are placed in the Libs folder, and Libproject is a standalone project that requires a manual configuration of Dependencies. </span></li> <li><strong>different points:</strong> <span class="Apple-converted-space">as can also rely on aar, and as in addition to relying on the local library, it can also rely on the library on the server, but eclipse can only rely on the local library. </span></li> </ul> </ul><p><p><strong>9. Q: What is the difference between a jar package and an aar?</strong></p></p><p><p><strong>answer:</strong> the <span class="Apple-converted-space">jar package cannot package so and resource files in, but AAR can, see this Difference. </span></p></p><p><p><strong>10. Q: What are the features that are particularly handy in eclipse, but are not used well in the as?</strong></p></p><p><p>a <strong>:</strong> using shortcut keys in the same class to find the same string (eclipse's shortcut is ctrl+k), as can be used to implement similar functions in F3, but it is particularly inconvenient, because it will play a drop-down list to let you choose; Debugging code during program run (eclipse only needs to select the current process in ddms, Click the Debug button on it, but as does not find this feature, it may be the version of my as issue).</p></p><p><p><strong>11, Q: As the use of the process encountered what problems, how to solve?</strong></p></p><p><p><strong>For:</strong></p></p> <ul> <ul> <li> Assets File directory in the "src/main/" directory, and java, res folder peer, </li> <li> aidl file needs to create a separate folder in the "src/main/" directory, and then created the corresponding package name, Place the Aidl file under the package name Package. The </li> <li> reference to so in the Libs folder requires the following attributes to be added under the Android tab of the Build.gradle file under the corresponding module: </li> </ul> </ul><pre class="prettyprint"><pre class="prettyprint"><code style="margin:0px; padding:0px; border-radius:3px; color: #c7254e; font-family:menlo, Monaco, consolas, ' Courier New ', monospace; font-size:1em; font-style:normal; font-weight:400; background-color:transparent; "><span class="pln"> Android <span class="pun">{<span class="pln"> sourcesets <span class="pun">{<span class="p ln "> main <span class=" pun ">{<span class=" PLN "> jnilibs<span class=" pun ">.<span class="pun" srcdirs <span>=<span class="pln"> <span class="pun">[<span class="str"> ' Libs ' <span class="pun">]< Span class= "pln" > <span class="pun">}<span class="pln"> <span class="pun">}<span class="pln"> <span class="pun">} </span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span> </span></span></code></pre></pre> <ul> <ul> <li> <p> Android Studio's compile-time masking lint Check avoids problems that are compiled because of a compilation condition that is too restrictive: </p> <pre class="prettyprint"><code style="margin: 0px; padding:0px; border-radius:3px; Color: #c7254e; font-family:menlo, Monaco, consolas, ' Courier New ', monospace; font-size:1em; font-style:normal; font-weight:400; background-color:transparent; "><span class="pln"> lintoptions <span class="pun">{<span class="pln"> abortonerror <span class="kwd">false<span class="pln"> <span class="pun">} </span> </span> </span> </span> </span> </span> </code> </pre> </li> <li> If you encounter a file conflict in multiple jar packages, You can add the following attributes under the Android tab of the Build.gradle file under Module: </li> </ul> </ul><pre class="prettyprint"><pre class="prettyprint"><code style="margin: 0px; padding: 0px; border-radius: 3px; color: #c7254e; font-family: Menlo, Monaco, Consolas, ‘Courier New‘, monospace; font-size: 1em; font-style: normal; font-weight: 400; background-color: transparent;"><span class="pln"> packagingOptions <span class="pun">{<span class="pln"> exclude <span class="str">‘META-INF/NOTICE.txt‘<span class="com">// 这里是具体的冲突文件全路径<span class="pln"> exclude <span class="str">‘META-INF/LICENSE.txt‘<span class="pln"> <span class="pun">}</span></span></span></span></span></span></span></span></span></code></pre></pre> <ul> <li><li>Adjust the color of the Logcat file display: file→setting→editor→colors&fonts→android logcat→ adjusts the color of the log at each level Logcat the right side of the interface;</li></li> <li><li>Display line number: file→setting→editor→general→appearance→ check "show lines numbers";</li></li> <li><li>In the console of logcat, "no debuggable applications" problem is displayed: tools→android→enable ADB integration;</li></li> <li><li>If you rely on the project and the main project has the same type of resource files, you need to modify the dependencies in the project resource name compilation will not error, if the dependency project in this resource file is not required for the entire project, you can directly delete;</li></li> <li><li>A master project in Android Studio that relies on multiple libraries is slow to compile (clean and rebuild, which is the pattern in eclipse), Because this kind of engineering framework is the main project and each dependent project has a build.gradle, it will take a long time to compile, can be no resource files and so of the dependency project into a jar package, there are resource files and so packaged into AAR files, and then referenced in the main project, so that the compilation will be quick;</li></li> <li><li>Android Studio is very strict with the nine diagram, if the file ends with ". 9.png" But the picture is not 9, the compilation will be error, the solution is to open the image directly in as, the 9 diagram editing tools to edit 9 diagram;</li></li> <li><li>There are two ways to modify the dependencies between Module: (1) modify the dependencies in the Build.gradle file of each module directly, (2) right-click Project→open module settings→ in the left modules column of the popup panel, select the module to modify the dependency, click on the right side of the depencencies tag to modify;</li></li> <li><li>Android Studio Auto guide: file→settings→editor→general→auto import→java→ Toggle "Insert Imports on paste" to "all" → Tick "Add Unambigious imports on the fly ";</li></li> <li><li>Code formatting shortcut Keys: <code style="margin: 0px; padding: 0px; border-radius: 3px; color: #c7254e; font-family: Menlo, Monaco, Consolas, ‘Courier New‘, monospace; font-size: 0.92em; font-style: normal; font-weight: 400; background-color: #f3f3f3;">CTRL+ALT+L</code> ;</li></li> <li><li>To rename a folder or file shortcut keys: <code style="margin: 0px; padding: 0px; border-radius: 3px; color: #c7254e; font-family: Menlo, Monaco, Consolas, ‘Courier New‘, monospace; font-size: 0.92em; font-style: normal; font-weight: 400; background-color: #f3f3f3;">ALT+SHIFT+R</code> ;</li></li> <li><li>When the mouse hovers over a method, the information for that method is displayed: preferences→editor→show doc on mouse move;</li></li> <li><li>Delete a module, Select the module directly in the IDE and press DELETE is not deleted, you need to right-click Project→open module settings→ in the left modules column of the popup panel, select the "-" icon in the upper left corner of the panel to remove module→ click on the "-" symbol → Click OK to return to the ide, and then select the module to be deleted, Press the Delte shortcut key to delete it;</li></li> <li><li>Android Studio performs lint and other tools for code detection, analyze→inspect codes;</li></li> <li><li>Import aar: Copy AAR to the Libs folder and add the following to the Module's Build.gradle file:</li></li> </ul><pre class="prettyprint"><pre class="prettyprint"><code style="margin: 0px; padding: 0px; border-radius: 3px; color: #c7254e; font-family: Menlo, Monaco, Consolas, ‘Courier New‘, monospace; font-size: 1em; font-style: normal; font-weight: 400; background-color: transparent;"><span class="pln"> repositories <span class="pun">{<span class="pln"> flatDir<span class="pun">()<span class="pln"> <span class="pun">{<span class="pln"> dirs <span class="str">‘libs‘<span class="pln"> <span class="pun">}<span class="pln"> <span class="pun">}</span></span></span></span></span></span></span></span></span></span></span></span></code></pre></pre><p><p>The AAR file is then referenced in the Build.gradle dependencies tag in the following format: compile (name: ' AAR package name without extension ', ext: ' aar ')</p></p><p><p><strong>12. Q: What are the new tools or features that are more convenient than eclipse?</strong></p></p><p><p><strong>For:</strong></p></p> <ul> <ul> <li>Tools to view the memory footprint and memory changes of the app;</li> <li>A tool for viewing network usage during app operation;</li> <li>Tools for viewing CPU and GPU usage;</li> <li>Code Cleanup (analyze-code Cleanup .... ), Code static Check tool (enhanced Ling check tool, analyze-inspect code ....) );</li> <li>The DOS window can be used directly;</li> <li>The ability to code and bookmark (eclipse also has, but not previously used);</li> <li>IDE 9 diagram Editing function;</li> <li>Shortcut keys</li> <li>...... A lot of a lot of small features, with the special convenience of Cooked.</li> </ul> </ul><p><p><strong>13, Q: In the process of using as, what advice?</strong></p></p><p><p>a <strong>:</strong> just like when using eclipse do not easily update adt, in the process of using as do not easily update Gradle and as, each version will have some differences, there will be a lot of pits, or wait for a new version come out for a period of time, more stable and then use, After all, the IDE is a productivity tool, and it's boring to spend a lot of time learning how to use and solve problems in the Process.</p></p><p><p></p></p><p><p>Mobile development must understand the issue of "detailed Eclipse to Android Studio</p></p></span>
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