【我的Android进阶之旅】解决SDK升级到27.0.3遇到的GLIBC_2.14 not found、no acceptable C compiler found in $PATH等问题

一、问题一:Failed to find Build Tools revision 27.0.3

1.1、问题描述

最近公司的Android项目都要进行SDK升级,目前在本地编译的时候将SDK升级到了27.0.3,本地运行正常,然后在jenkins服务器上跑的时候就会出现异常。异常如下所示:


[Gradle] - Launching build.
[AP_Develop] $ /opt/gradle/gradle-2.14.1/bin/gradle clean lintForXTC --stacktrace build --stacktrace findbugs --stacktrace
Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF-8
Failed to download any source lists!
java.net.ConnectException: Connection timed out (Connection timed out)

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring project ':SecureUnisignon'.
> Failed to find Build Tools revision 27.0.3

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

* Exception is:
org.gradle.api.ProjectConfigurationException: A problem occurred configuring project ':SecureUnisignon'.
    at org.gradle.configuration.project.LifecycleProjectEvaluator.addConfigurationFailure(LifecycleProjectEvaluator.java:79)
    at org.gradle.configuration.project.LifecycleProjectEvaluator.notifyAfterEvaluate(LifecycleProjectEvaluator.java:74)
    at org.gradle.configuration.project.LifecycleProjectEvaluator.evaluate(LifecycleProjectEvaluator.java:61)
    at org.gradle.api.internal.project.AbstractProject.evaluate(AbstractProject.java:540)
    at org.gradle.api.internal.project.AbstractProject.evaluate(AbstractProject.java:93)
    at org.gradle.execution.TaskPathProjectEvaluator.configureHierarchy(TaskPathProjectEvaluator.java:47)
    at org.gradle.configuration.DefaultBuildConfigurer.configure(DefaultBuildConfigurer.java:35)
    at org.gradle.initialization.DefaultGradleLauncher$2.run(DefaultGradleLauncher.java:124)
    at org.gradle.internal.Factories$1.create(Factories.java:22)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:91)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:53)
    at org.gradle.initialization.DefaultGradleLauncher.doBuildStages(DefaultGradleLauncher.java:121)
    at org.gradle.initialization.DefaultGradleLauncher.access$200(DefaultGradleLauncher.java:32)
    at org.gradle.initialization.DefaultGradleLauncher$1.create(DefaultGradleLauncher.java:98)
    at org.gradle.initialization.DefaultGradleLauncher$1.create(DefaultGradleLauncher.java:92)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:91)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:63)
    at org.gradle.initialization.DefaultGradleLauncher.doBuild(DefaultGradleLauncher.java:92)
    at org.gradle.initialization.DefaultGradleLauncher.run(DefaultGradleLauncher.java:83)
    at org.gradle.launcher.exec.InProcessBuildActionExecuter$DefaultBuildController.run(InProcessBuildActionExecuter.java:99)
    at org.gradle.tooling.internal.provider.ExecuteBuildActionRunner.run(ExecuteBuildActionRunner.java:28)
    at org.gradle.launcher.exec.ChainingBuildActionRunner.run(ChainingBuildActionRunner.java:35)
    at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:48)
    at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:30)
    at org.gradle.launcher.exec.ContinuousBuildActionExecuter.execute(ContinuousBuildActionExecuter.java:81)
    at org.gradle.launcher.exec.ContinuousBuildActionExecuter.execute(ContinuousBuildActionExecuter.java:46)
    at org.gradle.launcher.exec.DaemonUsageSuggestingBuildActionExecuter.execute(DaemonUsageSuggestingBuildActionExecuter.java:51)
    at org.gradle.launcher.exec.DaemonUsageSuggestingBuildActionExecuter.execute(DaemonUsageSuggestingBuildActionExecuter.java:28)
    at org.gradle.launcher.cli.RunBuildAction.run(RunBuildAction.java:43)
    at org.gradle.internal.Actions$RunnableActionAdapter.execute(Actions.java:173)
    at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(CommandLineActionFactory.java:239)
    at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(CommandLineActionFactory.java:212)
    at org.gradle.launcher.cli.JavaRuntimeValidationAction.execute(JavaRuntimeValidationAction.java:35)
    at org.gradle.launcher.cli.JavaRuntimeValidationAction.execute(JavaRuntimeValidationAction.java:24)
    at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:33)
    at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:22)
    at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:205)
    at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:169)
    at org.gradle.launcher.Main.doAction(Main.java:33)
    at org.gradle.launcher.bootstrap.EntryPoint.run(EntryPoint.java:45)
    at org.gradle.launcher.bootstrap.ProcessBootstrap.runNoExit(ProcessBootstrap.java:55)
    at org.gradle.launcher.bootstrap.ProcessBootstrap.run(ProcessBootstrap.java:36)
    at org.gradle.launcher.GradleMain.main(GradleMain.java:23)
