android studio 编译调试 错误

原创 2014年01月01日 22:51:11

Execution failed for task ':TestAndroid:compileDebug'.
有各种各样原因,具体就请自己进cmd编译看什么地方出错
进入项目的gradle文件所在目录打
gradlew compileDebug --stacktrace
来追踪就可以啦~
 
昨天编译的时候出现了问题,具体问题具体解决!


Gradle:
FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':TestAndroid:compileDebug'.
> Compilation failed; see the compiler error output for details.

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

Could not execute build using Gradle installation 'C:\gradle-1.6'.


首先进入命令行
进入项目根目录(gradule文件所在目录)
输入命令


gradlew compileDebug --stacktrace


查看错误位置:
错误如下
=================================================================


C:\Users\Administrator\AndroidStudioProjects\TestAndroid\TestAndroid\src\main\ja
va\com\example\testandroid\MainActivity.java:125: 警告:编码 GBK 的不可映射字符
                            //淇濆瓨褰撳墠璁$畻缁撴灉锛屼笅娆℃墦寮?仮澶?
                      SharedPreferences settings = getSharedPreferences(PROFILE_
NAME,Activity.MODE_PRIVATE);
                                                 ^
C:\Users\Administrator\AndroidStudioProjects\TestAndroid\TestAndroid\src\main\ja
va\com\example\testandroid\MainActivity.java:125: 警告:编码 GBK 的不可映射字符
                            //淇濆瓨褰撳墠璁$畻缁撴灉锛屼笅娆℃墦寮?仮澶?
                      SharedPreferences settings = getSharedPreferences(PROFILE_
NAME,Activity.MODE_PRIVATE);
                                                    ^
C:\Users\Administrator\AndroidStudioProjects\TestAndroid\TestAndroid\src\main\ja
va\com\example\testandroid\MainActivity.java:126: 找不到符号
符号: 变量 settings
                            SharedPreferences.Editor editor = settings.edit();
                                                              ^
1 错误
:TestAndroid:compileDebug FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':TestAndroid:compileDebug'.
> Compilation failed; see the compiler error output for details.

* Try:
Run with --info or --debug option to get more log output.

* Exception is:
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':TestAnd
roid:compileDebug'.
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.ex
ecuteActions(ExecuteActionsTaskExecuter.java:69)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.ex
ecute(ExecuteActionsTaskExecuter.java:46)
        at org.gradle.api.internal.tasks.execution.PostExecutionAnalysisTaskExec
uter.execute(PostExecutionAnalysisTaskExecuter.java:35)
        at org.gradle.api.internal.changedetection.state.CacheLockReleasingTaskE
xecuter$1.run(CacheLockReleasingTaskExecuter.java:35)
        at org.gradle.internal.Factories$1.create(Factories.java:22)
        at org.gradle.cache.internal.DefaultCacheAccess.longRunningOperation(Def
aultCacheAccess.java:179)


=======================================================


因循错误应该是编码问题

125行用了中文注释


因为Gradle默认编译采用了GBK,但是java文件中的注释中文用UTF-8
所以有问题


设置Gradle的编译编码即可:


具体方法


打开项目结构
structure


打开gradle文件


加入


//设置编码 
    tasks.withType(Compile) { 
        options.encoding = "UTF-8" 
    }
 
然后再次运行命令行查看有错不
如果不行检查自己的java文件编码
换成UTF-8


再编译 OK通过!

安卓编译错误app:compileDebugJavaWithJavac>Compilation failed; see the compiler error output for details.

Error:Execution failed for task ':app:compileDebugJavaWithJavac'. > Compilation failed; see the comp...
  • Daxue_haha
  • Daxue_haha
  • 2017-11-22 16:20:29
  • 3644

Android Studio 编译常见问题解决办法

1.dexDebug ExecException finished with non-zero exit value 2 需要在gradle中配置下面的代码,原因是引用了多个libraries文件 d...
  • u014702332
  • u014702332
  • 2016-04-26 13:07:24
  • 30404

Compile failed; see the compiler error output for details. 解决

android编译某些java文件的时候,就是javac的时候,要设置编码格式。 这个问题就是项目中的某个文件的编码格式和你设定的不一样导致的。 (备份下,纠结了很久)...
  • Nil88
  • Nil88
  • 2013-06-11 12:17:59
  • 8738

"compileDebugJavaWithJavac"错误解决

在AS中进行编译,出现如下错误: Error:Execution failed for task ':xxx:compileDebugJavaWithJavac'. > Compilation fa...
  • liranke
  • liranke
  • 2015-12-12 21:33:01
  • 44383

快速解决Error:Execution failed for task ':app:compileReleaseJavaWithJavac'. > Compilation failed; see th

> 自从AS升级2.3之后,偶尔遇到一个问题 Error:Execution failed for task ':appmain:compileReleaseJavaWithJavac'. >...
  • Justin_1107
  • Justin_1107
  • 2017-05-09 18:04:52
  • 5302

Bmob之Error:Execution failed for task ':app:compileDebugJavaWithJavac'. > Compilation failed; see the

最近在写Bmob相关内容,又遇到了这个问题,之前遇到过该问题,忘记怎么解决的了,今天又遇到调试了好久,特发一贴来记录一下,防止再走老路。 问题描述:Error:(19, 55) 错误: 无法访问Su...
  • s1674521
  • s1674521
  • 2017-03-28 18:33:43
  • 2010

关于uiautomator的build.xml不能编译的问题

BUILD FAILED D:\environment\adt-bundle-windows-x86_64-20140702\sdk\tools\ant\uibuild.xml:183: Compil...
  • zeze_Z
  • zeze_Z
  • 2016-08-30 20:01:57
  • 1573

Error:Compilation failed; see the compiler error output for details.

我们来看看这个博主:http://blog.csdn.net/runner__1/article/details/53482565我就是借鉴他找错的经历找到错误的在命令行中进入项目的根目录,或者可以在...
  • jessie363959744
  • jessie363959744
  • 2018-03-20 11:18:35
  • 74

Android studio 报错修改

错误: Error:Unable to start the daemon process. This problem might be caused by incorrect configuratio...
  • jiuweitianhu_12345
  • jiuweitianhu_12345
  • 2017-06-05 09:53:10
  • 158
收藏助手
不良信息举报
您举报文章:android studio 编译调试 错误
举报原因:
原因补充:

(最多只允许输入30个字)