您的位置:首页 > 编程语言 > Java开发

Android eclipse转studio的流程及问题

2016-09-20 18:22 441 查看
    废话不说进入正题,我感觉也没有人看我的废话...

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

    

打开Import
新用户:



老用户: File-->Import Project



直接找到原有的Eclipse工程
单一工程直接导入即可。

有库工程的需要注意,导入一定要指向主工程,而不是整个项目的目录。指向项目目录是无法进行转换的。



指定目标路径



这个地方需要详细说一下



这里上面两个选项暂且不说,勾选上。

最后一项提一下: 将Module名创建为camelCase风格。

驼峰式,这个搞Java的都会熟悉,camelCase表示首字母小写的驼峰式风格,CamelCase表示首字母大写的驼峰式风格。

不勾选这个选项意味着你原先的工程名是啥样,转换完就是啥样。

当然也有例外,比如countly-sdk-android转换完就成了countlysdkandroid,下划线我就不知道了,这个没有再仔细研究规则,不过CamelCase会保持正常。

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



到这里,你的应用其实已经可以通过AndroidStudio正常编译,你也可以写代码去了。

但我希望你还能继续看下去,因为这个成功后弹出来的import-summary.txt写了些很重要的东西。

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

现在看第一部分

ECLIPSE ANDROID PROJECT IMPORT SUMMARY
======================================

Manifest Merging:
-----------------
Your project uses libraries that provide manifests, and your Eclipse
project did not explicitly turn on manifest merging. In Android Gradle
projects, manifests are always merged (meaning that contents from your
libraries' manifests will be merged into the app manifest. If you had
manually copied contents from library manifests into your app manifest
you may need to remove these for the app to build correctly.


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

看第二部分

Ignored Files:
--------------
The following files were *not* copied into the new Gradle project; you
should evaluate whether these are still needed in your project and if
so manually move them:

From Test:
* Thumbs.db
* android.keystore
* ic_launcher-web.png
* proguard-project.txt
From libraryListView:
* LICENSE
* pom.xml
From playdemo:
* proguard-project.txt

第二部分是忽略的东西 有些东西要加上去的哦 我导入之后忽略的东西就这么多 这些东西都不用加上去

接下来是第三部分

Replaced Jars with Dependencies:
--------------------------------
The importer recognized the following .jar files as third party
libraries and replaced them with Gradle dependencies instead. This has
the advantage that more explicit version information is known, and the
libraries can be updated automatically. However, it is possible that
the .jar file in your project was of an older version than the
dependency 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 ADT
Eclipse 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 network
connectivity to download dependencies.

Bugs:
-----
If for some reason your project does not build, and you determine that
it is due to a bug or limitation of the Eclipse
b383
to Gradle importer,
please file a bug at http://b.android.com with category
Component-Tools.

(This import summary is for your information only, and can be deleted
after 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包等东西.但是 这种方法是对的,具体的问题再具体的去网上查就行.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  android