Android eclipse转studio的流程及问题

来源:互联网 发布:软件开发毕业设计题目 编辑:程序博客网 时间:2024/05/20 22:41

    废话不说进入正题,我感觉也没有人看我的废话...

    网上说有两种办法,这里只写其一:

    

  • 打开Import

    • 新用户:
       将Eclipse代码导入到AndroidStudio的两种方式
    • 老用户: File-->Import Project
       将Eclipse代码导入到AndroidStudio的两种方式
  • 直接找到原有的Eclipse工程

    • 单一工程直接导入即可。
    • 有库工程的需要注意,导入一定要指向主工程,而不是整个项目的目录。指向项目目录是无法进行转换的。
       将Eclipse代码导入到AndroidStudio的两种方式
  • 指定目标路径
     将Eclipse代码导入到AndroidStudio的两种方式
  • 这个地方需要详细说一下
     将Eclipse代码导入到AndroidStudio的两种方式
    这里上面两个选项暂且不说,勾选上。
    最后一项提一下: 将Module名创建为camelCase风格。
    驼峰式,这个搞Java的都会熟悉,camelCase表示首字母小写的驼峰式风格,CamelCase表示首字母大写的驼峰式风格。
    不勾选这个选项意味着你原先的工程名是啥样,转换完就是啥样。
    当然也有例外,比如countly-sdk-android转换完就成了countlysdkandroid,下划线我就不知道了,这个没有再仔细研究规则,不过CamelCase会保持正常。

  • 之后需要经过一段时间的转换。成功后可以看到import-summary.txt,这个文件非常有用,后面会讲到。

    •  将Eclipse代码导入到AndroidStudio的两种方式

    到这里,你的应用其实已经可以通过AndroidStudio正常编译,你也可以写代码去了。
    但我希望你还能继续看下去,因为这个成功后弹出来的import-summary.txt写了些很重要的东西。

  • 这里的import-summary.txt文件是非常非常重要的文件,基本上你成功的导入还是失败都是靠这个文件,有可能你和我一样,都有一个毛病,见到英文本能的略过,只有比较重要的时候才好好看看翻译一下.所以这里,这个文件是比较重要的,你要全部的都翻译出来,你的导入的成功率才会大,这句话是本文的重中之重.

  • 现在看第一部分

  • ECLIPSE ANDROID PROJECT IMPORT SUMMARY======================================Manifest Merging:-----------------Your project uses libraries that provide manifests, and your Eclipseproject did not explicitly turn on manifest merging. In Android Gradleprojects, manifests are always merged (meaning that contents from yourlibraries' manifests will be merged into the app manifest. If you hadmanually copied contents from library manifests into your app manifestyou may need to remove these for the app to build correctly.

  • 第一部分让你明白一些 这里就不献丑翻译了

  • 看第二部分

  • Ignored Files:--------------The following files were *not* copied into the new Gradle project; youshould evaluate whether these are still needed in your project and ifso manually move them:From Test:* Thumbs.db* android.keystore* ic_launcher-web.png* proguard-project.txtFrom libraryListView:* LICENSE* pom.xmlFrom playdemo:* proguard-project.txt
    第二部分是忽略的东西 有些东西要加上去的哦 我导入之后忽略的东西就这么多 这些东西都不用加上去

  • 接下来是第三部分

  • Replaced Jars with Dependencies:--------------------------------The importer recognized the following .jar files as third partylibraries and replaced them with Gradle dependencies instead. This hasthe advantage that more explicit version information is known, and thelibraries can be updated automatically. However, it is possible thatthe .jar file in your project was of an older version than thedependency we picked, which could render the project not compileable.You can disable the jar replacement in the import wizard and try again:android-support-v4.jar => com.android.support:support-v4:19.1.0
    意思是 一些本来的东西用谷歌线上的东西代替了.

  • 第四部分

  • Moved Files:------------Android Gradle projects use a different directory structure than ADTEclipse projects. Here's how the projects were restructured:In libraryListView:* AndroidManifest.xml => libraryListView\src\main\AndroidManifest.xml* assets\ => libraryListView\src\main\assets* res\ => libraryListView\src\main\res\* src\ => libraryListView\src\main\java\
    这里的意思是把一些东西移动了位置

  • 最后一部分

  • Next Steps:-----------You can now build the project. The Gradle project needs networkconnectivity to download dependencies.Bugs:-----If for some reason your project does not build, and you determine thatit is due to a bug or limitation of the Eclipse to Gradle importer,please file a bug at http://b.android.com with categoryComponent-Tools.(This import summary is for your information only, and can be deletedafter import once you are satisfied with the results.)
    加重了自己的理解,让自己理解更深一些,对于Bugs的问题 我没有碰到

  • 如此,你的项目就导入到studio中去了,但是 这只是个开始,不同的项目,会遇到各种各样的问题,有的可能容易解决,有的肯定解决起来很困难.很多情况下,我们都是研究了半天终于解决了,但是具体解决是怎么解决的,还是有点懵的.
  • 这里 我介绍一下 我遇到较难的问题及解决
  • 这个问题主要是由于包的重复,我在线下载了包,又在bin文件里面导入了包,两个包重复

  • 第二个问题

  • 这个问题怎么解决呢在
  • 解决方法: 
    在build.gradle的android{…}里面加上 
    [html] view plaincopy 
    packagingOptions { 
    exclude ‘META-INF/DEPENDENCIES’ 
    exclude ‘META-INF/NOTICE’ 
    exclude ‘META-INF/LICENSE’ 
    exclude ‘META-INF/LICENSE.txt’ 
    exclude ‘META-INF/NOTICE.txt’ 
    }

    packagingOptions 应该放到最前面才生效,放到最后面经试验不行。


  • 虽然我成功的导入了,这只是我公司的项目,如果换的项目不一定成功,因为其中可能还会有很多意想不到的问题,其实导入到studio很简单,困难的是导入进去之后,你遇到的问题,eclipse有的 studio没有的,或者说构建方法不一样的类或者jar包等东西.但是 这种方法是对的,具体的问题再具体的去网上查就行.
  • 0 0
    原创粉丝点击