Eclipse导入项目时常见问题解决汇总, Android Studio转为Eclipse项目问题汇总

打开eclipse时提示Java was started but returned exit code=13 打开之前先安装jdk8就行。

一、Android Studio转为Eclipse项目问题汇总

1、Theme.AppCompat.Light无法找到问题

使用adt开发新建一个Android app,选择支持的SDK版本如果小于11(Android3.0)就会报如下错误。

error: Error retrieving parent for item: No resource found that matches the given name 'Theme.AppCompat.Light'.

最彻底的解决办法:直接新建一个正常的项目(4.0及以上),把代码和资源全复制到新项目里,肯定能解决。

官网给出的答案是:

https://developer.android.com/tools/support-library/setup.html#add-library

简单来说就是新的eclipse默认模版主题UI需要使用比较高版本api,如果需要支持低版本,需要导入appCompact库来支持,网上一般给出的解法:

File->Import (android-sdk\extras\android\support\v7). Choose "appcompat"
Project-> properties->Android. In the section library "Add" and choose "appCompat"
包括stackoverflow上也有很多人遇到,但很多人通过这个解决,但我就是没办法解决。

2、一些代码类被弃用,或用新的代替了。

1)比如:报错 Error:(303, 27) 错误: 找不到符号 符号: 方法 sin(float) 位置: 类 FloatMath

原因是Android6.0不支持FloatMath.sin()了,主要有两个方法可以解决。

方法一:

用23一下的SDK版本进行编译。将gradle.build文件里(包括project的gradle.build和module的gradle.build)的compileSdkVersion设为23以下。

方法二:

将上面报错的地方,即 用Math类替换FloatMath类,Math.sin();

2)安卓解决6.0以后没有setLatestEventInfo方法,解决办法,直接贴代码

NotificationManager manager = (NotificationManager) this.getSystemService(Context.NOTIFICATION_SERVICE);
//新建一个Notification管理器;
//API level 11
Notification.Builder builder = new Notification.Builder(this);//新建Notification.Builder对象
PendingIntent intent = PendingIntent.getActivity(this, 0, new Intent(this, MainActivity.class), 0);
//PendingIntent点击通知后所跳转的页面
builder.setContentTitle("Bmob Test");
builder.setContentText("message");
builder.setSmallIcon(R.mipmap.ic_launcher);
builder.setContentIntent(intent);//执行intent
Notification notification = builder.getNotification();//将builder对象转换为普通的notification
notification.flags |= Notification.FLAG_AUTO_CANCEL;//点击通知后通知消失
manager.notify(1,notification);//运行notification

3.Failed to load

1)比如Failed to load C:\eclipse\eclipse\sdk\build-tools\28.0.3\lib\dx.jar

原因:eclipse自动使用最高版本的SDK,ADT比SDK版本低导致

解决办法一: 从25.0.0里复制一个来替换掉。

解决办法二:

1、用SDK Manager.exe下载低版本的build-tools,如25.0.2

2、在你项目的project.properties文件中加入这个

sdk.buildtools=25.0.2//设置sdk使用的buildtools版本  指定版本编译


 

发布了331 篇原创文章 · 获赞 140 · 访问量 71万+

猜你喜欢

转载自blog.csdn.net/chenhao0568/article/details/91042792