Jenkins gradle sonarQube Android - android

I have to setup a job on Jenkins to build an Android Application. I have also a SonarQube server which is accessible at http://x.x.x.198/sonar.
I added a shell script that will be called to launch sonarqube analysis on the project.
SonarQube server and Jenkins run on different server, and I can access to the SonarQube host from Jenkins machine.
The build failed and here is the console output:
./gradlew sonarqube --stacktrace -Dsonar.url.host=http://x.x.x.198/sonar
Parallel execution with configuration on demand is an incubating feature.
Incremental java compilation is an incubating feature.
:app:sonarqubeSonarQube server [http://x.x.x.198/sonar] can not be reached
FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:sonarqube'.
> Unable to execute SonarQube
* Try:
Run with --info or --debug option to get more log output.
* Exception is:
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':app:sonarqube'.
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:64)
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.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:54)
at org.gradle.internal.concurrent.StoppableExecutorImpl$1.run(StoppableExecutorImpl.java:40)
Caused by: org.sonarsource.scanner.api.internal.ScannerException: Unable to execute SonarQube
at org.sonarsource.scanner.api.internal.IsolatedLauncherFactory$1.run(IsolatedLauncherFactory.java:84)
at org.sonarsource.scanner.api.internal.IsolatedLauncherFactory$1.run(IsolatedLauncherFactory.java:71)
at org.sonarsource.scanner.api.internal.IsolatedLauncherFactory.createLauncher(IsolatedLauncherFactory.java:71)
at org.sonarsource.scanner.api.internal.IsolatedLauncherFactory.createLauncher(IsolatedLauncherFactory.java:67)
at org.sonarsource.scanner.api.EmbeddedScanner.doStart(EmbeddedScanner.java:218)
at org.sonarsource.scanner.api.EmbeddedScanner.start(EmbeddedScanner.java:156)
at org.sonarqube.gradle.SonarQubeTask.run(SonarQubeTask.java:83)
at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:75)
at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.doExecute(AnnotationProcessingTaskFactory.java:227)
at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.execute(AnnotationProcessingTaskFactory.java:220)
at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.execute(AnnotationProcessingTaskFactory.java:209)
at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:585)
at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:568)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:80)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:61)
... 14 more
Caused by: java.lang.IllegalStateException: Fail to download libraries from server
at org.sonarsource.scanner.api.internal.Jars.downloadFiles(Jars.java:93)
at org.sonarsource.scanner.api.internal.Jars.download(Jars.java:70)
at org.sonarsource.scanner.api.internal.JarDownloader.download(JarDownloader.java:39)
at org.sonarsource.scanner.api.internal.IsolatedLauncherFactory$1.run(IsolatedLauncherFactory.java:75)
... 28 more
Caused by: java.lang.IllegalStateException: Status returned by url [http://10.133.64.198/sonar/batch_bootstrap/index] is not valid: [403]
at org.sonarsource.scanner.api.internal.ServerConnection.callUrl(ServerConnection.java:116)
at org.sonarsource.scanner.api.internal.ServerConnection.downloadString(ServerConnection.java:99)
at org.sonarsource.scanner.api.internal.Jars.downloadFiles(Jars.java:78)
... 31 more
BUILD FAILED
Total time: 1.632 secs
Build step 'Execute shell' marked build as failure
Finished: FAILURE
Has anyone already faced this problem? Need help :|
Thanks in advance.

Finaly found why it doesn't work. In my gradle.properties, i had specified some proxy properties. I have removed these entries (host, port, login, password, ...) so when sonarqube task is called, gradle does not use any proxy to access the SonarQube server. The task finished successfully on Jenkins and analysis reports uploaded to sonarqube server :).
This post helped me Sonarqube grade build failed with "SonarQube server [http://x.12.11.18:9000] can not be reached"
Hope this will help others.

2.7.1 is not back-compatible. Lock your plugin version to 2.6 in your pom.xml or upgrade your SonarQube
Workaround: Adding -Dsonar.host.url=http://my.server:9000 to mvn command works for me
Better than disabling the plugin, you may fix the plugin version to
2.6, which works fine, taking into account sonar.host.url.
For instance, with Maven in my case:
<pluginManagement>
</plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>sonar-maven-plugin</artifactId>
<version>2.6</version>
<!-- sonar.host.url not working with version 2.7 -->
</plugin>
</plugins>
</pluginManagement>

Related

Android build error: org.gradle.api.tasks.TaskExecutionException

I am getting following error when I try to build my app for release. I didn't get this error before update my Android studio and plugins. I'm using general libraries and nothing wrong in gradle configuration. Android Studio version is:
Android Studio 3.1.2
Build #AI-173.4720617, built on April 14, 2018
JRE: 1.8.0_152-release-1024-b02 amd64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
Windows 10 10.0
Gradle: 4.4
Here is the error log. As I understand, it does not implies specific part in my code.
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':app:lintVitalRelease'.
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:100)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:70)
at org.gradle.api.internal.tasks.execution.OutputDirectoryCreatingTaskExecuter.execute(OutputDirectoryCreatingTaskExecuter.java:51)
at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:62)
at org.gradle.api.internal.tasks.execution.ResolveTaskOutputCachingStateExecuter.execute(ResolveTaskOutputCachingStateExecuter.java:54)
at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:60)
at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:97)
at org.gradle.api.internal.tasks.execution.CleanupStaleOutputsExecuter.execute(CleanupStaleOutputsExecuter.java:87)
at org.gradle.api.internal.tasks.execution.ResolveTaskArtifactStateTaskExecuter.execute(ResolveTaskArtifactStateTaskExecuter.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:54)
at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43)
at org.gradle.api.internal.tasks.execution.CatchExceptionTaskExecuter.execute(CatchExceptionTaskExecuter.java:34)
at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker$1.run(DefaultTaskGraphExecuter.java:248)
at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:336)
at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:328)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:199)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:110)
at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:241)
at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:230)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.processTask(DefaultTaskPlanExecutor.java:123)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.access$200(DefaultTaskPlanExecutor.java:79)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:104)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:98)
at org.gradle.execution.taskgraph.DefaultTaskExecutionPlan.execute(DefaultTaskExecutionPlan.java:626)
at org.gradle.execution.taskgraph.DefaultTaskExecutionPlan.executeWithTask(DefaultTaskExecutionPlan.java:581)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.run(DefaultTaskPlanExecutor.java:98)
at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63)
at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:46)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:55)
at java.lang.Thread.run(Thread.java:745)
Caused by: org.gradle.api.GradleException: Lint found fatal errors while assembling a release target.
To proceed, either fix the issues identified by lint, or modify your build script as follows:
...
android {
lintOptions {
checkReleaseBuilds false
// Or, if you prefer, you can continue to check for errors in release builds,
// but continue the build even when errors are found:
abortOnError false
}
}
...
at com.android.tools.lint.gradle.LintGradleExecution.abort(LintGradleExecution.java:199)
at com.android.tools.lint.gradle.LintGradleExecution.runLint(LintGradleExecution.java:263)
at com.android.tools.lint.gradle.LintGradleExecution.lintSingleVariant(LintGradleExecution.java:359)
at com.android.tools.lint.gradle.LintGradleExecution.analyze(LintGradleExecution.java:93)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.android.tools.lint.gradle.api.ReflectiveLintRunner.runLint(ReflectiveLintRunner.kt:38)
at com.android.build.gradle.tasks.LintBaseTask.runLint(LintBaseTask.java:87)
at com.android.build.gradle.tasks.LintPerVariantTask.lint(LintPerVariantTask.java:41)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:73)
at org.gradle.api.internal.project.taskfactory.StandardTaskAction.doExecute(StandardTaskAction.java:46)
at org.gradle.api.internal.project.taskfactory.StandardTaskAction.execute(StandardTaskAction.java:39)
at org.gradle.api.internal.project.taskfactory.StandardTaskAction.execute(StandardTaskAction.java:26)
at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:780)
at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:747)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$1.run(ExecuteActionsTaskExecuter.java:121)
at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:336)
at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:328)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:199)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:110)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:110)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:92)
... 32 more
As the logcat pointed out that, I can easily get rid of this problems adding following lines in app/gradle.
android {
lintOptions {
checkReleaseBuilds false
// Or, if you prefer, you can continue to check for errors in release builds,
// but continue the build even when errors are found:
abortOnError false
}
}
However this only incase the problem which I couldn't find what causes the error. Is this in bug Android Studio or Gradle. I couldn't find any answer on web related this. Thanks in advance.
I found the problem thanks to #CommonsWare. When I run the gradle-lint in the gradle>verification section I got the following logs. Appereantly, some missing apostrophes and several missing translations causes the error. If anyone encounteres similar error, just check translations before anything else.
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:lint'.
> Lint found errors in the project; aborting build.
Fix the issues identified by lint, or add the following to your build script to proceed with errors:
...
android {
lintOptions {
abortOnError false
}
}
...
Errors found:
D:\Applications\APPFOLDER\app\src\main\res\values-fr\strings.xml:66: Error: Apostrophe not preceded by \ [StringEscaping]
D:\Applications\GunlukBurclar\app\src\main\res\values-ar\strings.xml:35: Error: "settings_birthhour" is translated here but not found in default locale [ExtraTranslation]
<string name="settings_birthhour">???? ???????:</string>
~~~~~~~~~~~~~~~~~~~~~~~~~
D:\Applications\APPFOLDER\app\src\main\res\values-az\strings.xml:35: Also translated here
D:\Applications\APPFOLDER\app\src\main\res\values-de\strings.xml:35: Also translated here
D:\Applications\APPFOLDER\app\src\main\res\values-es\strings.xml:35: Also translated here
D:\Applications\APPFOLDER\app\src\main\res\values-fa\strings.xml:35: Also translated here
D:\Applications\APPFOLDER\app\src\main\res\values-fr\strings.xml:35: Also translated here
D:\Applications\APPFOLDER\app\src\main\res\values-ja\strings.xml:35: Also translated here
D:\Applications\APPFOLDER\app\src\main\res\values-pt\strings.xml:35: Also translated here
D:\Applications\APPFOLDER\app\src\main\res\values-ru\strings.xml:35: Also translated here
D:\Applications\APPFOLDER\app\src\main\res\values-tr\strings.xml:59: Also translated here
D:\Applications\APPFOLDER\app\src\main\res\values-zh\strings.xml:35: Also translated here
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUİLD FAILED in 29s
33 actionable tasks: 17 executed, 16 up-to-date
00:44:14: Task execution finished 'lint'.
I had a similar error when I tried to compile.
Lint found fatal errors while assembling a release target.
To proceed, either fix the issues identified by lint, or modify your build script as follows:
...
android {
lintOptions {
checkReleaseBuilds false
// Or, if you prefer, you can continue to check for errors in release builds,
// but continue the build even when errors are found:
abortOnError false
}
}
...
----
After investigating several hours, he has found the solution. But I think the most important thing is the system that he has used.
In any Android file, in the left bar, we can click on the right button and access "Analyze", then we give an inspection code and we realize all Lint errors.
In my case, he corrected and got the problem. But this system gives a broad view of the health of the project code.
Resources:
https://developer.android.com/studio/write/lint?hl=es-419