Caused by: java.lang.IllegalStateException: Failed to find Build Tools revision 27.0.3
    at com.android.builder.sdk.DefaultSdkLoader.installBuildTools(DefaultSdkLoader.java:286)
    at com.android.builder.sdk.DefaultSdkLoader.getTargetInfo(DefaultSdkLoader.java:145)
    at com.android.build.gradle.internal.SdkHandler.initTarget(SdkHandler.java:136)
    at com.android.build.gradle.BasePlugin.ensureTargetSetup(BasePlugin.java:760)
    at com.android.build.gradle.BasePlugin.createAndroidTasks(BasePlugin.java:657)
    at com.android.build.gradle.BasePlugin$10.call(BasePlugin.java:608)
    at com.android.build.gradle.BasePlugin$10.call(BasePlugin.java:605)
    at com.android.builder.profile.ThreadRecorder.record(ThreadRecorder.java:156)
    at com.android.builder.profile.ThreadRecorder.record(ThreadRecorder.java:120)
    at com.android.build.gradle.BasePlugin.lambda$createTasks$1(BasePlugin.java:603)
    at org.gradle.internal.event.BroadcastDispatch$ActionInvocationHandler.dispatch(BroadcastDispatch.java:93)
    at org.gradle.internal.event.BroadcastDispatch$ActionInvocationHandler.dispatch(BroadcastDispatch.java:82)
    at org.gradle.internal.event.AbstractBroadcastDispatch.dispatch(AbstractBroadcastDispatch.java:44)
    at org.gradle.internal.event.BroadcastDispatch.dispatch(BroadcastDispatch.java:79)
    at org.gradle.internal.event.BroadcastDispatch.dispatch(BroadcastDispatch.java:30)
    at org.gradle.internal.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:93)
    at com.sun.proxy.$Proxy11.afterEvaluate(Unknown Source)
    at org.gradle.configuration.project.LifecycleProjectEvaluator.notifyAfterEvaluate(LifecycleProjectEvaluator.java:67)
    ... 41 more


BUILD FAILED

【我的Android进阶之旅】解决SDK升级到27.0.3遇到的GLIBC_2.14 not found、no acceptable C compiler found in $PATH等问题

【我的Android进阶之旅】解决SDK升级到27.0.3遇到的GLIBC_2.14 not found、no acceptable C compiler found in $PATH等问题

1.2、问题分析与解决

如上图日志所示,Caused by: java.lang.IllegalStateException: Failed to find Build Tools revision 27.0.3,在Jenkins配置的节点编译服务器上,找不到27.0.3的Build Tools。

因此,我们登录Jenkins配置的节点编译服务器,升级SDK的Build Tools到27.0.3即可解决。具体SDK升级的操作这里就不介绍了。

【我的Android进阶之旅】解决SDK升级到27.0.3遇到的GLIBC_2.14 not found、no acceptable C compiler found in $PATH等问题

