问:
Error:Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'. >
My project was running well but suddenly it starts raising an ERROR:

Gradle build finished with 1 error(s)

Error:Execution failed for task
':app:transformDexArchiveWithExternalLibsDexMergerForDebug'.
java.lang.IllegalStateException: Expected BEGIN_ARRAY but was STRING at line 1 column 1 path $

It raises on both Android Emulator and Real Device.

I tried to

delete .gradle folder on root of the project

re-make and re-sync project

close and open Android Studio

Restart Windows

Change API (26, 27)

BUT no success.

Android Studio 3.0.1

EDIT 1: It seems that it's caused by com.google.code.gson:gson:2.8.2

Here's the gradle console output with stack trace:

```<code>Executing tasks: [:app:assembleDebug]

Configuration on demand is an incubating feature.
:app:preBuild UP-TO-DATE
:app:preDebugBuild UP-TO-DATE
:app:compileDebugAidl UP-TO-DATE
:app:compileDebugRenderscript UP-TO-DATE
:app:checkDebugManifest UP-TO-DATE
:app:generateDebugBuildConfig UP-TO-DATE
:app:prepareLintJar UP-TO-DATE
:app:generateDebugResValues UP-TO-DATE
:app:generateDebugResources UP-TO-DATE
:app:mergeDebugResources UP-TO-DATE
:app:createDebugCompatibleScreenManifests UP-TO-DATE
:app:processDebugManifest
:app:splitsDiscoveryTaskDebug UP-TO-DATE
:app:processDebugResources
:app:generateDebugSources
:app:javaPreCompileDebug UP-TO-DATE
:app:compileDebugJavaWithJavac UP-TO-DATE
:app:compileDebugNdk NO-SOURCE
:app:compileDebugSources UP-TO-DATE
:app:mergeDebugShaders UP-TO-DATE
:app:compileDebugShaders UP-TO-DATE
:app:generateDebugAssets UP-TO-DATE
:app:mergeDebugAssets UP-TO-DATE
:app:transformClassesWithDexBuilderForDebug UP-TO-DATE
:app:transformDexArchiveWithExternalLibsDexMergerForDebug FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'.
> java.lang.IllegalStateException: Expected BEGIN_ARRAY but was STRING at line 1 column 1 path $

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

* Exception is:
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'.
    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:63)
    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: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:197)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:107)
    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:124)
    at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.access$200(DefaultTaskPlanExecutor.java:80)
    at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:105)
    at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:99)
    at org.gradle.execution.taskgraph.DefaultTaskExecutionPlan.execute(DefaultTaskExecutionPlan.java:625)
    at org.gradle.execution.taskgraph.DefaultTaskExecutionPlan.executeWithTask(DefaultTaskExecutionPlan.java:580)
    at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.run(DefaultTaskPlanExecutor.java:99)
    at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor.process(DefaultTaskPlanExecutor.java:60)
    at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter.execute(DefaultTaskGraphExecuter.java:128)
    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:46)
    at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:37)
    at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:30)
    at org.gradle.initialization.DefaultGradleLauncher$ExecuteTasks.run(DefaultGradleLauncher.java:311)
    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:197)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:107)
    at org.gradle.initialization.DefaultGradleLauncher.runTasks(DefaultGradleLauncher.java:202)
    at org.gradle.initialization.DefaultGradleLauncher.doBuildStages(DefaultGradleLauncher.java:132)
    at org.gradle.initialization.DefaultGradleLauncher.executeTasks(DefaultGradleLauncher.java:107)
    at org.gradle.internal.invocation.GradleBuildController$1.call(GradleBuildController.java:78)
    at org.gradle.internal.invocation.GradleBuildController$1.call(GradleBuildController.java:75)
    at org.gradle.internal.work.DefaultWorkerLeaseService.withLocks(DefaultWorkerLeaseService.java:152)
    at org.gradle.internal.invocation.GradleBuildController.doBuild(GradleBuildController.java:100)
    at org.gradle.internal.invocation.GradleBuildController.run(GradleBuildController.java:75)
    at org.gradle.tooling.internal.provider.runner.BuildModelActionRunner.run(BuildModelActionRunner.java:53)
    at org.gradle.launcher.exec.ChainingBuildActionRunner.run(ChainingBuildActionRunner.java:35)
    at org.gradle.launcher.exec.ChainingBuildActionRunner.run(ChainingBuildActionRunner.java:35)
    at org.gradle.tooling.internal.provider.ValidatingBuildActionRunner.run(ValidatingBuildActionRunner.java:32)
    at org.gradle.launcher.exec.RunAsBuildOperationBuildActionRunner$1.run(RunAsBuildOperationBuildActionRunner.java:43)
    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:197)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:107)
    at org.gradle.launcher.exec.RunAsBuildOperationBuildActionRunner.run(RunAsBuildOperationBuildActionRunner.java:40)
    at org.gradle.tooling.internal.provider.SubscribableBuildActionRunner.run(SubscribableBuildActionRunner.java:51)
    at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:45)
    at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:29)
    at org.gradle.launcher.exec.BuildTreeScopeBuildActionExecuter.execute(BuildTreeScopeBuildActionExecuter.java:39)
    at org.gradle.launcher.exec.BuildTreeScopeBuildActionExecuter.execute(BuildTreeScopeBuildActionExecuter.java:25)
    at org.gradle.tooling.internal.provider.ContinuousBuildActionExecuter.execute(ContinuousBuildActionExecuter.java:71)
    at org.gradle.tooling.internal.provider.ContinuousBuildActionExecuter.execute(ContinuousBuildActionExecuter.java:45)
    at org.gradle.tooling.internal.provider.ServicesSetupBuildActionExecuter.execute(ServicesSetupBuildActionExecuter.java:51)
    at org.gradle.tooling.internal.provider.ServicesSetupBuildActionExecuter.execute(ServicesSetupBuildActionExecuter.java:32)
    at org.gradle.tooling.internal.provider.GradleThreadBuildActionExecuter.execute(GradleThreadBuildActionExecuter.java:36)
    at org.gradle.tooling.internal.provider.GradleThreadBuildActionExecuter.execute(GradleThreadBuildActionExecuter.java:25)
    at org.gradle.tooling.internal.provider.ParallelismConfigurationBuildActionExecuter.execute(ParallelismConfigurationBuildActionExecuter.java:43)
    at org.gradle.tooling.internal.provider.ParallelismConfigurationBuildActionExecuter.execute(ParallelismConfigurationBuildActionExecuter.java:29)
    at org.gradle.tooling.internal.provider.StartParamsValidatingActionExecuter.execute(StartParamsValidatingActionExecuter.java:64)
    at org.gradle.tooling.internal.provider.StartParamsValidatingActionExecuter.execute(StartParamsValidatingActionExecuter.java:29)
    at org.gradle.tooling.internal.provider.SessionFailureReportingActionExecuter.execute(SessionFailureReportingActionExecuter.java:55)
    at org.gradle.tooling.internal.provider.SessionFailureReportingActionExecuter.execute(SessionFailureReportingActionExecuter.java:42)
    at org.gradle.tooling.internal.provider.SetupLoggingActionExecuter.execute(SetupLoggingActionExecuter.java:58)
    at org.gradle.tooling.internal.provider.SetupLoggingActionExecuter.execute(SetupLoggingActionExecuter.java:33)
    at org.gradle.launcher.daemon.server.exec.ExecuteBuild.doBuild(ExecuteBuild.java:67)
    at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:36)
    at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
    at org.gradle.launcher.daemon.server.exec.WatchForDisconnection.execute(WatchForDisconnection.java:37)
    at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
    at org.gradle.launcher.daemon.server.exec.ResetDeprecationLogger.execute(ResetDeprecationLogger.java:26)
    at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
    at org.gradle.launcher.daemon.server.exec.RequestStopIfSingleUsedDaemon.execute(RequestStopIfSingleUsedDaemon.java:34)
    at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
    at org.gradle.launcher.daemon.server.exec.ForwardClientInput$2.call(ForwardClientInput.java:74)
    at org.gradle.launcher.daemon.server.exec.ForwardClientInput$2.call(ForwardClientInput.java:72)
    at org.gradle.util.Swapper.swap(Swapper.java:38)
    at org.gradle.launcher.daemon.server.exec.ForwardClientInput.execute(ForwardClientInput.java:72)
    at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
    at org.gradle.launcher.daemon.server.exec.LogAndCheckHealth.execute(LogAndCheckHealth.java:55)
    at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
    at org.gradle.launcher.daemon.server.exec.LogToClient.doBuild(LogToClient.java:62)
    at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:36)
    at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
    at org.gradle.launcher.daemon.server.exec.EstablishBuildEnvironment.doBuild(EstablishBuildEnvironment.java:82)
    at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:36)
    at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
    at org.gradle.launcher.daemon.server.exec.StartBuildOrRespondWithBusy$1.run(StartBuildOrRespondWithBusy.java:50)
    at org.gradle.launcher.daemon.server.DaemonStateCoordinator$1.run(DaemonStateCoordinator.java:297)
    at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63)
    at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:46)
    at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:55)
Caused by: com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Expected BEGIN_ARRAY but was STRING at line 1 column 1 path $
    at com.google.gson.Gson.fromJson(Gson.java:817)
    at com.google.gson.Gson.fromJson(Gson.java:770)
    at com.android.build.gradle.internal.pipeline.SubStream.loadSubStreams(SubStream.java:129)
    at com.android.build.gradle.internal.pipeline.IntermediateFolderUtils.<init>(IntermediateFolderUtils.java:66)
    at com.android.build.gradle.internal.pipeline.IntermediateStream.init(IntermediateStream.java:191)
    at com.android.build.gradle.internal.pipeline.IntermediateStream.asOutput(IntermediateStream.java:135)
    at com.android.build.gradle.internal.pipeline.TransformTask$2.call(TransformTask.java:229)
    at com.android.build.gradle.internal.pipeline.TransformTask$2.call(TransformTask.java:218)
    at com.android.builder.profile.ThreadRecorder.record(ThreadRecorder.java:102)
    at com.android.build.gradle.internal.pipeline.TransformTask.transform(TransformTask.java:213)
    at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:73)
    at org.gradle.api.internal.project.taskfactory.DefaultTaskClassInfoStore$IncrementalTaskAction.doExecute(DefaultTaskClassInfoStore.java:173)
    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:336)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:328)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:197)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:107)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:111)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:92)
    ... 102 more
Caused by: java.lang.IllegalStateException: Expected BEGIN_ARRAY but was STRING at line 1 column 1 path $
    at com.google.gson.stream.JsonReader.beginArray(JsonReader.java:351)
    at com.google.gson.internal.bind.CollectionTypeAdapterFactory$Adapter.read(CollectionTypeAdapterFactory.java:79)
    at com.google.gson.internal.bind.CollectionTypeAdapterFactory$Adapter.read(CollectionTypeAdapterFactory.java:60)
    at com.google.gson.Gson.fromJson(Gson.java:805)
    ... 122 more

* Get more help at https://help.gradle.org

BUILD FAILED in 1s

19 actionable tasks: 3 executed, 16 up-to-date
</code>```