AAPT2 failing to merge resources on Docker

I'm trying to build an Android application inside a docker container on a CI server and aapt2 is failing to merge the resources.
Base Docker Image is openjdk:8-alpine
The packages being installed in my image from alpine repositories are:
build-base alpine-sdk bash ca-certificates curl gcc git gzip musl-dev openssh-client python python-dev tar unzip wget
Also I'm downloading and installing Glibc from
https://github.com/sgerrand/alpine-pkg-glibc/releases/download/2.25-r0/glibc-2.25-r0.apk
The installed android sdk packages are
build-tools;26.0.0-rc2 platforms;android-25 platform-tools extras;android;m2repository extras;google;m2repository extras;google;google_play_services
The application is currently using Gradle Wrapper 4.0-rc-1
The error is:
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:mergeDebugResources'.
> Error: java.lang.ExceptionInInitializerError
* Exception is:
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':app:mergeDebugResources'.
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:100)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:70)
at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:64)
at org.gradle.api.internal.tasks.execution.ResolveTaskOutputCachingStateExecuter.execute(ResolveTaskOutputCachingStateExecuter.java:54)
at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:58)
at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:88)
at org.gradle.api.internal.tasks.execution.ResolveTaskArtifactStateTaskExecuter.execute(ResolveTaskArtifactStateTaskExecuter.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:54)
at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43)
at org.gradle.api.internal.tasks.execution.CatchExceptionTaskExecuter.execute(CatchExceptionTaskExecuter.java:34)
at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker$1.run(DefaultTaskGraphExecuter.java:242)
at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:303)
at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:295)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:177)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:91)
at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:235)
at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:224)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.processTask(DefaultTaskPlanExecutor.java:121)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.access$200(DefaultTaskPlanExecutor.java:77)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:102)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:96)
at org.gradle.execution.taskgraph.DefaultTaskExecutionPlan.execute(DefaultTaskExecutionPlan.java:611)
at org.gradle.execution.taskgraph.DefaultTaskExecutionPlan.executeWithTask(DefaultTaskExecutionPlan.java:566)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.run(DefaultTaskPlanExecutor.java:96)
at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63)
at org.gradle.internal.concurrent.StoppableExecutorImpl$1.run(StoppableExecutorImpl.java:46)
at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:55)
Caused by: com.android.build.gradle.tasks.ResourceException: Error: java.lang.ExceptionInInitializerError
at com.android.build.gradle.tasks.MergeResources.doFullTaskAction(MergeResources.java:201)
at com.android.build.gradle.internal.tasks.IncrementalTask.taskAction(IncrementalTask.java:80)
at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:73)
at org.gradle.api.internal.project.taskfactory.DefaultTaskClassInfoStore$IncrementalTaskAction.doExecute(DefaultTaskClassInfoStore.java:168)
at org.gradle.api.internal.project.taskfactory.DefaultTaskClassInfoStore$StandardTaskAction.execute(DefaultTaskClassInfoStore.java:134)
at org.gradle.api.internal.project.taskfactory.DefaultTaskClassInfoStore$StandardTaskAction.execute(DefaultTaskClassInfoStore.java:121)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$1.run(ExecuteActionsTaskExecuter.java:122)
at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:303)
at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:295)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:177)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:91)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:111)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:92)
... 27 more
Caused by: Error: java.lang.ExceptionInInitializerError
at com.android.ide.common.res2.MergedResourceWriter.postWriteAction(MergedResourceWriter.java:596)
at com.android.ide.common.res2.MergeWriter.end(MergeWriter.java:45)
at com.android.ide.common.res2.MergedResourceWriter.end(MergedResourceWriter.java:237)
at com.android.ide.common.res2.DataMerger.mergeData(DataMerger.java:301)
at com.android.ide.common.res2.ResourceMerger.mergeData(ResourceMerger.java:412)
at com.android.build.gradle.tasks.MergeResources.doFullTaskAction(MergeResources.java:194)
... 39 more
Caused by: java.util.concurrent.ExecutionException: java.lang.ExceptionInInitializerError
at com.android.ide.common.res2.MergedResourceWriter.postWriteAction(MergedResourceWriter.java:564)
... 44 more
Caused by: java.lang.ExceptionInInitializerError
... 45 more
Caused by: java.lang.ExceptionInInitializerError
at com.android.builder.internal.aapt.v2.AaptV2Jni.lambda$compile$0(AaptV2Jni.java:90)
Caused by: com.android.tools.aapt2.Aapt2Exception: Failed to load shared library '/tmp/aapt2_8990614974494423638.dir/libc++.so'
at com.android.tools.aapt2.Aapt2Jni.loadLibraryFromResource(Aapt2Jni.java:162)
at com.android.tools.aapt2.Aapt2Jni.loadSharedLibrariesFromResources(Aapt2Jni.java:204)
at com.android.tools.aapt2.Aapt2Jni.load(Aapt2Jni.java:97)
at com.android.tools.aapt2.Aapt2Jni.<clinit>(Aapt2Jni.java:43)
... 1 more
Caused by: java.lang.UnsatisfiedLinkError: /tmp/aapt2_8990614974494423638.dir/libc++.so: Error relocating /tmp/aapt2_8990614974494423638.dir/libc++.so: strtoll_l: symbol not found
at com.android.tools.aapt2.Aapt2Jni.loadLibraryFromResource(Aapt2Jni.java:159)
... 4 more
BUILD FAILED in 30s
I tried installing different alpine packages with no luck.
I have the feeling that this is related to Glibc and/or Musl libraries, but I don't understand it enough not to know how to solve this problem
Also, everything works fine on a very similar image (alpine based too) with build-tools 25.0.3 and Gradle 3.5.
Any clues? Thanks
I stumble upon the same error. The problem as you suspected is that Alpine Linux ships with Musl instead of GNU libc, the Android SDK tooling requires glibc.
You could use something like this: https://github.com/frol/docker-alpine-glibc, or create a similar image on your own if you're comfortable with someone else compiling glibc for you.
You can check which libraries are missing (ENOENT singal) with: $ strace ./aapt2
Then try to create a simbolic link of those libraries to the expected path.