[root@localhost glibc-build-2.14]# ll /opt/android/sdk/build-tools/
总用量 52
drwxr-xr-x. 4 root root 4096 1114 17:20 22.0.1
drwxr-xr-x. 4 root root 4096 1114 17:21 23.0.1
drwxr-xr-x. 4 root root 4096 1114 17:21 23.0.2
drwxr-xr-x. 4 root root 4096 1114 17:22 23.0.3
drwxr-xr-x. 5 root root 4096 411 09:31 25.0.0
drwxr-xr-x. 5 root root 4096 1114 14:37 25.0.1
drwxr-xr-x. 5 root root 4096 1114 14:37 25.0.2
drwxr-xr-x. 5 root root 4096 1114 14:37 25.0.3
drwxr-xr-x. 5 root root 4096 1114 14:37 26.0.1
drwxr-xr-x. 5 root root 4096 1114 14:37 26.0.2
drwxr-xr-x. 5 root root 4096 1114 14:37 26.0.3
drwxr-xr-x. 5 root root 4096 324 10:47 27.0.1
drwxr-xr-x. 5 root root 4096 417 11:36 27.0.3
[root@localhost glibc-build-2.14]# 

接着重新编译,就会遇到第二个问题 /lib64/libc.so.6: version `GLIBC_2.14’ not found

二、问题二:/lib64/libc.so.6: version `GLIBC_2.14’ not found

1、问题描述

