请使用 -Xlint:deprecation 重新编译

来源:互联网 发布:mac 命令行 u盘路径 编辑:程序博客网 时间:2024/05/22 10:52

在编译的过程中出现了这个提示,但是并没有说明到底是哪一个类中出现的情况. 
使用的是 gradle assembleDebug

注: /home/malin/malin_github/BilibiliLogin/app/src/main/Java/com/malin/animation/fragment/LoginFragment.java使用或覆盖了已过时的 API。 
注: 有关详细信息, 请使用 -Xlint:deprecation 重新编译。 
注: /home/malin/malin_github/BilibiliLogin/app/build/generated/source/apt/debug/com/malin/animation/fragment/LoginFragment$$ViewBinder.java使用了未经检查或不安全的操作。 
注: 有关详细信息, 请使用 -Xlint:unchecked 重新编译。

解决办法是:

在工程的根目录下的build.gradle文件中加入

allprojects {    gradle.projectsEvaluated {        tasks.withType(JavaCompile) {            options.compilerArgs << "-Xlint:unchecked" << "-Xlint:deprecation"        }    }}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7

从新执行 gradle assembleDebug (或者 gradle lint)

/home/malin/malin_github/BilibiliLogin/app/src/main/java/com/malin/animation/fragment/LoginFragment.java:429: 警告: [deprecation] Resources中的getColor(int)已过时 
mViewPassWordBottomLine.setBackgroundColor(mActivity.getResources().getColor(R.color.gray_dark));

^



但有时还时有后续的,我属于那种做着比较大的项目,做了一大半,突然某次运行就坏事,以上方法一大堆出现已过时。。。又不是不能用,看着都没眼看了,但是主要问题貌似还不是这个,看看下面的。

Error:Uncaught translation error: com.android.dx.cf.code.SimException: local variable type mismatch: attempt to set or access a value of type java.lang.Object using a local variable of type int. This is symptomatic of .class transformation tools that ignore local variable information.
1 error; aborting

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:transformClasses_enhancedWithInstantReloadDexForDebug'.
> com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.ide.common.process.ProcessException: Return code 1 for dex process

* Try:
Run with --stacktrace option to get the stack trace. Run with --debug option to get more log output.


Android studio编译报错:Error:Execution failed for task ':app:transformClasses_enhancedWithInstantReloadDexForDebug'.

> com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException:Java.util.concurrent.ExecutionException: com.android.ide.common.process.ProcessException: Return code 1 for dex process


从错上几乎看不出有什么有用的信息,但是解决方法就是去掉Enable instant run to hot swap code/resource changes on deploy(default enabled)选项:


基本干净了,呵呵。。。-_-!


Android studio的2.0新版本出了一个革命性的功能就是Instant Run(即时运行)!新的即时运行功能可以让开发者像写html网页一样写Android原生代码,能做到一边修改代码,一边在模拟器或者实际设备上看到 修改代码后的结果。

但是这个功能,会引发一些问题,编程的时候会感到不适应。

首先是四个属性: 
1:Enable Instant Run to hot swap code/resource changes on deploy (default enabled) 
//启用即时运行 热交换代码/资源变化 部署(默认启用)

2:Restart activity on code changes 
//当代码变动时重启

3:Show toasts in the running app when changes are applied 
//当代码变动应用时弹出toast

4:show Instant Run status notifications 
//在notification里显示instant Run 的状态

经常遇到的问题: 
1.使用了instant Run功能后开启应用就会短暂白屏,即使是全新的项目也会出现短暂的白屏

解决:取消勾选第四个选项

2.code 已经更新了,但是点击运行的时候还是提示 No changes To Deploy

解决:取消勾选第一个选项

3.Error:Execution failed for task ‘:app:transformClassesWithDexForDebug’

解决:取消勾选第一个选项。如果已经取消过第一个选项,就clean project



0 0
原创粉丝点击