Kotlin Android Compile

I'm getting this error and can't figure out why:
Error:Execution failed for task ':app:compileDebugKotlin'.
> java.io.IOException: java.lang.ArrayIndexOutOfBoundsException: 0
I think it has to do with android gradle plugin version not being compatible with kotlin gradle plugin version. I didn't upgrade anything, it worked before. But suddenly, this just started to appear and prevent the compilation process.
Is there any public place where i can find the latest android studio plugin based on the latest Kotlin plugin?
thanks in advances,
J
StackTrade:
* Exception is:
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':app:compileDebugKotlin'.
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.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:54)
at org.gradle.internal.concurrent.StoppableExecutorImpl$1.run(StoppableExecutorImpl.java:40)
Caused by: org.gradle.api.UncheckedIOException: java.io.IOException: java.lang.ArrayIndexOutOfBoundsException: 0
at org.gradle.internal.UncheckedException.throwAsUncheckedException(UncheckedException.java:43)
at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:78)
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)
... 14 more
Caused by: java.io.IOException: java.lang.ArrayIndexOutOfBoundsException: 0
at org.jetbrains.kotlin.com.intellij.util.io.CompressedAppendableFile.loadChunk(CompressedAppendableFile.java:207)
at org.jetbrains.kotlin.com.intellij.util.io.CompressedAppendableFile.access$700(CompressedAppendableFile.java:36)
at org.jetbrains.kotlin.com.intellij.util.io.CompressedAppendableFile$FileChunkReadCache.get(CompressedAppendableFile.java:482)
at org.jetbrains.kotlin.com.intellij.util.io.CompressedAppendableFile$SegmentedChunkInputStream.read(CompressedAppendableFile.java:522)
at org.jetbrains.kotlin.com.intellij.util.io.PersistentHashMapValueStorage.readBytes(PersistentHashMapValueStorage.java:376)
at org.jetbrains.kotlin.com.intellij.util.io.PersistentHashMap.doGet(PersistentHashMap.java:510)
at org.jetbrains.kotlin.com.intellij.util.io.PersistentHashMap.get(PersistentHashMap.java:464)
at org.jetbrains.kotlin.incremental.storage.LazyStorage.get(LazyStorage.kt:67)
at org.jetbrains.kotlin.incremental.IncrementalCacheImpl$SourceToClassesMap.get(IncrementalCacheImpl.kt:558)
at org.jetbrains.kotlin.incremental.IncrementalCacheImpl.classesBySources(IncrementalCacheImpl.kt:128)
at org.jetbrains.kotlin.gradle.tasks.KotlinCompile.callCompiler(Tasks.kt:445)
at org.jetbrains.kotlin.gradle.tasks.KotlinCompile.callCompiler(Tasks.kt:151)
at org.jetbrains.kotlin.gradle.tasks.AbstractKotlinCompile.execute(Tasks.kt:117)
at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:75)
... 20 more
Caused by: java.lang.ArrayIndexOutOfBoundsException: 0
at org.iq80.snappy.SnappyDecompressor.readUncompressedLength(SnappyDecompressor.java:410)
at org.iq80.snappy.SnappyDecompressor.uncompress(SnappyDecompressor.java:38)
at org.iq80.snappy.Snappy.uncompress(Snappy.java:37)
at org.jetbrains.kotlin.com.intellij.util.CompressionUtil.readCompressedWithoutOriginalBufferLength(CompressionUtil.java:97)
at org.jetbrains.kotlin.com.intellij.util.io.CompressedAppendableFile.decompress(CompressedAppendableFile.java:370)
at org.jetbrains.kotlin.com.intellij.util.io.CompressedAppendableFile.loadChunk(CompressedAppendableFile.java:191)
... 33 more
BUILD FAILED
Go to Files > Settings and turn off completely Instant Run, I mean all checkboxes should be unchecked.
Clean and rebuild project.
Also, check your Gradle configuration and update Gradle and Android Studio if you're not using the latest.
According to this issue, changing Gradle plugin version from 2.10 to 2.14.1 may help.
Protip: Use combination Ctrl+Shift+A to find commands like
Configure Kotlin in Project
Configure Kotlin Updates
Convert Java
File to Kotlin
This is what worked for me:
1.Turn on off Gradle Offline mode it should be online.
Clean and rebuild project.
I had this error recently out of the blue as well. After far too long searching for an answer, I eventually tried Build | Rebuild Project, and it worked. It doesn't seem like a compiler problem, but rather a project setup one (since Kotlin works on my other project).