答:
Disable instant run in your project

Go to File | Settings | Build, Execution, Deployment | Instant Run -> Uncheck it

Body:
My project was running well but suddenly it starts raising an ERROR:

Gradle build finished with 1 error(s)

Error:Execution failed for task
':app:transformDexArchiveWithExternalLibsDexMergerForDebug'.
java.lang.IllegalStateException: Expected BEGIN_ARRAY but was STRING at line 1 column 1 path $

It raises on both Android Emulator and Real Device.

I tried to

delete .gradle folder on root of the project

re-make and re-sync project

close and open Android Studio

Restart Windows

Change API (26, 27)

BUT no success.

Android Studio 3.0.1

EDIT 1: It seems that it's caused by com.google.code.gson:gson:2.8.2

Here's the gradle console output with stack trace:

Executing tasks: [:app:assembleDebug]

Configuration on demand is an incubating feature.
:app:preBuild UP-TO-DATE
:app:preDebugBuild UP-TO-DATE
:app:compileDebugAidl UP-TO-DATE
:app:compileDebugRenderscript UP-TO-DATE
:app:checkDebugManifest UP-TO-DATE
:app:generateDebugBuildConfig UP-TO-DATE
:app:prepareLintJar UP-TO-DATE
:app:generateDebugResValues UP-TO-DATE
:app:generateDebugResources UP-TO-DATE
:app:mergeDebugResources UP-TO-DATE
:app:createDebugCompatibleScreenManifests UP-TO-DATE
:app:processDebugManifest
:app:splitsDiscoveryTaskDebug UP-TO-DATE
:app:processDebugResources
:app:generateDebugSources
:app:javaPreCompileDebug UP-TO-DATE
:app:compileDebugJavaWithJavac UP-TO-DATE
:app:compileDebugNdk NO-SOURCE
:app:compileDebugSources UP-TO-DATE
:app:mergeDebugShaders UP-TO-DATE
:app:compileDebugShaders UP-TO-DATE
:app:generateDebugAssets UP-TO-DATE
:app:mergeDebugAssets UP-TO-DATE
:app:transformClassesWithDexBuilderForDebug UP-TO-DATE
:app:transformDexArchiveWithExternalLibsDexMergerForDebug FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'.
> java.lang.IllegalStateException: Expected BEGIN_ARRAY but was STRING at line 1 column 1 path $

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

* Exception is:
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'.
    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:63)
    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: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:197)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:107)
    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:124)
    at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.access$200(DefaultTaskPlanExecutor.java:80)
    at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:105)
    at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:99)
    at org.gradle.execution.taskgraph.DefaultTaskExecutionPlan.execute(DefaultTaskExecutionPlan.java:625)
    at org.gradle.execution.taskgraph.DefaultTaskExecutionPlan.executeWithTask(DefaultTaskExecutionPlan.java:580)
    at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.run(DefaultTaskPlanExecutor.java:99)
    at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor.process(DefaultTaskPlanExecutor.java:60)
    at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter.execute(DefaultTaskGraphExecuter.java:128)
    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:46)
    at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:37)
    at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:30)
    at org.gradle.initialization.DefaultGradleLauncher$ExecuteTasks.run(DefaultGradleLauncher.java:311)
    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:197)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:107)
    at org.gradle.initialization.DefaultGradleLauncher.runTasks(DefaultGradleLauncher.java:202)
    at org.gradle.initialization.DefaultGradleLauncher.doBuildStages(DefaultGradleLauncher.java:132)
    at org.gradle.initialization.DefaultGradleLauncher.executeTasks(DefaultGradleLauncher.java:107)
    at org.gradle.internal.invocation.GradleBuildController$1.call(GradleBuildController.java:78)
    at org.gradle.internal.invocation.GradleBuildController$1.call(GradleBuildController.java:75)
    at org.gradle.internal.work.DefaultWorkerLeaseService.withLocks(DefaultWorkerLeaseService.java:152)
    at org.gradle.internal.invocation.GradleBuildController.doBuild(GradleBuildController.java:100)
    at org.gradle.internal.invocation.GradleBuildController.run(GradleBuildController.java:75)
    at org.gradle.tooling.internal.provider.runner.BuildModelActionRunner.run(BuildModelActionRunner.java:53)
    at org.gradle.launcher.exec.ChainingBuildActionRunner.run(ChainingBuildActionRunner.java:35)
    at org.gradle.launcher.exec.ChainingBuildActionRunner.run(ChainingBuildActionRunner.java:35)
    at org.gradle.tooling.internal.provider.ValidatingBuildActionRunner.run(ValidatingBuildActionRunner.java:32)
    at org.gradle.launcher.exec.RunAsBuildOperationBuildActionRunner$1.run(RunAsBuildOperationBuildActionRunner.java:43)
    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:197)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:107)
    at org.gradle.launcher.exec.RunAsBuildOperationBuildActionRunner.run(RunAsBuildOperationBuildActionRunner.java:40)
    at org.gradle.tooling.internal.provider.SubscribableBuildActionRunner.run(SubscribableBuildActionRunner.java:51)
    at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:45)
    at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:29)
    at org.gradle.launcher.exec.BuildTreeScopeBuildActionExecuter.execute(BuildTreeScopeBuildActionExecuter.java:39)
    at org.gradle.launcher.exec.BuildTreeScopeBuildActionExecuter.execute(BuildTreeScopeBuildActionExecuter.java:25)
    at org.gradle.tooling.internal.provider.ContinuousBuildActionExecuter.execute(ContinuousBuildActionExecuter.java:71)
    at org.gradle.tooling.internal.provider.ContinuousBuildActionExecuter.execute(ContinuousBuildActionExecuter.java:45)
    at org.gradle.tooling.internal.provider.ServicesSetupBuildActionExecuter.execute(ServicesSetupBuildActionExecuter.java:51)
    at org.gradle.tooling.internal.provider.ServicesSetupBuildActionExecuter.execute(ServicesSetupBuildActionExecuter.java:32)
    at org.gradle.tooling.internal.provider.GradleThreadBuildActionExecuter.execute(GradleThreadBuildActionExecuter.java:36)
    at org.gradle.tooling.internal.provider.GradleThreadBuildActionExecuter.execute(GradleThreadBuildActionExecuter.java:25)
    at org.gradle.tooling.internal.provider.ParallelismConfigurationBuildActionExecuter.execute(ParallelismConfigurationBuildActionExecuter.java:43)
    at org.gradle.tooling.internal.provider.ParallelismConfigurationBuildActionExecuter.execute(ParallelismConfigurationBuildActionExecuter.java:29)
    at org.gradle.tooling.internal.provider.StartParamsValidatingActionExecuter.execute(StartParamsValidatingActionExecuter.java:64)
    at org.gradle.tooling.internal.provider.StartParamsValidatingActionExecuter.execute(StartParamsValidatingActionExecuter.java:29)
    at org.gradle.tooling.internal.provider.SessionFailureReportingActionExecuter.execute(SessionFailureReportingActionExecuter.java:55)
    at org.gradle.tooling.internal.provider.SessionFailureReportingActionExecuter.execute(SessionFailureReportingActionExecuter.java:42)
    at org.gradle.tooling.internal.provider.SetupLoggingActionExecuter.execute(SetupLoggingActionExecuter.java:58)
    at org.gradle.tooling.internal.provider.SetupLoggingActionExecuter.execute(SetupLoggingActionExecuter.java:33)
    at org.gradle.launcher.daemon.server.exec.ExecuteBuild.doBuild(ExecuteBuild.java:67)
    at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:36)
    at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
    at org.gradle.launcher.daemon.server.exec.WatchForDisconnection.execute(WatchForDisconnection.java:37)
    at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
    at org.gradle.launcher.daemon.server.exec.ResetDeprecationLogger.execute(ResetDeprecationLogger.java:26)
    at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
    at org.gradle.launcher.daemon.server.exec.RequestStopIfSingleUsedDaemon.execute(RequestStopIfSingleUsedDaemon.java:34)
    at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
    at org.gradle.launcher.daemon.server.exec.ForwardClientInput$2.call(ForwardClientInput.java:74)
    at org.gradle.launcher.daemon.server.exec.ForwardClientInput$2.call(ForwardClientInput.java:72)
    at org.gradle.util.Swapper.swap(Swapper.java:38)
    at org.gradle.launcher.daemon.server.exec.ForwardClientInput.execute(ForwardClientInput.java:72)
    at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
    at org.gradle.launcher.daemon.server.exec.LogAndCheckHealth.execute(LogAndCheckHealth.java:55)
    at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
    at org.gradle.launcher.daemon.server.exec.LogToClient.doBuild(LogToClient.java:62)
    at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:36)
    at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
    at org.gradle.launcher.daemon.server.exec.EstablishBuildEnvironment.doBuild(EstablishBuildEnvironment.java:82)
    at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:36)
    at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
    at org.gradle.launcher.daemon.server.exec.StartBuildOrRespondWithBusy$1.run(StartBuildOrRespondWithBusy.java:50)
    at org.gradle.launcher.daemon.server.DaemonStateCoordinator$1.run(DaemonStateCoordinator.java:297)
    at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63)
    at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:46)
    at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:55)
