Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Building with Gradle Throws MalformedJsonException

Whenever I try to build my project with Gradle, I get this error

:app:mergeDebugResources FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:mergeDebugResources'.
> Error: com.google.common.util.concurrent.UncheckedExecutionException: java.lang.RuntimeException: com.google.gson.stream.MalformedJsonException: Use JsonReader.setLenient(true) to accept malformed JSON at line 1 column 1

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

* Exception is:
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':app:mergeDebugResources'.
    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:310)
    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.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:54)
    at org.gradle.internal.concurrent.StoppableExecutorImpl$1.run(StoppableExecutorImpl.java:40)
Caused by: com.android.build.gradle.tasks.ResourceException: Error: com.google.common.util.concurrent.UncheckedExecutionException: java.lang.RuntimeException: com.google.gson.stream.MalformedJsonException: Use JsonReader.setLenient(true) to accept malformed JSON at line 1 column 1
    at com.android.build.gradle.tasks.MergeResources.doFullTaskAction(MergeResources.java:164)
    at com.android.build.gradle.internal.tasks.IncrementalTask.taskAction(IncrementalTask.java:104)
    at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:75)
    at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$IncrementalTaskAction.doExecute(AnnotationProcessingTaskFactory.java:243)
    at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.execute(AnnotationProcessingTaskFactory.java:219)
    at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$IncrementalTaskAction.execute(AnnotationProcessingTaskFactory.java:230)
    at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.execute(AnnotationProcessingTaskFactory.java:208)
    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: Error: com.google.common.util.concurrent.UncheckedExecutionException: java.lang.RuntimeException: com.google.gson.stream.MalformedJsonException: Use JsonReader.setLenient(true) to accept malformed JSON at line 1 column 1
    at com.android.ide.common.res2.MergeWriter.end(MergeWriter.java:54)
    at com.android.ide.common.res2.MergedResourceWriter.end(MergedResourceWriter.java:129)
    at com.android.ide.common.res2.DataMerger.mergeData(DataMerger.java:291)
    at com.android.ide.common.res2.ResourceMerger.mergeData(ResourceMerger.java:48)
    at com.android.build.gradle.tasks.MergeResources.doFullTaskAction(MergeResources.java:157)
    ... 22 more
Caused by: java.lang.RuntimeException: com.google.common.util.concurrent.UncheckedExecutionException: java.lang.RuntimeException: com.google.gson.stream.MalformedJsonException: Use JsonReader.setLenient(true) to accept malformed JSON at line 1 column 1
    at com.android.ide.common.internal.WaitableExecutor.waitForTasksWithQuickFail(WaitableExecutor.java:117)
    at com.android.ide.common.res2.MergeWriter.end(MergeWriter.java:50)
    ... 26 more
Caused by: com.google.common.util.concurrent.UncheckedExecutionException: java.lang.RuntimeException: com.google.gson.stream.MalformedJsonException: Use JsonReader.setLenient(true) to accept malformed JSON at line 1 column 1
    at com.google.common.cache.LocalCache$Segment.get(LocalCache.java:2201)
    at com.google.common.cache.LocalCache.get(LocalCache.java:3934)
    at com.google.common.cache.LocalCache.getOrLoad(LocalCache.java:3938)
    at com.google.common.cache.LocalCache$LocalLoadingCache.get(LocalCache.java:4821)
    at com.android.ide.common.blame.MergingLog.getWholeFileMap(MergingLog.java:128)
    at com.android.ide.common.blame.MergingLog.logCopy(MergingLog.java:88)
    at com.android.ide.common.blame.MergingLog.logCopy(MergingLog.java:98)
    at com.android.ide.common.res2.MergedResourceWriter$1.call(MergedResourceWriter.java:215)
    at com.android.ide.common.res2.MergedResourceWriter$1.call(MergedResourceWriter.java:171)
Caused by: java.lang.RuntimeException: com.google.gson.stream.MalformedJsonException: Use JsonReader.setLenient(true) to accept malformed JSON at line 1 column 1
    at com.android.ide.common.blame.MergingLogPersistUtil.loadFromSingleFile(MergingLogPersistUtil.java:293)
    at com.android.ide.common.blame.MergingLog$1.load(MergingLog.java:55)
    at com.android.ide.common.blame.MergingLog$1.load(MergingLog.java:52)
    at com.google.common.cache.LocalCache$LoadingValueReference.loadFuture(LocalCache.java:3524)
    at com.google.common.cache.LocalCache$Segment.loadSync(LocalCache.java:2317)
    at com.google.common.cache.LocalCache$Segment.lockedGetOrLoad(LocalCache.java:2280)
    at com.google.common.cache.LocalCache$Segment.get(LocalCache.java:2195)
    ... 8 more
Caused by: com.google.gson.stream.MalformedJsonException: Use JsonReader.setLenient(true) to accept malformed JSON at line 1 column 1
    at com.google.gson.stream.JsonReader.syntaxError(JsonReader.java:1505)
    at com.google.gson.stream.JsonReader.checkLenient(JsonReader.java:1386)
    at com.google.gson.stream.JsonReader.doPeek(JsonReader.java:572)
    at com.google.gson.stream.JsonReader.beginArray(JsonReader.java:332)
    at com.android.ide.common.blame.MergingLogPersistUtil.loadFromSingleFile(MergingLogPersistUtil.java:266)
    ... 14 more


BUILD FAILED

I have been working on this project for almost a year now, this is the first time I've seen this issue building with Gradle. Google doesn't return any helpful results either.

My computer's harddrive stopped responding so I had to do a force shutdown while Android Studio was open, and that might have something to do with the issue.

Steps taken:

  • Restart Android Studio

  • Invalidate Caches and Restart

  • Delete .gradle folder in my home directory

This is very aggravating, and I can't seem to find a fix for this. Thank you for the help!

like image 897
ccrama Avatar asked Oct 22 '15 15:10

ccrama


1 Answers

This should work:

  1. Delete .gradle folder from the workspace.
  2. Restart Android Studio.
  3. Build -> Clean Project.
like image 167
Saurav Daruka Avatar answered Oct 20 '22 15:10

Saurav Daruka