GAE Endpoints gradle build error while generating classes

Gradle build fails on appengineEndpointsExportClientLibs task with the following stacktrace. I can run the backend module but I can't update any backend classes and see the change.
org.gradle.api.tasks.TaskValidationException: A problem was found with the configuration of task ':backend:appengineEndpointsExportClientLibs'.
at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:55)
at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:42)
at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:52)
Caused by: org.gradle.api.InvalidUserDataException: No value has been specified for property 'clientLibJarOut'.
at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:47)
... 51 more

java.lang.NoSuchMethodError: com.google.common.io.Files.asCharSink

I'm getting this error since I updated Android Studio to 9.1 and to gradle 14.+ :
I'm executing the task assembleRelease on my project.
And here is what I got :
* What went wrong:
Execution failed for task ':app:dexParisRelease'.
> com.google.common.io.Files.asCharSink(Ljava/io/File;Ljava/nio/charset/Charset;[Lcom/google/common/io/FileWriteMode;)Lcom/google/common/io/CharSink;
* Try:
Run with --info or --debug option to get more log output.
* Exception is:
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':app:dexParisRelease'.
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:64)
at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:58)
at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:42)
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.api.internal.AbstractTask.executeWithoutThrowingTaskFailure(AbstractTask.java:305)
at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.executeTask(AbstractTaskPlanExecutor.java:79)
at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.processTask(AbstractTaskPlanExecutor.java:63)
at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.run(AbstractTaskPlanExecutor.java:51)
at org.gradle.internal.concurrent.DefaultExecutorFactory$StoppableExecutorImpl$1.run(DefaultExecutorFactory.java:64)
Caused by: java.lang.NoSuchMethodError: com.google.common.io.Files.asCharSink(Ljava/io/File;Ljava/nio/charset/Charset;[Lcom/google/common/io/FileWriteMode;)Lcom/google/common/io/CharSink;
at com.android.builder.core.AndroidBuilder.getFilesToAdd(AndroidBuilder.java:1429)
at com.android.builder.core.AndroidBuilder.convertByteCode(AndroidBuilder.java:1408)
at com.android.builder.core.AndroidBuilder$convertByteCode$4.call(Unknown Source)
at com.android.build.gradle.tasks.Dex.doTaskAction(Dex.groovy:136)
at com.android.build.gradle.tasks.Dex.this$5$doTaskAction(Dex.groovy)
at com.android.build.gradle.tasks.Dex$this$5$doTaskAction.callCurrent(Unknown Source)
at com.android.build.gradle.tasks.Dex.taskAction(Dex.groovy:79)
at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:63)
at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$IncrementalTaskAction.doExecute(AnnotationProcessingTaskFactory.java:235)
at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.execute(AnnotationProcessingTaskFactory.java:211)
at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$IncrementalTaskAction.execute(AnnotationProcessingTaskFactory.java:222)
at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.execute(AnnotationProcessingTaskFactory.java:200)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:80)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:61)
... 13 more
Any idea please ?
You use two different versions of Guava at the same time.
Your stacktrace is incomplete so I cannot answer fully. Also, I don't know Android Studio.
But, I can read your stack trace and I see that the class AndroidBuilder is trying to access the method com.google.common.io.Files.asCharSink. The method asCharSink exists from Guava 14.
Usually the error you get happens when you mess with dependencies.
Given that you see some stack trace components indicating Gradle and that you mention using Gradle, I gather that you get this issue when building using Gradle.
So I don't think that you actually mess with dependencies but rather that you have incompatibilities between your gradle version (requiring Guava 14 or later) and the Guava actually loaded in the classpath of your builder.
So check how Gradle is called and update the Guava version of that tool to 14 or later.

Categories

Resources