编译之后出错,就会遇到第二个问题 /lib64/libc.so.6: version `GLIBC_2.14’ not found,具体错误信息如下所示:


:SecureUnisignon:clean
:jslibrary:clean
:watch:clean
:SecureUnisignon:preBuild UP-TO-DATE
:SecureUnisignon:preReleaseBuild UP-TO-DATE
:SecureUnisignon:checkReleaseManifest
:SecureUnisignon:preDebugAndroidTestBuild UP-TO-DATE
:SecureUnisignon:preDebugBuild UP-TO-DATE
:SecureUnisignon:preDebugUnitTestBuild UP-TO-DATE
:SecureUnisignon:preReleaseUnitTestBuild UP-TO-DATE
:SecureUnisignon:prepareComAndroidSupportAppcompatV72221Library
:SecureUnisignon:prepareComAndroidSupportSupportV42221Library
:SecureUnisignon:prepareComXtcBigdataBigdataCommon0020Library
:SecureUnisignon:prepareComXtcBigdataBigdataForApp0011Library
:SecureUnisignon:prepareComXtcDataDataDatabase014Library
:SecureUnisignon:prepareComXtcLogLog101Library
:SecureUnisignon:prepareIoReactivexRxandroid121Library
:SecureUnisignon:prepareReleaseDependencies
:SecureUnisignon:compileReleaseAidl
:SecureUnisignon:compileReleaseNdk UP-TO-DATE
:SecureUnisignon:compileLint
:SecureUnisignon:copyReleaseLint UP-TO-DATE
:SecureUnisignon:compileReleaseRenderscript
:SecureUnisignon:generateReleaseBuildConfig
:SecureUnisignon:generateReleaseResValues
:SecureUnisignon:generateReleaseResources
:SecureUnisignon:mergeReleaseResources
:SecureUnisignon:processReleaseManifest
:SecureUnisignon:processReleaseResources/opt/android/sdk/build-tools/27.0.3/aapt: /lib64/libc.so.6: version `GLIBC_2.14' not found (required by /opt/android/sdk/build-tools/27.0.3/aapt)
/opt/android/sdk/build-tools/27.0.3/aapt: /lib64/libc.so.6: version `GLIBC_2.14' not found (required by /opt/android/sdk/build-tools/27.0.3/lib64/libc++.so)

 FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':SecureUnisignon:processReleaseResources'.
> com.android.ide.common.process.ProcessException: Failed to execute aapt

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

* Exception is:
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':SecureUnisignon:processReleaseResources'.
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:69)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:46)
    at org.gradle.api.internal.tasks.execution.PostExecutionAnalysisTaskExecuter.execute(PostExecutionAnalysisTaskExecuter.java:35)
    at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:66)
    at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:58)
    at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:52)
    at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:52)
    at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:53)
    at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43)
    at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:203)
    at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:185)
    at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.processTask(AbstractTaskPlanExecutor.java:66)
    at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.run(AbstractTaskPlanExecutor.java:50)
    at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor.process(DefaultTaskPlanExecutor.java:25)
    at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter.execute(DefaultTaskGraphExecuter.java:110)
    at org.gradle.execution.SelectedTaskExecutionAction.execute(SelectedTaskExecutionAction.java:37)
    at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:37)
    at org.gradle.execution.DefaultBuildExecuter.access$000(DefaultBuildExecuter.java:23)
    at org.gradle.execution.DefaultBuildExecuter$1.proceed(DefaultBuildExecuter.java:43)
    at org.gradle.execution.DryRunBuildExecutionAction.execute(DryRunBuildExecutionAction.java:32)
    at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:37)
    at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:30)
    at org.gradle.initialization.DefaultGradleLauncher$4.run(DefaultGradleLauncher.java:153)
    at org.gradle.internal.Factories$1.create(Factories.java:22)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:91)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:53)
    at org.gradle.initialization.DefaultGradleLauncher.doBuildStages(DefaultGradleLauncher.java:150)
    at org.gradle.initialization.DefaultGradleLauncher.access$200(DefaultGradleLauncher.java:32)
    at org.gradle.initialization.DefaultGradleLauncher$1.create(DefaultGradleLauncher.java:98)
    at org.gradle.initialization.DefaultGradleLauncher$1.create(DefaultGradleLauncher.java:92)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:91)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:63)
    at org.gradle.initialization.DefaultGradleLauncher.doBuild(DefaultGradleLauncher.java:92)
    at org.gradle.initialization.DefaultGradleLauncher.run(DefaultGradleLauncher.java:83)
    at org.gradle.launcher.exec.InProcessBuildActionExecuter$DefaultBuildController.run(InProcessBuildActionExecuter.java:99)
    at org.gradle.tooling.internal.provider.ExecuteBuildActionRunner.run(ExecuteBuildActionRunner.java:28)
    at org.gradle.launcher.exec.ChainingBuildActionRunner.run(ChainingBuildActionRunner.java:35)
    at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:48)
    at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:30)
    at org.gradle.launcher.exec.ContinuousBuildActionExecuter.execute(ContinuousBuildActionExecuter.java:81)
    at org.gradle.launcher.exec.ContinuousBuildActionExecuter.execute(ContinuousBuildActionExecuter.java:46)
    at org.gradle.launcher.exec.DaemonUsageSuggestingBuildActionExecuter.execute(DaemonUsageSuggestingBuildActionExecuter.java:51)
    at org.gradle.launcher.exec.DaemonUsageSuggestingBuildActionExecuter.execute(DaemonUsageSuggestingBuildActionExecuter.java:28)
    at org.gradle.launcher.cli.RunBuildAction.run(RunBuildAction.java:43)
    at org.gradle.internal.Actions$RunnableActionAdapter.execute(Actions.java:173)
    at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(CommandLineActionFactory.java:239)
    at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(CommandLineActionFactory.java:212)
    at org.gradle.launcher.cli.JavaRuntimeValidationAction.execute(JavaRuntimeValidationAction.java:35)
    at org.gradle.launcher.cli.JavaRuntimeValidationAction.execute(JavaRuntimeValidationAction.java:24)
    at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:33)
    at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:22)
    at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:205)
    at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:169)
    at org.gradle.launcher.Main.doAction(Main.java:33)
    at org.gradle.launcher.bootstrap.EntryPoint.run(EntryPoint.java:45)
    at org.gradle.launcher.bootstrap.ProcessBootstrap.runNoExit(ProcessBootstrap.java:55)
    at org.gradle.launcher.bootstrap.ProcessBootstrap.run(ProcessBootstrap.java:36)
    at org.gradle.launcher.GradleMain.main(GradleMain.java:23)
Caused by: java.lang.RuntimeException: com.android.ide.common.process.ProcessException: Failed to execute aapt
    at com.android.build.gradle.tasks.ProcessAndroidResources.doFullTaskAction(ProcessAndroidResources.java:185)
    at com.android.build.gradle.internal.tasks.IncrementalTask.taskAction(IncrementalTask.java:82)
    at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:75)
    at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$IncrementalTaskAction.doExecute(AnnotationProcessingTaskFactory.java:245)
    at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.execute(AnnotationProcessingTaskFactory.java:221)
    at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$IncrementalTaskAction.execute(AnnotationProcessingTaskFactory.java:232)
    at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.execute(AnnotationProcessingTaskFactory.java:210)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:80)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:61)
    ... 57 more
Caused by: com.android.ide.common.process.ProcessException: Failed to execute aapt
    at com.android.builder.core.AndroidBuilder.processResources(AndroidBuilder.java:873)
    at com.android.build.gradle.tasks.ProcessAndroidResources.doFullTaskAction(ProcessAndroidResources.java:178)
    ... 65 more
Caused by: java.util.concurrent.ExecutionException: com.android.ide.common.process.ProcessException: Error while executing '/opt/android/sdk/build-tools/27.0.3/aapt' with arguments {package -f --no-crunch -I /opt/android/sdk/platforms/android-27/android.jar -M /data/jenkins/workspace/AP_Develop/SecureUnisignon/build/intermediates/manifests/aapt/release/AndroidManifest.xml -S /data/jenkins/workspace/AP_Develop/SecureUnisignon/build/intermediates/res/merged/release -m -J /data/jenkins/workspace/AP_Develop/SecureUnisignon/build/generated/source/r/release --custom-package com.bbk.secureunisignon --non-constant-id -0 apk --output-text-symbols /data/jenkins/workspace/AP_Develop/SecureUnisignon/build/intermediates/bundles/release --no-version-vectors}
    at com.google.common.util.concurrent.AbstractFuture$Sync.getValue(AbstractFuture.java:299)
    at com.google.common.util.concurrent.AbstractFuture$Sync.get(AbstractFuture.java:286)
    at com.google.common.util.concurrent.AbstractFuture.get(AbstractFuture.java:116)
    at com.android.builder.core.AndroidBuilder.processResources(AndroidBuilder.java:871)
    ... 66 more
Caused by: com.android.ide.common.process.ProcessException: Error while executing '/opt/android/sdk/build-tools/27.0.3/aapt' with arguments {package -f --no-crunch -I /opt/android/sdk/platforms/android-27/android.jar -M /data/jenkins/workspace/AP_Develop/SecureUnisignon/build/intermediates/manifests/aapt/release/AndroidManifest.xml -S /data/jenkins/workspace/AP_Develop/SecureUnisignon/build/intermediates/res/merged/release -m -J /data/jenkins/workspace/AP_Develop/SecureUnisignon/build/generated/source/r/release --custom-package com.bbk.secureunisignon --non-constant-id -0 apk --output-text-symbols /data/jenkins/workspace/AP_Develop/SecureUnisignon/build/intermediates/bundles/release --no-version-vectors}
    at com.android.build.gradle.internal.process.GradleProcessResult.buildProcessException(GradleProcessResult.java:75)
    at com.android.build.gradle.internal.process.GradleProcessResult.assertNormalExitValue(GradleProcessResult.java:49)
    at com.android.builder.internal.aapt.AbstractProcessExecutionAapt$1.onSuccess(AbstractProcessExecutionAapt.java:78)
    at com.android.builder.internal.aapt.AbstractProcessExecutionAapt$1.onSuccess(AbstractProcessExecutionAapt.java:74)
    at com.google.common.util.concurrent.Futures$6.run(Futures.java:1319)
    at com.google.common.util.concurrent.MoreExecutors$DirectExecutor.execute(MoreExecutors.java:457)
    at com.google.common.util.concurrent.ExecutionList.executeListener(ExecutionList.java:156)
    at com.google.common.util.concurrent.ExecutionList.execute(ExecutionList.java:145)
    at com.google.common.util.concurrent.AbstractFuture.set(AbstractFuture.java:185)
    at com.google.common.util.concurrent.SettableFuture.set(SettableFuture.java:53)
    at com.android.build.gradle.internal.process.GradleProcessExecutor$1.run(GradleProcessExecutor.java:60)
Caused by: org.gradle.process.internal.ExecException: Process 'command '/opt/android/sdk/build-tools/27.0.3/aapt'' finished with non-zero exit value 1
    at org.gradle.process.internal.DefaultExecHandle$ExecResultImpl.assertNormalExitValue(DefaultExecHandle.java:367)
    at com.android.build.gradle.internal.process.GradleProcessResult.assertNormalExitValue(GradleProcessResult.java:47)
    ... 9 more


BUILD FAILED

【我的Android进阶之旅】解决SDK升级到27.0.3遇到的GLIBC_2.14 not found、no acceptable C compiler found in $PATH等问题

【我的Android进阶之旅】解决SDK升级到27.0.3遇到的GLIBC_2.14 not found、no acceptable C compiler found in $PATH等问题

2.2、问题分析与解决

从上面的日志可以分析出来,在执行Android编译的时候,aapt执行失败了,因为aapt需要/lib64/libc.so.6文件

/lib64/libc.so.6: version `GLIBC_2.14' not found (required by /opt/android/sdk/build-tools/27.0.3/aapt)
/opt/android/sdk/build-tools/27.0.3/aapt: /lib64/libc.so.6: version `GLIBC_2.14' not found (required by /opt/android/sdk/build-tools/27.0.3/lib64/libc++.so)

然后我们就去解决该问题。

2.2.1 第一步,查看系统版本

[root@localhost glibc-build-2.14]#  cat /etc/redhat-release 
CentOS release 6.5 (Final)
[root@localhost glibc-build-2.14]# 

【我的Android进阶之旅】解决SDK升级到27.0.3遇到的GLIBC_2.14 not found、no acceptable C compiler found in $PATH等问题

2.2.2 第二步,glibc库版本

root@localhost /]#  strings /lib64/libc.so.6 |grep GLIBC_
GLIBC_2.2.5
GLIBC_2.2.6
GLIBC_2.3
GLIBC_2.3.2
GLIBC_2.3.3
GLIBC_2.3.4
GLIBC_2.4
GLIBC_2.5
GLIBC_2.6
GLIBC_2.7
GLIBC_2.8
GLIBC_2.9
GLIBC_2.10
GLIBC_2.11
GLIBC_2.12
GLIBC_PRIVATE
[root@localhost /]# 

由上面的信息可以看出系统是CentOS 6.5,最高支持glibc的版本为2.12,而研发程序要2.14版本,所以需要升级。

2.2.3 下载glibc库版本并升级

因为在尝试过程中,没有记录下来,现在我将hitstory操作的写在这里

【我的Android进阶之旅】解决SDK升级到27.0.3遇到的GLIBC_2.14 not found、no acceptable C compiler found in $PATH等问题

 #下载
 wget http://ftp.gnu.org/gnu/glibc/glibc-2.14.tar.gz 
 wget http://ftp.gnu.org/gnu/glibc/glibc-ports-2.14.tar.gz 
 #解压
 tar -xvf  glibc-2.14.tar.gz 
 tar -xvf  glibc-ports-2.14.tar.gz
 #创建相关目录
 mv glibc-ports-2.14 glibc-2.14/ports
 mkdir glibc-build-2.14
 cd glibc-build-2.14/ 

 #生成C编译的环境
 yum -y install gcc

 #编译C
 ../glibc-2.14/configure  --prefix=/usr --disable-profile --enable-add-ons --with-headers=/usr/include --with-binutils=/usr/bin
 make

 # 安装刚才编译好的 libc.so
 makeinstall 

 # 查看glibc库版本
 strings /lib64/libc.so.6 |grep GLIBC_

2.2.3.1 下载glibc-2.14.tar.gz 和 glibc-ports-2.14.tar.gz 并解压

执行以下命令即可下载

 wget http://ftp.gnu.org/gnu/glibc/glibc-2.14.tar.gz 
 wget http://ftp.gnu.org/gnu/glibc/glibc-ports-2.14.tar.gz 

执行以下命令即可解压

tar -xvf  glibc-2.14.tar.gz 
tar -xvf  glibc-ports-2.14.tar.gz

下面是下载并解压之后的目录图

【我的Android进阶之旅】解决SDK升级到27.0.3遇到的GLIBC_2.14 not found、no acceptable C compiler found in $PATH等问题

2.2.3.2 移动目录并创建目录

mv glibc-ports-2.14 glibc-2.14/ports
mkdir glibc-build-2.14
cd glibc-build-2.14/ 

将glibc-ports-2.14目录移动到 glibc-2.14/ports,并创建一个目录 glibc-build-2.14,并且接入该目录

2.2.3.3 安装gcc并编译

cd glibc-build-2.14/ 
../glibc-2.14/configure  --prefix=/usr --disable-profile --enable-add-ons --with-headers=/usr/include --with-binutils=/usr/bin
make

直接编译会出错,会报一个错误 configure: error: no acceptable C compiler found in $PATH,查看提示发现是因为该Linux服务器上没有安装gcc编译器,缺少gcc编译环境,可以通过yum安装gcc编译环境:yum install gcc

错误提示

configure: error: no acceptable C compiler found in $PATH
See `config.log' for more details.

