Gradle Android项目切换开发工具到Ecilpse+ADT遇到的各种问题及解决

缘起——领导给了个手机人脸识别的项目源码,让我们加到现有系统里去,打开一看,是个Gradle架构下开发的Android项目。因为我们现有程序是Eclipse加ADT来做的,所以要把这个项目导入到Eclipse里来。

Import… Existing Gradle Project,指定到根目录,开始

一,遇到的第一个问题,提示“找不到android sdk”。
解决:Eclipse -> Window -> Preferences 左侧找到Android。右侧SDK Location: 把路径copy出来。写入到导入项目根目录下的local.properties 文件里。注意多加的斜杠:

sdk.dir=E\:\\MyProjects\\App\\android-sdk-windows

二,再来,遇到的第二个问题,报错:You have not accepted the license agreements of the following SDK components:
[Android SDK Platform 26, Android SDK Build-Tools 26.0.2].
Before building your project, you need to accept the license agreements and complete the installation of the missing components using the Android Studio SDK Manager.
Alternatively, to learn how to transfer the license agreements from one workstation to another, go to http://d.android.com/r/studio-ui/export-licenses.html
报错信息是如此清楚明白,然并卵,因为google被屏蔽的原因,那个网址大陆这边是没法访问的。
解决:这个报错的意思是需要接受license,并且用SDK Manager下载[Android SDK Platform 26, Android SDK Build-Tools 26.0.2]。我的SDK Manager上并没有提示我安装的地方,我就直接在CSDN上找到了别人提供的安装包下载,直接解压,copy在sdk目录下就行了。分别是\App\android-sdk-windows\platforms\android-26 和 \App\android-sdk-windows\build-tools\26.0.2

三,再来,报错:You have not accepted the license agreements of the following SDK components:
[ConstraintLayout for Android 1.0.2, Solver for ConstraintLayout 1.0.2]

解决:这个东西可让我心烦了好久,因为ConstraintLayout是Android Studio推出的东西,Eclipse根本不支持,我几乎一度想放弃。但是看了好多文章,所谓ConstraintLayout他只是一种Layout样式,鉴于要导入的项目是个极简单的项目Layout肯定不多,于是我搜了一下res下面的Layout,实际上也只有一处使用到了ConstraintLayout 把他改成LinearLayout

另外app.iml和build.gradle里面的

<orderEntry type="library" exported="" name="constraint-layout-solver-1.0.2" level="project" />
<orderEntry type="library" exported="" name="constraint-layout-1.0.2" level="project" />

ConstraintLayout 里面的

compile 'com.android.support.constraint:constraint-layout:1.0.2'

都删掉或注解掉

四,继续import,报错:You have not accepted the license agreements of the following SDK components:
[Android Support Repository].
解决:在SDK Manager里,下面Extras里面找到Android Support Repository,安装
这里写图片描述

五,再来,继续报错:A problem occurred configuring project ‘:app’ java.lang.NullPointerException (no error message)

这个错误就非常令人抓狂了,字面意义上是说“空指针”……没有其他的error信息。学过C的同学都知道,指针问题,那是极令人头疼的问题,而且这还不是自己的程序。百度了几个解决方案,都无效。

只能根据直觉,查看所有的调用过程,根据老司机的直觉,应该是NDK的问题,于是从网上down了一个1.7版的NDK,好大,将近700M,放在SDK目录里解压。在local.properties里 指定ndk的dir。

ndk.dir=E\:\\MyProjects\\App\\android-sdk-windows\\android-ndk-r17

七,再Import,竟然成功了,我几乎不敢相信,真神奇
这里写图片描述

这个我在网上查过,从没见谁把Android Studio的项目往Eclips+ADT环境里导的,我相当于把一瓶新酒硬生生给塞进了老瓶子里。虽然遇到了一堆问题,不过办法总比问题多。继续加油吧,骚年!

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值