AndroidStudio Initial Experience: Solving Execution failed for task': TestAndroid: c

Source: Internet
Author: User

Execution failed for task': TestAndroid: compiledebug '.
There are various reasons. For specific reasons, please compile it in cmd to see what went wrong.
Enter the project's gradle file directory and type
Gradlew compileDebug -- stacktrace
You can trace it ~
 
A problem occurred during compilation yesterday. The specific problem is solved!


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.

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


First, go to the command line
Enter the project root directory (the directory where the gradule file is located)
Enter the command


Gradlew compileDebug -- stacktrace


View error location:
The error is as follows:
========================================================== ======================================


C: \ Users \ Administrator \ AndroidStudioProjects \ TestAndroid \ src \ main \ ja
Va \ com \ example \ testandroid \ MainActivity. java: 125: Warning: Non- able characters encoded in GBK
// Qiniaoyaoyaoyaoyun $ commandid was provided when there was a problem between them? Too many?
SharedPreferences settings = getSharedPreferences (PROFILE _
NAME, Activity. MODE_PRIVATE );
^
C: \ Users \ Administrator \ AndroidStudioProjects \ TestAndroid \ src \ main \ ja
Va \ com \ example \ testandroid \ MainActivity. java: 125: Warning: Non- able characters encoded in GBK
// Qiniaoyaoyaoyaoyun $ commandid was provided when there was a problem between them? Too many?
SharedPreferences settings = getSharedPreferences (PROFILE _
NAME, Activity. MODE_PRIVATE );
^
C: \ Users \ Administrator \ AndroidStudioProjects \ TestAndroid \ src \ main \ ja
Va \ com \ example \ testandroid \ MainActivity. java: 126: No symbol found
Symbol: variable settings
SharedPreferences. Editor editor = settings. edit ();
^
1 error
: 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.exe cution. ExecuteActionsTaskExecuter. ex
EcuteActions (ExecuteActionsTaskExecuter. java: 69)
At org.gradle.api.internal.tasks.exe cution. ExecuteActionsTaskExecuter. ex
Ecute (ExecuteActionsTaskExecuter. java: 46)
At org.gradle.api.internal.tasks.exe cution. PostExecutionAnalysisTaskExec
Uter.exe cute (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)


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


The incorrect cycle should be a coding problem.

125 lines use Chinese comments


Because Gradle uses GBK by default, but the comments in java files use UTF-8 for Chinese
So there is a problem


Set the Gradle compilation encoding:


Method


Open the project structure
Structure


Open the gradle File


Join


// Set the Encoding
Tasks. withType (Compile ){
Options. encoding = "UTF-8"
}
 
Run the command line again to check whether there are any errors.
If not, check your java file encoding.
Into UTF-8


Compile it again!

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.