Android studio 软件报错

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Android studio 软件报错相关的知识,希望对你有一定的参考价值。

这是什么意思啊

参考技术A 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文件

加入
http://blog.csdn.net/susubuhui/article/details/9383875本回答被提问者和网友采纳

android studio 学习日记 报错

error1:
Could not find Nexus_S_API_14.ini file in $ANDROID_AVD_HOME nor in $HOME/.android/avd
.android目录配置问题 在环境变量新建android_avd_home:变量值为.android目录
error2:
I/O Error: EOF
adb被占用 结束进程就好
warning3:建议布局先面对UI之后面对代码

以上是关于Android studio 软件报错的主要内容,如果未能解决你的问题,请参考以下文章

(androis studio)app连连看demo练习

android studio真机测试页面跳转时自动弹出软件,报错null exception解决方案

Android Studio的安装及"SSL peer shut down incorrectly"问题

请问,我的androi studio中动态申请权限,Manifest.permission.WRITE_EXTERNAL_STORAGE

Android Studio运行APP报错:系统找不到指定的路径?

Android Studio 发展史