Caused by: com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Expected BEGIN_ARRAY but was STRING at line 1 column 1 path $
    at com.google.gson.Gson.fromJson(Gson.java:817)
    at com.google.gson.Gson.fromJson(Gson.java:770)
    at com.android.build.gradle.internal.pipeline.SubStream.loadSubStreams(SubStream.java:129)
    at com.android.build.gradle.internal.pipeline.IntermediateFolderUtils.<init>(IntermediateFolderUtils.java:66)
    at com.android.build.gradle.internal.pipeline.IntermediateStream.init(IntermediateStream.java:191)
    at com.android.build.gradle.internal.pipeline.IntermediateStream.asOutput(IntermediateStream.java:135)
    at com.android.build.gradle.internal.pipeline.TransformTask$2.call(TransformTask.java:229)
    at com.android.build.gradle.internal.pipeline.TransformTask$2.call(TransformTask.java:218)
    at com.android.builder.profile.ThreadRecorder.record(ThreadRecorder.java:102)
    at com.android.build.gradle.internal.pipeline.TransformTask.transform(TransformTask.java:213)
    at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:73)
    at org.gradle.api.internal.project.taskfactory.DefaultTaskClassInfoStore$IncrementalTaskAction.doExecute(DefaultTaskClassInfoStore.java:173)
    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:336)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:328)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:197)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:107)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:111)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:92)
    ... 102 more
Caused by: java.lang.IllegalStateException: Expected BEGIN_ARRAY but was STRING at line 1 column 1 path $
    at com.google.gson.stream.JsonReader.beginArray(JsonReader.java:351)
    at com.google.gson.internal.bind.CollectionTypeAdapterFactory$Adapter.read(CollectionTypeAdapterFactory.java:79)
    at com.google.gson.internal.bind.CollectionTypeAdapterFactory$Adapter.read(CollectionTypeAdapterFactory.java:60)
    at com.google.gson.Gson.fromJson(Gson.java:805)
    ... 122 more

* Get more help at https://help.gradle.org

BUILD FAILED in 1s

19 actionable tasks: 3 executed, 16 up-to-date


来源: stackexchange

问:
Is Tensorflow Dataset API slower than Queues?
I replaced CIFAR-10 preprocessing pipeline in the project with Dataset API approach and it resulted in performance decrease of about 10-20%.

Preporcessing is rather standart:
- read image from disk
- make random/crop and flip
- shuffle, batch
- feed to the model

Overall i see that batche processing is now 15% faster, but every once in a while (or, more precisely, whenever I reinitialize dataframe or expect reshuffling) the batch is being blocked for up long time (30 sec) which totals to slower epoch-per-epoch processing.

This behaviour seems to do something with internal hashing. If I reduce N in ds.shuffle(buffer_size=N) delays are shorter but proportionally more frequent. Removing shuffle at all results to delays as if buffer_size was set to dataset size.

Can somebody explain internal logic of Dataset API when it comes to reading/caching? Is there any reason at all to expect Dataset API to work faster than manually created Queues?

I am using TF 1.3.

答:
Suggested things didn't solve my problem back in the days, but I would like to add a couple of recommendations for those, who don't want to learn about queues and still get the most out of TF data pipeline:

Convert your input data into TFRecord (as cumbersome as it might be)

Use recommended input pipeline format

.

```<code>files = tf.data.Dataset.list_files(data_dir)
ds = tf.data.TFRecordDataset(files, num_parallel_reads=32)
ds = (ds.shuffle(10000)
    .repeat(EPOCHS)
    .map(parser_fn, num_parallel_calls=64)
    .batch(batch_size)
)
dataset = dataset.prefetch(2)
</code>```

Where you have to pay attention to 3 main components:

num_parallel_read=32 to parallelize disk IO operations

num_parallel_calls=64 to parallelize calls to parser function

prefetch(2)

ContentLicense: CC BY-SA 3.0

Body:
Suggested things didn't solve my problem back in the days, but I would like to add a couple of recommendations for those, who don't want to learn about queues and still get the most out of TF data pipeline:

Convert your input data into TFRecord (as cumbersome as it might be)

Use recommended input pipeline format

.

files = tf.data.Dataset.list_files(data_dir)
ds = tf.data.TFRecordDataset(files, num_parallel_reads=32)
ds = (ds.shuffle(10000)
    .repeat(EPOCHS)
    .map(parser_fn, num_parallel_calls=64)
    .batch(batch_size)
)
dataset = dataset.prefetch(2)

Where you have to pay attention to 3 main components:

num_parallel_read=32 to parallelize disk IO operations

num_parallel_calls=64 to parallelize calls to parser function

prefetch(2)

ContentLicense: CC BY-SA 4.0


问:
Regroup button events in one event
I use 6 different buttons doing practically the same thing.

private void VisaCreaDoc_Click(object sender, RoutedEventArgs e)
{
    ViewModel.ValidateItem(InfosPosteViewModel.CREADOC);
}

private void VisaTravaux_Click(object sender, RoutedEventArgs e)
{
    ViewModel.ValidateItem(InfosPosteViewModel.TRAVAUX);

}

private void VisaRemiseOuvrageIR_Click(object sender, RoutedEventArgs e)
{
    ViewModel.ValidateItem(InfosPosteViewModel.REMISEOUVRIR);
}

private void VisaRemiseOuvrageExpl_Click(object sender, RoutedEventArgs e)
{
    ViewModel.ValidateItem(InfosPosteViewModel.REMISEOUVREXPL);
}

private void VisaMES_Click(object sender, RoutedEventArgs e)
{
    ViewModel.ValidateItem(InfosPosteViewModel.MISEENSERVICE);
}