执行以下命令安装gcc

 yum install gcc

执行一会儿,gcc环境就安装好了。然后我们可以重新执行上面的编译命令

cd glibc-build-2.14/ 
../glibc-2.14/configure  --prefix=/usr --disable-profile --enable-add-ons --with-headers=/usr/include --with-binutils=/usr/bin
make

这个命令会执行很长一段时间,大概执行10分钟左右。

如果遇到编译出错问题,可以参考
+ 【工作】Centos6.5 升级glibc解决“libc.so.6: version GLIBC_2.14 not found”报错问题

【我的Android进阶之旅】解决SDK升级到27.0.3遇到的GLIBC_2.14 not found、no acceptable C compiler found in $PATH等问题

【我的Android进阶之旅】解决SDK升级到27.0.3遇到的GLIBC_2.14 not found、no acceptable C compiler found in $PATH等问题

2.2.3.4 安装刚才编译好的so

继续完成后续的安装,执行下面的命令即可

make install

以上完成不报错的话,查看库文件,发现/lib64/libc.so.6软链接指向了2.14版本

[root@localhost glibc-2.14]# ll /lib64/libc.so.6 
lrwxrwxrwx. 1 root root 12 417 13:03 /lib64/libc.so.6 -> libc-2.14.so
[root@localhost glibc-2.14]# 

