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!