private void VisaEncodageArchivage_Click(object sender, RoutedEventArgs e)
{
    ViewModel.ValidateItem(InfosPosteViewModel.ENCODAGEARCHIVAGE);
```

As you can see, they're using a function from the ViewModel with a different parameter.

Is there any way to regroup the 6 button events to have only one and kind of pass the parameter directly in the XAML call or something similar to avoid having the "code duplication" ?

答: Maybe you can avoid some duplicate code by creating a command for the ViewModel function (see Introduction to WPF Commands). As far as I know you can also define a CommandParameter in XAML.

Title: Regroup button events in one event

Body:
I use 6 different buttons doing practically the same thing.

private void VisaCreaDoc_Click(object sender, RoutedEventArgs e)
{
    ViewModel.ValidateItem(InfosPosteViewModel.CREADOC);
}

private void VisaTravaux_Click(object sender, RoutedEventArgs e)
{
    ViewModel.ValidateItem(InfosPosteViewModel.TRAVAUX);

}

private void VisaRemiseOuvrageIR_Click(object sender, RoutedEventArgs e)
{
    ViewModel.ValidateItem(InfosPosteViewModel.REMISEOUVRIR);
}

private void VisaRemiseOuvrageExpl_Click(object sender, RoutedEventArgs e)
{
    ViewModel.ValidateItem(InfosPosteViewModel.REMISEOUVREXPL);
}

private void VisaMES_Click(object sender, RoutedEventArgs e)
{
    ViewModel.ValidateItem(InfosPosteViewModel.MISEENSERVICE);
}

private void VisaEncodageArchivage_Click(object sender, RoutedEventArgs e)
{
    ViewModel.ValidateItem(InfosPosteViewModel.ENCODAGEARCHIVAGE);

As you can see, they're using a function from the ViewModel with a different parameter.

Is there any way to regroup the 6 button events to have only one and kind of pass the parameter directly in the XAML call or something similar to avoid having the "code duplication" ?


问:
Get Data from API using retrofit
I need to get the details from the API and display them in textviews.

Here's my API in JSON format  : https://imgur.com/a/WI98ymx

I need to get the data like username, user image, user phone number etc in Strings and display them in textviews.
How do i request all the fields and show the list in different textviews?

Here's my Login interface

```<code>package com.example.hb.loginapi;

import java.util.List;

   import retrofit2.Call;
   import retrofit2.http.GET;

  import retrofit2.http.POST;

   import retrofit2.http.Query;

    interface Login {

   @POST("user_login_v1")
   Call<ResObj>  loginInfo(@Query("password") String password,
   @Query("email") String email);

   @GET("user_login_v1")
   Call<List> getUserDetails();

}
</code>```

Here's my ResObj class

```<code>package com.example.hb.loginapi;

import com.google.gson.annotations.SerializedName;
import java.util.List;

 public class ResObj {

@SerializedName("settings")
private Settings settings;

@SerializedName("data")
private List<DataItem> data;

public void setSettings(Settings settings){
    this.settings = settings;
}

public Settings getSettings(){
    return settings;
}

public void setData(List<DataItem> data){
    this.data = data;
}

public List<DataItem> getData(){
    return data;
}

public class Settings {

    @SerializedName("success")
    private String success;

    @SerializedName("message")
    private String message;

    @SerializedName("fields")
    private List<String> fields;

    public void setSuccess(String success) {
        this.success = success;
    }

    public String getSuccess() {
        return success;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public String getMessage() {
        return message;
    }

    public void setFields(List<String> fields) {
        this.fields = fields;
    }

    public List<String> getFields() {
        return fields;
    }
}

public class DataItem{

    @SerializedName("user_name")
    private String userName;

    @SerializedName("search_report_count")
    private String searchReportCount;

    @SerializedName("access_token")
    private String accessToken;

    @SerializedName("profile_image")
    private String profileImage;

    @SerializedName("is_social")
    private String isSocial;

    @SerializedName("is_notification_enabled")
    private String isNotificationEnabled;

    @SerializedName("user_id")
    private String userId;

    @SerializedName("phone")
    private String phone;

    @SerializedName("plate_number")
    private String plateNumber;

    @SerializedName("state_id")
    private String stateId;

    @SerializedName("state")
    private String state;

    @SerializedName("email")
    private String email;

    @SerializedName("status")
    private String status;

    public void setUserName(String userName){
        this.userName = userName;
    }

    public String getUserName(){
        return userName;
    }

    public void setSearchReportCount(String searchReportCount){
        this.searchReportCount = searchReportCount;
    }

    public String getSearchReportCount(){
        return searchReportCount;
    }

    public void setAccessToken(String accessToken){
        this.accessToken = accessToken;
    }

    public String getAccessToken(){
        return accessToken;
    }

    public void setProfileImage(String profileImage){
        this.profileImage = profileImage;
    }

    public String getProfileImage(){
        return profileImage;
    }

    public void setIsSocial(String isSocial){
        this.isSocial = isSocial;
    }

    public String getIsSocial(){
        return isSocial;
    }

    public void setIsNotificationEnabled(String isNotificationEnabled){
        this.isNotificationEnabled = isNotificationEnabled;
    }

    public String getIsNotificationEnabled(){
        return isNotificationEnabled;
    }

    public void setUserId(String userId){
        this.userId = userId;
    }

    public String getUserId(){
        return userId;
    }

    public void setPhone(String phone){
        this.phone = phone;
    }

    public String getPhone(){
        return phone;
    }

    public void setPlateNumber(String plateNumber){
        this.plateNumber = plateNumber;
    }

    public String getPlateNumber(){
        return plateNumber;
    }

    public void setStateId(String stateId){
        this.stateId = stateId;
    }

    public String getStateId(){
        return stateId;
    }

    public void setState(String state){
        this.state = state;
    }

    public String getState(){
        return state;
    }

    public void setEmail(String email){
        this.email = email;
    }

    public String getEmail(){
        return email;
    }

    public void setStatus(String status){
        this.status = status;
    }

    public String getStatus(){
        return status;
    }
}

}
</code>```

My Layout

```<code><?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    tools:context=".MainActivity"
    android:background="#e9edf6"
    android:scrollbars="vertical">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical">

    <com.mikhaellopez.circularimageview.CircularImageView
        android:id="@+id/userProfilePic"
        android:layout_gravity="center"
        android:layout_marginTop="30dp"
        android:layout_width="150dp"
        android:layout_height="150dp"
        />

        <TextView
            android:id="@+id/userName"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:textColor="@color/fnavyblue"
            android:textSize="20sp"
            android:text="DummyNameText"
            android:layout_marginTop="50dp"
            />

        <TextView
            android:id="@+id/userID"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:textColor="@color/fnavyblue"
            android:textSize="20sp"
            android:text="DummyUserIDText"
            android:layout_marginTop="20dp"
            />

        <TextView
            android:id="@+id/emailID"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:textColor="@color/fnavyblue"
            android:textSize="20sp"
            android:text="DummyEmailText"
            android:layout_marginTop="20dp"
            />

        <TextView
            android:id="@+id/userStatus"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:textColor="@color/fnavyblue"
            android:textSize="20sp"
            android:text="DummyStatusText"
            android:layout_marginTop="20dp"
            />

        <TextView
            android:id="@+id/userPlateNum"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:textColor="@color/fnavyblue"
            android:textSize="20sp"
            android:text="DummyPlateNumText"
            android:layout_marginTop="20dp"
            />

        <TextView
            android:id="@+id/userStateName"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:textColor="@color/fnavyblue"
            android:textSize="20sp"
            android:text="DummyStateNameText"
            android:layout_marginTop="20dp"
            />

        <TextView
            android:id="@+id/userStateID"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:textColor="@color/fnavyblue"
            android:textSize="20sp"
            android:text="DummyStateIDText"
            android:layout_marginTop="20dp"
            />

        <TextView
            android:id="@+id/userSearchReportCount"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:textColor="@color/fnavyblue"
            android:textSize="20sp"
            android:text="DummySearchReportCountText"
            android:layout_marginTop="20dp"
            />

    </LinearLayout>
</ScrollView>
</code>```

My MainActivity.java

```<code>public class MainActivity extends AppCompatActivity {

List emList=new ArrayList();

List dataList=new ArrayList();

List userDets=new ArrayList();

ImageView proImg;
TextView userName;
TextView userID;
TextView userEmail;
TextView userStatus;
TextView userPlateNum;
TextView userStateName;
TextView userStateID;
TextView userSearchReportCount;

String img;
String name;
String idUser;
String emailID;
String status;
String plateNum;
String stateName;
String stateID;
String searchReportCount;

String email;

Login login;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    emList.add(email);

    userName=findViewById(R.id.userName);

    email=getIntent().getStringExtra("email");

     login=ApiUtils.getLoginClass();

    getUserData();
}

private void getUserData(){
    Call<List> call=login.getUserDetails();

    call.enqueue(new Callback() {
        @Override
        public void onResponse(Call call, Response response) {
            if(response.isSuccessful()){
                List resObj=(List)response.body();

                for(int i=0;i<resObj.size();i++){
                    Log.e("data",resObj.get(i).toString());
                }
 }
        }

        @Override
        public void onFailure(Call call, Throwable t) {
            Toast.makeText(getApplicationContext(),t.getMessage(),Toast.LENGTH_LONG).show();
        }
    });
}
</code>```

}

I don't know what to write in the onResponse() method.

答:
Update api interface method

```<code>@GET("user_login_v1")
Call<ResObj> getUserDetails();
</code>```

Update your getUserData() method

```<code>private void getUserData(){
    Call<ResObj> call=login.getUserDetails();

    call.enqueue(new Callback() {
        @Override
        public void onResponse(Call call, Response response) {
            if(response.isSuccessful()){
                ResObj resObj=(ResObj)response.body();
                DataItem user=reObj.getData().get(0);
                //set value on yout text views
                userName.setText(user.getUserName())
                userID.setText(user.getUserId())
                //....
               }
        }

        @Override
        public void onFailure(Call call, Throwable t) {
            Toast.makeText(getApplicationContext(),t.getMessage(),Toast.LENGTH_LONG).show();
        }
    });
}
</code>```

Title: Get Data from API using retrofit

Body:
I need to get the details from the API and display them in textviews.

Here's my API in JSON format  : https://imgur.com/a/WI98ymx

I need to get the data like username, user image, user phone number etc in Strings and display them in textviews.
How do i request all the fields and show the list in different textviews?

Here's my Login interface

package com.example.hb.loginapi;

import java.util.List;

   import retrofit2.Call;
   import retrofit2.http.GET;

  import retrofit2.http.POST;

   import retrofit2.http.Query;

    interface Login {

   @POST("user_login_v1")
   Call<ResObj>  loginInfo(@Query("password") String password,
   @Query("email") String email);

   @GET("user_login_v1")
   Call<List> getUserDetails();

}

Here's my ResObj class

package com.example.hb.loginapi;

import com.google.gson.annotations.SerializedName;
import java.util.List;

 public class ResObj {

@SerializedName("settings")
private Settings settings;

@SerializedName("data")
private List<DataItem> data;

public void setSettings(Settings settings){
    this.settings = settings;
}

public Settings getSettings(){
    return settings;
}

public void setData(List<DataItem> data){
    this.data = data;
}

public List<DataItem> getData(){
    return data;
}

public class Settings {

    @SerializedName("success")
    private String success;

    @SerializedName("message")
    private String message;

    @SerializedName("fields")
    private List<String> fields;

    public void setSuccess(String success) {
        this.success = success;
    }

    public String getSuccess() {
        return success;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public String getMessage() {
        return message;
    }

    public void setFields(List<String> fields) {
        this.fields = fields;
    }

    public List<String> getFields() {
        return fields;
    }
}

public class DataItem{

    @SerializedName("user_name")
    private String userName;

    @SerializedName("search_report_count")
    private String searchReportCount;

    @SerializedName("access_token")
    private String accessToken;

    @SerializedName("profile_image")
    private String profileImage;

    @SerializedName("is_social")
    private String isSocial;

    @SerializedName("is_notification_enabled")
    private String isNotificationEnabled;

    @SerializedName("user_id")
    private String userId;

    @SerializedName("phone")
    private String phone;

    @SerializedName("plate_number")
    private String plateNumber;

    @SerializedName("state_id")
    private String stateId;

    @SerializedName("state")
    private String state;

    @SerializedName("email")
    private String email;

    @SerializedName("status")
    private String status;

    public void setUserName(String userName){
        this.userName = userName;
    }

    public String getUserName(){
        return userName;
    }

    public void setSearchReportCount(String searchReportCount){
        this.searchReportCount = searchReportCount;
    }

    public String getSearchReportCount(){
        return searchReportCount;
    }

    public void setAccessToken(String accessToken){
        this.accessToken = accessToken;
    }

    public String getAccessToken(){
        return accessToken;
    }

    public void setProfileImage(String profileImage){
        this.profileImage = profileImage;
    }

    public String getProfileImage(){
        return profileImage;
    }

    public void setIsSocial(String isSocial){
        this.isSocial = isSocial;
    }

    public String getIsSocial(){
        return isSocial;
    }

    public void setIsNotificationEnabled(String isNotificationEnabled){
        this.isNotificationEnabled = isNotificationEnabled;
    }

    public String getIsNotificationEnabled(){
        return isNotificationEnabled;
    }

    public void setUserId(String userId){
        this.userId = userId;
    }

    public String getUserId(){
        return userId;
    }

    public void setPhone(String phone){
        this.phone = phone;
    }

    public String getPhone(){
        return phone;
    }

    public void setPlateNumber(String plateNumber){
        this.plateNumber = plateNumber;
    }

    public String getPlateNumber(){
        return plateNumber;
    }

    public void setStateId(String stateId){
        this.stateId = stateId;
    }

    public String getStateId(){
        return stateId;
    }

    public void setState(String state){
        this.state = state;
    }

    public String getState(){
        return state;
    }

    public void setEmail(String email){
        this.email = email;
    }

    public String getEmail(){
        return email;
    }

    public void setStatus(String status){
        this.status = status;
    }

    public String getStatus(){
        return status;
    }
}

}

My Layout

<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    tools:context=".MainActivity"
    android:background="#e9edf6"
    android:scrollbars="vertical">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical">

    <com.mikhaellopez.circularimageview.CircularImageView
        android:id="@+id/userProfilePic"
        android:layout_gravity="center"
        android:layout_marginTop="30dp"
        android:layout_width="150dp"
        android:layout_height="150dp"
        />

        <TextView
            android:id="@+id/userName"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:textColor="@color/fnavyblue"
            android:textSize="20sp"
            android:text="DummyNameText"
            android:layout_marginTop="50dp"
            />

        <TextView
            android:id="@+id/userID"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:textColor="@color/fnavyblue"
            android:textSize="20sp"
            android:text="DummyUserIDText"
            android:layout_marginTop="20dp"
            />

        <TextView
            android:id="@+id/emailID"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:textColor="@color/fnavyblue"
            android:textSize="20sp"
            android:text="DummyEmailText"
            android:layout_marginTop="20dp"
            />

        <TextView
            android:id="@+id/userStatus"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:textColor="@color/fnavyblue"
            android:textSize="20sp"
            android:text="DummyStatusText"
            android:layout_marginTop="20dp"
            />

        <TextView
            android:id="@+id/userPlateNum"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:textColor="@color/fnavyblue"
            android:textSize="20sp"
            android:text="DummyPlateNumText"
            android:layout_marginTop="20dp"
            />

        <TextView
            android:id="@+id/userStateName"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:textColor="@color/fnavyblue"
            android:textSize="20sp"
            android:text="DummyStateNameText"
            android:layout_marginTop="20dp"
            />

        <TextView
            android:id="@+id/userStateID"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:textColor="@color/fnavyblue"
            android:textSize="20sp"
            android:text="DummyStateIDText"
            android:layout_marginTop="20dp"
            />

        <TextView
            android:id="@+id/userSearchReportCount"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:textColor="@color/fnavyblue"
            android:textSize="20sp"
            android:text="DummySearchReportCountText"
            android:layout_marginTop="20dp"
            />

    </LinearLayout>
</ScrollView>

My MainActivity.java

public class MainActivity extends AppCompatActivity {

List emList=new ArrayList();

List dataList=new ArrayList();

List userDets=new ArrayList();

ImageView proImg;
TextView userName;
TextView userID;
TextView userEmail;
TextView userStatus;
TextView userPlateNum;
TextView userStateName;
TextView userStateID;
TextView userSearchReportCount;

String img;
String name;
String idUser;
String emailID;
String status;
String plateNum;
String stateName;
String stateID;
String searchReportCount;

String email;

Login login;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    emList.add(email);

    userName=findViewById(R.id.userName);

    email=getIntent().getStringExtra("email");

     login=ApiUtils.getLoginClass();

    getUserData();
}

private void getUserData(){
    Call<List> call=login.getUserDetails();

    call.enqueue(new Callback() {
        @Override
        public void onResponse(Call call, Response response) {
            if(response.isSuccessful()){
                List resObj=(List)response.body();

                for(int i=0;i<resObj.size();i++){
                    Log.e("data",resObj.get(i).toString());
                }
 }
        }

        @Override
        public void onFailure(Call call, Throwable t) {
            Toast.makeText(getApplicationContext(),t.getMessage(),Toast.LENGTH_LONG).show();
        }
    });
}

}

I don't know what to write in the onResponse() method.

Body:
Update api interface method

@GET("user_login_v1")
Call<ResObj> getUserDetails();

Update your getUserData() method

private void getUserData(){
    Call<ResObj> call=login.getUserDetails();

    call.enqueue(new Callback() {
        @Override
        public void onResponse(Call call, Response response) {
            if(response.isSuccessful()){
                ResObj resObj=(ResObj)response.body();
                DataItem user=reObj.getData().get(0);
                //set value on yout text views
                userName.setText(user.getUserName())
                userID.setText(user.getUserId())
                //....
               }
        }

        @Override
        public void onFailure(Call call, Throwable t) {
            Toast.makeText(getApplicationContext(),t.getMessage(),Toast.LENGTH_LONG).show();
        }
    });
}


问:
JQuery calendar not displaying booked dates from database as marked
I have this jquery calender where multiple dates can be selected and pushed to an array. These dates are saved in db later. This part works fine.

Later after refreshing the page calendar doesn't show all those dates as marked.

Dates in database are stored as a string in single cell. I have tried to return it as a string as well as array after exploding it. Doesn't work.

Her is my code:

```<code>var preSavedDates = [];

// Function1 Starts
$.ajax({
    type:'POST',
    url:'../includes/ajax/availabily_dates_fetch.php',
    data: "&listingID=" + listingID,
    datatype: 'json',
    success:function(response){
        preSavedDates = response;
        //alert([response]);
    }
});
// Function1 Ends

$('#show-next-month').calendar({
    num_next_month: 11,
    num_prev_month: 0,
    unavailable: preSavedDates, // Here is the variable needed
    //unavailable: ['2019-2-5','2019-3-6','2019-1-25'], Works
    onSelectDate: function(date, month, year, thisEvent){
        var dateData = [year, month, date].join('-');
        dateClickEvent(dateData, thisEvent);
    }
});

// Function2 to cross check if variable exists
alert(preSavedDates);
// Function2 Ends
// Produces - 2019-2-5,2019-3-6,2019-1-25
</code>```

I expect dates from database to be highlighted in the calendar.

答:
It was silly me.

Calendar was getting initialized on document ready, and values for dates were fetched on an event at later time.

So calendar was considering default var preSavedDates = []; value.

Now that I have set calendar to initialize at the same time of fetching dates, it's working now.

Body:
I have this jquery calender where multiple dates can be selected and pushed to an array. These dates are saved in db later. This part works fine.

Later after refreshing the page calendar doesn't show all those dates as marked.

Dates in database are stored as a string in single cell. I have tried to return it as a string as well as array after exploding it. Doesn't work.

Her is my code:

var preSavedDates = [];

// Function1 Starts
$.ajax({
    type:'POST',
    url:'../includes/ajax/availabily_dates_fetch.php',
    data: "&listingID=" + listingID,
    datatype: 'json',
    success:function(response){
        preSavedDates = response;
        //alert([response]);
    }
});
// Function1 Ends

$('#show-next-month').calendar({
    num_next_month: 11,
    num_prev_month: 0,
    unavailable: preSavedDates, // Here is the variable needed
    //unavailable: ['2019-2-5','2019-3-6','2019-1-25'], Works
    onSelectDate: function(date, month, year, thisEvent){
        var dateData = [year, month, date].join('-');
        dateClickEvent(dateData, thisEvent);
    }
});

// Function2 to cross check if variable exists
alert(preSavedDates);
// Function2 Ends
// Produces - 2019-2-5,2019-3-6,2019-1-25

I expect dates from database to be highlighted in the calendar.


问:
Getting Data from server using rest Api how to set the Data in a Text in react native
I am getting the data from server successfully i am not under standing how to set that data in a Text tag in React native here is my code please help.

```<code> state = {
    data: []
  };

  componentWillMount() {
    this.fetchFreelancerData();
  }
  fetchFreelancerData = async () => {
    const { params } = this.props.navigation.state;
    const response = await fetch(
      BaseUrl + "listing/get_freelancers?listing_type=single&profile_id=" + params.profile_id
    );
    const json = await response.json();
    console.log(json[0].name);
    this.setState({ fetchFreelancer: json });
  };
</code>```

Here i am getting the response in json const successfully. i have also console the log as well and terminal is showing the name properly.But i am not understanding how to display the name in the Text tag.

this line  console.log(json[0].name); is getting the name properly.

```<code><View style={styles.viewStyle}>
                        <Text style = {styles.nameStyle}>

                        </Text>
</View>
</code>```

I have to set the name in the text as shown up here.

this is the response i am getting form server.

```<code>[
  Object {
    "_address": "",
    "_awards": Array [],
    "_educations": Array [],
    "_english_level": "",
    "_experience": Array [],
    "_featured_timestamp": "wt-featured",
    "_gender": "male",
    "_is_verified": "no",
    "_latitude": "",
    "_longitude": "",
    "_perhour_rate": "$125.00",
    "_projects": Array [],
    "_tag_line": "The Future Of Memory",
    "badge": Object {
      "badget_color": "#e67e22",
      "badget_url": "https://amentotech.com/projects/api_workreap/wp-content/uploads/2019/03/featured.png",
    },
    "banner_img": "https://amentotech.com/projects/api_workreap/wp-content/themes/workreap/images/frbanner-350x172.jpg",
    "cancelled_jobs": 0,
    "completed_jobs": 1,
    "content": "",
    "favorit": "",
    "freelancer_link": "https://amentotech.com/projects/api_workreap/freelancer/wezalono-alone/",
    "location": Object {
      "_country": "Turkey",
      "flag": "https://amentotech.com/projects/api_workreap/wp-content/uploads/2019/03/img-01-4.png",
    },
    "member_since": "April 13, 2019",
    "name": "wezalono Alone",
    "ongoning_jobs": 0,
    "profile_id": 604,
    "profile_img": "https://amentotech.com/projects/api_workreap/wp-content/uploads/2019/03/29-1-100x100.jpg",
    "rating_filter": "5",
    "reviews": Array [
      Object {
        "_is_verified": "no",
        "employer_image": "https://amentotech.com/projects/api_workreap/wp-content/uploads/2019/04/img-01__2_-2.jpg",
        "employer_name": "pozev Jon",
        "level_sign": 1,
        "level_title": "Basic Level",
        "post_date": "April 13, 2019",
        "project_location": "australia",
        "project_rating": "5.00",
        "project_title": "Ecology Professor",
        "review_content": "Excepteur sint occaecat cupidatat non proident, saeunt in culpa qui officia deserunt mollit anim laborum. ",
      },
    ],
    "skills": Array [],
    "total_earnings": "$0.00",
    "user_id": 63,
    "wt_average_rating": "5",
    "wt_total_percentage": "25",
    "wt_total_rating": "1",
  },
]
</code>```

答:
```<code><Text style = {styles.nameStyle}>{this.state.fetchFreelancer[0].name}</Text>
</code>```

Body:
I am getting the data from server successfully i am not under standing how to set that data in a Text tag in React native here is my code please help.

 state = {
    data: []
  };

  componentWillMount() {
    this.fetchFreelancerData();
  }
  fetchFreelancerData = async () => {
    const { params } = this.props.navigation.state;
    const response = await fetch(
      BaseUrl + "listing/get_freelancers?listing_type=single&profile_id=" + params.profile_id
    );
    const json = await response.json();
    console.log(json[0].name);
    this.setState({ fetchFreelancer: json });
  };

Here i am getting the response in json const successfully. i have also console the log as well and terminal is showing the name properly.But i am not understanding how to display the name in the Text tag.

this line  console.log(json[0].name); is getting the name properly.

<View style={styles.viewStyle}>
                        <Text style = {styles.nameStyle}>

                        </Text>
</View>

I have to set the name in the text as shown up here.

this is the response i am getting form server.

[
  Object {
    "_address": "",
    "_awards": Array [],
    "_educations": Array [],
    "_english_level": "",
    "_experience": Array [],
    "_featured_timestamp": "wt-featured",
    "_gender": "male",
    "_is_verified": "no",
    "_latitude": "",
    "_longitude": "",
    "_perhour_rate": "$125.00",
    "_projects": Array [],
    "_tag_line": "The Future Of Memory",
    "badge": Object {
      "badget_color": "#e67e22",
      "badget_url": "https://amentotech.com/projects/api_workreap/wp-content/uploads/2019/03/featured.png",
    },
    "banner_img": "https://amentotech.com/projects/api_workreap/wp-content/themes/workreap/images/frbanner-350x172.jpg",
    "cancelled_jobs": 0,
    "completed_jobs": 1,
    "content": "",
    "favorit": "",
    "freelancer_link": "https://amentotech.com/projects/api_workreap/freelancer/wezalono-alone/",
    "location": Object {
      "_country": "Turkey",
      "flag": "https://amentotech.com/projects/api_workreap/wp-content/uploads/2019/03/img-01-4.png",
    },
    "member_since": "April 13, 2019",
    "name": "wezalono Alone",
    "ongoning_jobs": 0,
    "profile_id": 604,
    "profile_img": "https://amentotech.com/projects/api_workreap/wp-content/uploads/2019/03/29-1-100x100.jpg",
    "rating_filter": "5",
    "reviews": Array [
      Object {
        "_is_verified": "no",
        "employer_image": "https://amentotech.com/projects/api_workreap/wp-content/uploads/2019/04/img-01__2_-2.jpg",
        "employer_name": "pozev Jon",
        "level_sign": 1,
        "level_title": "Basic Level",
        "post_date": "April 13, 2019",
        "project_location": "australia",
        "project_rating": "5.00",
        "project_title": "Ecology Professor",
        "review_content": "Excepteur sint occaecat cupidatat non proident, saeunt in culpa qui officia deserunt mollit anim laborum. ",
      },
    ],
    "skills": Array [],
    "total_earnings": "$0.00",
    "user_id": 63,
    "wt_average_rating": "5",
    "wt_total_percentage": "25",
    "wt_total_rating": "1",
  },
]


问:
Why does std::set.insert() return a non-const iterator, and yet I cannot modify it?
Consider this code example:

```<code>#include <set>
#include <string>

using namespace std;

set<string> string_set;

void foo(const string& a)
{
    pair<set<string>::iterator, bool> insert_result = string_set.insert(a);

    string& val = *(insert_result.first);
    val += " - inserted";
}
</code>```

So, correctness aside, such as not checking for successful insertion and so on, this code looks like it should allow me to amend the string after insertion, but the compiler (VS2010) forbids dereferencing the iterator to a non-const string (we're migrating from VS2005 which waved this through without a warning).

Now, I know this should be forbidden since it may make the string non-unique, and I'm kind of glad it works this way, but in the real world case it's not quite so clear cut as that, as I want to amend a non-mutable data member that doesn't participate in equivalence testing or ordering.

What I want to know is, how does the compiler KNOW I'm not allowed to do this, and how do I know without reference to the documentation (which doesn't mention this anyway)?

Cheers,
Guy

答:
From the standard :

23.3.3

A set is a kind of associative
  container that supports unique keys
  (contains at most one of each key
  value) and provides for fast retrieval
  of the keys themselves. Class set
  supports bidirectional iterators.

This is also from the standard :

    typedef implementation defined
    iterator;
    // See 23.1

The real implementation of set::iterator is a constant iterator in order to keep the requirement to have unique keys. Otherwise you could change the values in set to all the same values.

Body:
Consider this code example:

#include <set>
#include <string>

using namespace std;

set<string> string_set;

void foo(const string& a)
{
    pair<set<string>::iterator, bool> insert_result = string_set.insert(a);

    string& val = *(insert_result.first);
    val += " - inserted";
}

So, correctness aside, such as not checking for successful insertion and so on, this code looks like it should allow me to amend the string after insertion, but the compiler (VS2010) forbids dereferencing the iterator to a non-const string (we're migrating from VS2005 which waved this through without a warning).

Now, I know this should be forbidden since it may make the string non-unique, and I'm kind of glad it works this way, but in the real world case it's not quite so clear cut as that, as I want to amend a non-mutable data member that doesn't participate in equivalence testing or ordering.

What I want to know is, how does the compiler KNOW I'm not allowed to do this, and how do I know without reference to the documentation (which doesn't mention this anyway)?

Cheers,
Guy


问:
deepCss is failing to identify an element inside the shadow root in Protractor
Can not identify button which inside the ShadowRoot in protractor.

I have tried using deepCss as follows,

this.startNowButton = element(by.deepCss('button[class="apply-now"]'));

But I am getting

NoSuchElementError: No element found using locator: By(css selector, * /deep/ button[class="apply-now"])

Is this the correct way to identify the elements inside the ShadowRoot for Protractor? Thanks

my HTML page is similar to as follows,

```<code><div id="modal">
<div class="push-wrap">
   <header id ="site-header">
      <hmy-cms-header class="hydrated">
         #shadow-root (open)
           <header>
               <div class=notification-banner> ... </div>
               <div class="ca">
                  <button class="apply-now">"Apply"<span>now</span>
</code>```

答:
There has been issues with deepcss locator and it doesn't work as expected but there is work around for finding element in shadow DOM. Refer following link for other way of finding shadow dom element.

Protractor - shadow DOM

Body:
Can not identify button which inside the ShadowRoot in protractor.

I have tried using deepCss as follows,

this.startNowButton = element(by.deepCss('button[class="apply-now"]'));

But I am getting

NoSuchElementError: No element found using locator: By(css selector, * /deep/ button[class="apply-now"])

Is this the correct way to identify the elements inside the ShadowRoot for Protractor? Thanks

my HTML page is similar to as follows,

      <hmy-cms-header class="hydrated">
         #shadow-root (open)

 ...

                  <button class="apply-now">"Apply"now


问:
Generate Signed APK: Errors while building APK Android Studio
I am unable to generate Signed APK using minifyEnabled true and shrinkResources true

App Level : build.gradle

```<code>buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.1.0'
    }
}
apply plugin: 'com.android.application'