【我的Android进阶之旅】解决SDK升级到27.0.3遇到的GLIBC_2.14 not found、no acceptable C compiler found in $PATH等问题

2.2.3.5 再次查看glibc支持的版本

[root@localhost glibc-2.14]# strings /lib64/libc.so.6 |grep GLIBC_
GLIBC_2.2.5
GLIBC_2.2.6
GLIBC_2.3
GLIBC_2.3.2
GLIBC_2.3.3
GLIBC_2.3.4
GLIBC_2.4
GLIBC_2.5
GLIBC_2.6
GLIBC_2.7
GLIBC_2.8
GLIBC_2.9
GLIBC_2.10
GLIBC_2.11
GLIBC_2.12
GLIBC_2.13
GLIBC_2.14
GLIBC_PRIVATE
[root@localhost glibc-2.14]# 

【我的Android进阶之旅】解决SDK升级到27.0.3遇到的GLIBC_2.14 not found、no acceptable C compiler found in $PATH等问题

可以看到glibc支持的版本已经到2.14,再次执行程序就不会报错了。

2.3 重新运行Jenkins编译看看

再一次重新运行Jenkins进行编译,发现是编译成功的。大功告成!

【我的Android进阶之旅】解决SDK升级到27.0.3遇到的GLIBC_2.14 not found、no acceptable C compiler found in $PATH等问题


三、参考文档


【我的Android进阶之旅】解决SDK升级到27.0.3遇到的GLIBC_2.14 not found、no acceptable C compiler found in $PATH等问题

作者:欧阳鹏 欢迎转载,与人分享是进步的源泉!
转载请保留原文地址:https://blog.csdn.net/qq446282412/article/details/79974407

如果觉得本文对您有所帮助,欢迎您扫码下图所示的支付宝和微信支付二维码对本文进行随意打赏。您的支持将鼓励我继续创作!

【我的Android进阶之旅】解决SDK升级到27.0.3遇到的GLIBC_2.14 not found、no acceptable C compiler found in $PATH等问题

向我提问

【我的Android进阶之旅】解决SDK升级到27.0.3遇到的GLIBC_2.14 not found、no acceptable C compiler found in $PATH等问题

上一篇:冬季实战营第四期学习报告


下一篇:HTML5世界地图