repositories {
    mavenCentral()
}

android {
    compileSdkVersion 23
    buildToolsVersion '22.0.1'

    defaultConfig {
        applicationId "......."
        minSdkVersion 14
        targetSdkVersion 21
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        debug {
            minifyEnabled true
            shrinkResources true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }

        release {
            minifyEnabled true
            shrinkResources true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }

    configurations {
        compile.exclude group: "org.apache.httpcomponents", module: "httpclient"
    }
}

dependencies {
    compile 'com.android.support:design:23.0.1'
    compile 'com.android.support:cardview-v7:23.0.1'
    compile 'com.android.support:recyclerview-v7:23.0.1'
    compile 'com.android.support:appcompat-v7:23.0.1'
    compile 'com.squareup.picasso:picasso:2.5.2'
    compile 'com.google.apis:google-api-services-youtube:v3-rev149-1.20.0'
    compile 'com.google.http-client:google-http-client-android:1.20.0'
    compile 'com.google.api-client:google-api-client-android:1.20.0'
    compile 'com.google.api-client:google-api-client-gson:1.20.0'
    compile files('libs/YouTubeAndroidPlayerApi.jar')
    compile 'com.github.clans:fab:1.6.2'
}
</code>```

MessageView

```<code>Information:Gradle tasks [:app:assembleRelease]
:app:preBuild UP-TO-DATE
:app:preReleaseBuild UP-TO-DATE
:app:checkReleaseManifest
:app:preDebugBuild UP-TO-DATE
:app:prepareComAndroidSupportAppcompatV72301Library UP-TO-DATE
:app:prepareComAndroidSupportCardviewV72301Library UP-TO-DATE
:app:prepareComAndroidSupportDesign2301Library UP-TO-DATE
:app:prepareComAndroidSupportRecyclerviewV72301Library UP-TO-DATE
:app:prepareComAndroidSupportSupportV42301Library UP-TO-DATE
:app:prepareComGithubClansFab162Library UP-TO-DATE
:app:prepareReleaseDependencies
:app:compileReleaseAidl
:app:compileReleaseRenderscript
:app:generateReleaseBuildConfig
:app:generateReleaseAssets UP-TO-DATE
:app:mergeReleaseAssets
:app:generateReleaseResValues UP-TO-DATE
:app:generateReleaseResources
:app:mergeReleaseResources
:app:processReleaseManifest
:app:processReleaseResources
:app:generateReleaseSources
:app:processReleaseJavaRes UP-TO-DATE
:app:compileReleaseJavaWithJavac
Note: .....YouTubeRecyclerViewFragment.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: ....GetPlaylistAsyncTask.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
:app:compileReleaseNdk UP-TO-DATE
:app:compileReleaseSources
:app:proguardRelease UP-TO-DATE
:app:dexRelease
:app:shrinkReleaseResources
Removed unused resources: Binary resource data reduced from 741KB to 402KB: Removed 45%
Note: If necessary, you can disable resource shrinking by adding
android {
    buildTypes {
        release {
            shrinkResources false
        }
    }
}
:app:validateExternalOverrideSigning
:app:packageRelease FAILED
Error:Execution failed for task ':app:packageRelease'.
> Unable to compute hash of ....\app\build\intermediates\classes-proguard\release\classes.jar
Information:BUILD FAILED
Information:Total time: 7.45 secs
Information:1 error
Information:0 warnings
Information:See complete output in console
</code>```

答:
Clean project and start again generate signed Build/Apk.
its working fine for me.</p>

Body:
I am unable to generate Signed APK using minifyEnabled true and shrinkResources true

App Level : build.gradle

buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.1.0'
    }
}
apply plugin: 'com.android.application'

repositories {
    mavenCentral()
}

android {
    compileSdkVersion 23
    buildToolsVersion '22.0.1'

    defaultConfig {
        applicationId "......."
        minSdkVersion 14
        targetSdkVersion 21
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        debug {
            minifyEnabled true
            shrinkResources true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }

        release {
            minifyEnabled true
            shrinkResources true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }

    configurations {
        compile.exclude group: "org.apache.httpcomponents", module: "httpclient"
    }
}

dependencies {
    compile 'com.android.support:design:23.0.1'
    compile 'com.android.support:cardview-v7:23.0.1'
    compile 'com.android.support:recyclerview-v7:23.0.1'
    compile 'com.android.support:appcompat-v7:23.0.1'
    compile 'com.squareup.picasso:picasso:2.5.2'
    compile 'com.google.apis:google-api-services-youtube:v3-rev149-1.20.0'
    compile 'com.google.http-client:google-http-client-android:1.20.0'
    compile 'com.google.api-client:google-api-client-android:1.20.0'
    compile 'com.google.api-client:google-api-client-gson:1.20.0'
    compile files('libs/YouTubeAndroidPlayerApi.jar')
    compile 'com.github.clans:fab:1.6.2'
}

MessageView

Information:Gradle tasks [:app:assembleRelease]
:app:preBuild UP-TO-DATE
:app:preReleaseBuild UP-TO-DATE
:app:checkReleaseManifest
:app:preDebugBuild UP-TO-DATE
:app:prepareComAndroidSupportAppcompatV72301Library UP-TO-DATE
:app:prepareComAndroidSupportCardviewV72301Library UP-TO-DATE
:app:prepareComAndroidSupportDesign2301Library UP-TO-DATE
:app:prepareComAndroidSupportRecyclerviewV72301Library UP-TO-DATE
:app:prepareComAndroidSupportSupportV42301Library UP-TO-DATE
:app:prepareComGithubClansFab162Library UP-TO-DATE
:app:prepareReleaseDependencies
:app:compileReleaseAidl
:app:compileReleaseRenderscript
:app:generateReleaseBuildConfig
:app:generateReleaseAssets UP-TO-DATE
:app:mergeReleaseAssets
:app:generateReleaseResValues UP-TO-DATE
:app:generateReleaseResources
:app:mergeReleaseResources
:app:processReleaseManifest
:app:processReleaseResources
:app:generateReleaseSources
:app:processReleaseJavaRes UP-TO-DATE
:app:compileReleaseJavaWithJavac
Note: .....YouTubeRecyclerViewFragment.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: ....GetPlaylistAsyncTask.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
:app:compileReleaseNdk UP-TO-DATE
:app:compileReleaseSources
:app:proguardRelease UP-TO-DATE
:app:dexRelease
:app:shrinkReleaseResources
Removed unused resources: Binary resource data reduced from 741KB to 402KB: Removed 45%
Note: If necessary, you can disable resource shrinking by adding
android {
    buildTypes {
        release {
            shrinkResources false
        }
    }
}
:app:validateExternalOverrideSigning
:app:packageRelease FAILED
Error:Execution failed for task ':app:packageRelease'.
> Unable to compute hash of ....\app\build\intermediates\classes-proguard\release\classes.jar
Information:BUILD FAILED
Information:Total time: 7.45 secs
Information:1 error
Information:0 warnings
Information:See complete output in console


问:
How can same name data from same table added its quantity and insert into another table?
In my application has a input table where we can insert same product date wise with product quantity and finally same name product quantity addition and insert into another table called final table.

input table :

```<code> Date     |  Name   | qty
22-05-209  Product1  20
23-05-209  Product2  10
25-05-209  Product1  30
</code>```

final table :

```<code> Name     |   qty
 Product1     50
 Product2     10
</code>```

Using this code..but it doesnt work. its only insert single data , qty doesnt addition

```<code>    $sql=mysqli_query($con, "UPDATE total SET qty = (SELECT qty FROM input WHERE total.name = input.name)");
</code>```

答:
You have to update 'total' table with SUM of values you want like following :

Try this:

```<code>UPDATE total t2
INNER JOIN (
  SELECT name, SUM(qty) as qty_total
  FROM input
  GROUP BY name
) t1 ON t2.name = t1.name
SET t2.qty = t1.qty_total
</code>```

Body:
In my application has a input table where we can insert same product date wise with product quantity and finally same name product quantity addition and insert into another table called final table.

input table :

 Date     |  Name   | qty
22-05-209  Product1  20
23-05-209  Product2  10
25-05-209  Product1  30

final table :

 Name     |   qty
 Product1     50
 Product2     10

Using this code..but it doesnt work. its only insert single data , qty doesnt addition

    $sql=mysqli_query($con, "UPDATE total SET qty = (SELECT qty FROM input WHERE total.name = input.name)");

Body:
You have to update 'total' table with SUM of values you want like following :

Try this:

UPDATE total t2
INNER JOIN (
  SELECT name, SUM(qty) as qty_total
  FROM input
  GROUP BY name
) t1 ON t2.name = t1.name
SET t2.qty = t1.qty_total


问:
Usage of @Injectable class decorator on service provided by @Global module (in official documentation)
Questions about a ConfigService in documentation:
https://docs.nestjs.com/techniques/configuration#service

See the class definition there:

```<code>export class ConfigService { /* ... */ }
</code>```

Why there is no @Injectable decorator? Is there any reason or just a mistake? Has @Injectable decorator any impact on a fact the module that provides ConfigService might be @Global?

答:
there is no @Injectable decorator because this class is used as a custom provider. See follow the usage:

```<code>{
  provide: ConfigService,
  useValue: new ConfigService(`${process.env.NODE_ENV}.env`),
},
</code>```

In that case, your able to specify the token and the value that you want to use, here the configService is instantiate manually and not by the DI system.

When you use the @Injectable decorator you tell to nestjs that this class as to be instantiate by the framework.

I hope this will help you to understand.

Body:
Questions about a ConfigService in documentation:
https://docs.nestjs.com/techniques/configuration#service

See the class definition there:

export class ConfigService { /* ... */ }

Why there is no @Injectable decorator? Is there any reason or just a mistake? Has @Injectable decorator any impact on a fact the module that provides ConfigService might be @Global?

Body:
there is no @Injectable decorator because this class is used as a custom provider. See follow the usage:

{
  provide: ConfigService,
  useValue: new ConfigService(`${process.env.NODE_ENV}.env`),
},

In that case, your able to specify the token and the value that you want to use, here the configService is instantiate manually and not by the DI system.

When you use the @Injectable decorator you tell to nestjs that this class as to be instantiate by the framework.

I hope this will help you to understand.


问:
Angular Renderer2 can't add class
addClass method of Renderer doesn't work in case element has class with binding

Some HTML

```

<p>Inside <code>addClassDir</code></p>

<pre class="lang-js prettyprint-override"><code>ngOnInit() {
    this.renderer.addClass(this.elementRef.nativeElement, 'new-class');
}
</code>```

I know that class="my-class-{{smth}}" is a not Angular way, but I don't know how people use my directive. It should work anyway, but it doesn't. What is the most correct way to do it?

答:
You don't need the Renderer to add a class. Take advantage of NgClass syntax and the HostBinding directive.

Stackblitz Demo

```<code>export class MyDirective {

  @HostBinding('class.my-directive-class') customClass = true;

  constructor() { }

}
</code>```

Title: Angular Renderer2 can't add class

Body:
addClass method of Renderer doesn't work in case element has class with binding

Some HTML

Inside addClassDir

ngOnInit() {
    this.renderer.addClass(this.elementRef.nativeElement, 'new-class');
}

I know that class="my-class-{{smth}}" is a not Angular way, but I don't know how people use my directive. It should work anyway, but it doesn't. What is the most correct way to do it?

Body:
You don't need the Renderer to add a class. Take advantage of NgClass syntax and the HostBinding directive.

Stackblitz Demo

export class MyDirective {

  @HostBinding('class.my-directive-class') customClass = true;

  constructor() { }

}


问:
Form gives error if I don't fill all the details in Angular reactive forms
I am using a reactive form to insert contact details.
Some of the fields are mandatory while others are optional.
The issue I have is if the user doesn't fill optional details fields and click on submit button I get following error:

```<code>ERROR TypeError: "this.contactForm.value.contactLastVerifiedDate is null"
</code>```

HTML Code:

 ngOnInit() {
    this.contactForm = this.formBuilder.group({
      contactType: ['', Validators.required],
      contactSubType: ['', Validators.required],
      referenceNumber: ['', Validators.required],
      contactStartDate: ['', Validators.required],
      contactLastVerifiedDate: ['']
    });
  }
  onSubmit() {
   if (this.contactForm.valid) {
      const newContact = {
        contactType: this.contactForm.value.contactType,
        contactSubType: this.contactForm.value.contactSubType,
        referenceNumber: this.contactForm.value.referenceNumber,
        startDate: this.parseDate(this.contactForm.value.contactStartDate.toString()),
        lastVerifiedDate: this.parseDate(this.contactForm.value.contactLastVerifiedDate.toString()),
    }```
<pre class="snippet-code-html lang-html prettyprint-override"><code><form [formGroup]="contactForm" (ngSubmit)="onSubmit()">
  <div class="form-group">
    <label>Contact Type</label>
    <mat-select
      formControlName="contactType"
      class="form-control"
      [ngClass]="{ 'is-invalid': submitted && contactFormf.contactType.errors }"
      required
    >
      <mat-option *ngFor="let obj of contactTypes" [value]="obj.value"> {{ obj.viewValue }}</mat-option>
    </mat-select>
    <div *ngIf="submitted && contactFormf.contactType.errors" class="invalid-feedback">
      <div *ngIf="submitted && contactFormf.contactType.errors.required">Contact Type is required</div>
    </div>
  </div>

  <div class="form-group">
    <label>Contact Sub Type</label>
    <mat-select
      formControlName="contactSubType"
      class="form-control"
      [ngClass]="{ 'is-invalid': submitted && contactFormf.contactType.errors }"
      required
    >
      <mat-option *ngFor="let obj of contactSubTypes" [value]="obj.value"> {{ obj.viewValue }}</mat-option>
    </mat-select>
    <div *ngIf="submitted && contactFormf.contactSubType.errors" class="invalid-feedback">
      <div *ngIf="submitted && contactFormf.contactSubType.errors.required">Name Type is required</div>
    </div>
  </div>
  <div class="form-group">
    <label>Reference Number</label>
    <input
      type="text"
      formControlName="referenceNumber"
      class="form-control"
      [ngClass]="{ 'is-invalid': submitted && contactFormf.referenceNumber.errors }"
      required
    />
    <div *ngIf="submitted && contactFormf.referenceNumber.errors" class="invalid-feedback">
      <div *ngIf="submitted && contactFormf.referenceNumber.errors.required">Reference Number is required</div>
    </div>
  </div>

  <div class="form-group">
    <input
      matInput
      [matDatepicker]="startDate"
      formControlName="contactStartDate"
      placeholder="Choose Start date"
      [ngClass]="{ 'is-invalid': submitted && contactFormf.contactStartDate.errors }"
      required
    />
    <mat-datepicker-toggle matSuffix [for]="startDate"></mat-datepicker-toggle>
    <mat-datepicker #startDate></mat-datepicker>
    <div *ngIf="submitted && contactFormf.contactStartDate.errors" class="invalid-feedback">
      <div *ngIf="submitted && contactFormf.contactStartDate.errors.required">Contact Start Date is required</div>
    </div>
  </div>

  <div class="form-group">
    <input matInput [matDatepicker]="lastVerifiedDate" formControlName="contactLastVerifiedDate" placeholder="Choose Last Verified date" />
    <mat-datepicker-toggle matSuffix [for]="lastVerifiedDate"></mat-datepicker-toggle>
    <mat-datepicker #lastVerifiedDate></mat-datepicker>
  </div>

  <div class="form-group">
    <button>Save</button>
  </div>
</form></code>```

How can I make it Optional for user to submit form without entering Optional Details.Currently if user doesn't enter Optional details form gives error and if user enters details then it is successfully submitted

答:
you should check if there is a valid value before you parseDate... your function would be:</p>

```<code> onSubmit() {
   if (this.contactForm.valid) {
      const newContact = {
        contactType: this.contactForm.value.contactType,
        contactSubType: this.contactForm.value.contactSubType,
        referenceNumber: this.contactForm.value.referenceNumber,
        startDate: this.parseDate(this.contactForm.value.contactStartDate.toString()),
    lastVerifiedDate: (this.contactForm.value.contactLastVerifiedDate != '' && this.contactForm.value.contactLastVerifiedDate) ? this.parseDate(this.contactForm.value.contactLastVerifiedDate.toString()) : '',
    }
}
</code>```

Body:
I am using a reactive form to insert contact details.
Some of the fields are mandatory while others are optional.
The issue I have is if the user doesn't fill optional details fields and click on submit button I get following error:

ERROR TypeError: "this.contactForm.value.contactLastVerifiedDate is null"

HTML Code:

 ngOnInit() {
    this.contactForm = this.formBuilder.group({
      contactType: ['', Validators.required],
      contactSubType: ['', Validators.required],
      referenceNumber: ['', Validators.required],
      contactStartDate: ['', Validators.required],
      contactLastVerifiedDate: ['']
    });
  }
  onSubmit() {
   if (this.contactForm.valid) {
      const newContact = {
        contactType: this.contactForm.value.contactType,
        contactSubType: this.contactForm.value.contactSubType,
        referenceNumber: this.contactForm.value.referenceNumber,
        startDate: this.parseDate(this.contactForm.value.contactStartDate.toString()),
        lastVerifiedDate: this.parseDate(this.contactForm.value.contactLastVerifiedDate.toString()),
    }

<form [formGroup]="contactForm" (ngSubmit)="onSubmit()">

    Contact Type
    <mat-select
      formControlName="contactType"
      class="form-control"
      [ngClass]="{ 'is-invalid': submitted && contactFormf.contactType.errors }"
      required
    >
      <mat-option *ngFor="let obj of contactTypes" [value]="obj.value"> {{ obj.viewValue }}</mat-option>
    </mat-select>

Contact Type is required

    Contact Sub Type
    <mat-select
      formControlName="contactSubType"
      class="form-control"
      [ngClass]="{ 'is-invalid': submitted && contactFormf.contactType.errors }"
      required
    >
      <mat-option *ngFor="let obj of contactSubTypes" [value]="obj.value"> {{ obj.viewValue }}</mat-option>
    </mat-select>

Name Type is required

    Reference Number
    <input
      type="text"
      formControlName="referenceNumber"
      class="form-control"
      [ngClass]="{ 'is-invalid': submitted && contactFormf.referenceNumber.errors }"
      required
    />

Reference Number is required

    <input
      matInput
      [matDatepicker]="startDate"
      formControlName="contactStartDate"
      placeholder="Choose Start date"
      [ngClass]="{ 'is-invalid': submitted && contactFormf.contactStartDate.errors }"
      required
    />
    <mat-datepicker-toggle matSuffix [for]="startDate"></mat-datepicker-toggle>
    <mat-datepicker #startDate></mat-datepicker>

Contact Start Date is required

    <input matInput [matDatepicker]="lastVerifiedDate" formControlName="contactLastVerifiedDate" placeholder="Choose Last Verified date" />
    <mat-datepicker-toggle matSuffix [for]="lastVerifiedDate"></mat-datepicker-toggle>
    <mat-datepicker #lastVerifiedDate></mat-datepicker>

    <button>Save</button>

</form>

How can I make it Optional for user to submit form without entering Optional Details.Currently if user doesn't enter Optional details form gives error and if user enters details then it is successfully submitted

Body:
you should check if there is a valid value before you parseDate... your function would be:

 onSubmit() {
   if (this.contactForm.valid) {
      const newContact = {
        contactType: this.contactForm.value.contactType,
        contactSubType: this.contactForm.value.contactSubType,
        referenceNumber: this.contactForm.value.referenceNumber,
        startDate: this.parseDate(this.contactForm.value.contactStartDate.toString()),
    lastVerifiedDate: (this.contactForm.value.contactLastVerifiedDate != '' && this.contactForm.value.contactLastVerifiedDate) ? this.parseDate(this.contactForm.value.contactLastVerifiedDate.toString()) : '',
    }
}


问:
Hive external table delimited by commas, but comma present in data
I have some data coming in from an external source of the format:

```<code>user_id, user_name, project_name, position
"111", "Tom Petty", "Heartbreakers", "Vocals"
"222", "Ringo Starr", "Beatles, The", "Drummer"
"333", "Tom Brady", "Patriots", "QB"
</code>```

And I create my external table thusly:

```<code>CREATE EXTERNAL TABLE tab1 (
USER_ID String,
USER_NAME String,
PROJECT_NAME String,
POSITION String
)
ROW FORMAT DELIMITED
FIELDS TERMINATED BY ','
STORED AS TEXTFILE
LOCATION '/user/blah/foo'
</code>```

The problem occurs when data in some of the columns have embedded commas in them, Beatles, The for instance. This results in Hive putting the word The into the next column (position) and dropping the data in the last column.

All the incoming data fields are wrapped in double quotes but they are comma delimited even though they may have commas in them. Unfortunately having the sender clean the data is not an option.

How can I go about creating this table?

答:
try this</p>

```<code>ROW FORMAT SERDE 'org.apache.hadoop.hive.serde2.OpenCSVSerde'
WITH SERDEPROPERTIES (
   "separatorChar" = "\t",
   "quoteChar"     = "\""
)
</code>```

Body:
I have some data coming in from an external source of the format:

user_id, user_name, project_name, position
"111", "Tom Petty", "Heartbreakers", "Vocals"
"222", "Ringo Starr", "Beatles, The", "Drummer"
"333", "Tom Brady", "Patriots", "QB"

And I create my external table thusly:

CREATE EXTERNAL TABLE tab1 (
USER_ID String,
USER_NAME String,
PROJECT_NAME String,
POSITION String
)
ROW FORMAT DELIMITED
FIELDS TERMINATED BY ','
STORED AS TEXTFILE
LOCATION '/user/blah/foo'

The problem occurs when data in some of the columns have embedded commas in them, Beatles, The for instance. This results in Hive putting the word The into the next column (position) and dropping the data in the last column.

All the incoming data fields are wrapped in double quotes but they are comma delimited even though they may have commas in them. Unfortunately having the sender clean the data is not an option.

How can I go about creating this table?

Body:
try this

ROW FORMAT SERDE 'org.apache.hadoop.hive.serde2.OpenCSVSerde'
WITH SERDEPROPERTIES (
   "separatorChar" = "\t",
   "quoteChar"     = "\""
)