- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我昨天迁移到Android Studio 4.0,因为我想开始使用Jetpack Compose。升级Gradle和其他一些东西以使构建实际可用后,我能够成功构建(Cmd F9)项目(没有错误)。
但是,当我尝试运行(Ctrl R)项目时,它会在构建过程中使用所有绿色成功指示符运行(加上一些有关函数中未使用变量的警告),然后出错。是什么原因造成的?
除了在我的build.gradle中添加依赖项之外,我不知道如何使用Gradle进行任何操作,或者不遵循Google之类的网站的直接指示,即必须升级AS才能使用Jetpack Compose。因此,我不知道如何在构建过程中放置断点以查看正在发生的事情(搜索表明这实际上是不可能的)或如何找到问题所在。似乎Gradle期望有某种东西是JSON {}
,但是却找到了JSON []
。但是错误肯定不会暗示它可能是什么。
> Task :app:assembleDebug
FAILURE: Build failed with an exception.
* What went wrong:
java.lang.IllegalStateException: Expected BEGIN_OBJECT but was BEGIN_ARRAY at line 1 column 2 path $
> Expected BEGIN_OBJECT but was BEGIN_ARRAY at line 1 column 2 path $
* Try:
Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Exception is:
com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Expected BEGIN_OBJECT but was BEGIN_ARRAY at line 1 column 2 path $
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:226)
at com.google.gson.Gson.fromJson(Gson.java:927)
at com.google.gson.Gson.fromJson(Gson.java:865)
at com.android.build.api.variant.impl.BuiltArtifactsLoaderImpl$Companion.loadFromFile(BuiltArtifactsLoaderImpl.kt:68)
at com.android.build.gradle.internal.ide.EarlySyncBuildOutput$Companion.loadVersionTwoFile(EarlySyncBuildOutput.kt:109)
at com.android.build.gradle.internal.ide.EarlySyncBuildOutput$Companion.load(EarlySyncBuildOutput.kt:70)
at com.android.build.gradle.internal.ide.EarlySyncBuildOutput.load(EarlySyncBuildOutput.kt)
at com.android.build.gradle.internal.ide.BuildOutputsSupplier.lambda$get$2(BuildOutputsSupplier.java:59)
at com.google.common.collect.ImmutableList.forEach(ImmutableList.java:405)
at com.android.build.gradle.internal.ide.BuildOutputsSupplier.get(BuildOutputsSupplier.java:53)
at com.android.build.gradle.internal.ide.BuildOutputsSupplier.get(BuildOutputsSupplier.java:34)
at com.android.build.gradle.internal.ide.ModelBuilder.lambda$buildMinimalisticModel$0(ModelBuilder.java:288)
at com.android.build.gradle.internal.ide.ModelBuilder.buildMinimalisticModel(ModelBuilder.java:297)
at com.android.build.gradle.internal.ide.ModelBuilder.buildNonParameterizedModels(ModelBuilder.java:238)
at com.android.build.gradle.internal.ide.ModelBuilder.buildAll(ModelBuilder.java:208)
at com.android.build.gradle.internal.AppModelBuilder.buildAll(AppModelBuilder.kt:65)
at org.gradle.tooling.provider.model.internal.DefaultToolingModelBuilderRegistry$BuildOperationWrappingToolingModelBuilder$1$1.create(DefaultToolingModelBuilderRegistry.java:104)
at org.gradle.api.internal.project.DefaultProjectStateRegistry.withLenientState(DefaultProjectStateRegistry.java:134)
at org.gradle.tooling.provider.model.internal.DefaultToolingModelBuilderRegistry$BuildOperationWrappingToolingModelBuilder$1.call(DefaultToolingModelBuilderRegistry.java:100)
at org.gradle.internal.operations.DefaultBuildOperationExecutor$CallableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:416)
at org.gradle.internal.operations.DefaultBuildOperationExecutor$CallableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:406)
at org.gradle.internal.operations.DefaultBuildOperationExecutor$1.execute(DefaultBuildOperationExecutor.java:165)
at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:250)
at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:158)
at org.gradle.internal.operations.DefaultBuildOperationExecutor.call(DefaultBuildOperationExecutor.java:102)
at org.gradle.internal.operations.DelegatingBuildOperationExecutor.call(DelegatingBuildOperationExecutor.java:36)
at org.gradle.tooling.provider.model.internal.DefaultToolingModelBuilderRegistry$BuildOperationWrappingToolingModelBuilder.buildAll(DefaultToolingModelBuilderRegistry.java:97)
at org.gradle.tooling.internal.provider.runner.DefaultBuildController.getModel(DefaultBuildController.java:82)
at org.gradle.tooling.internal.consumer.connection.InternalBuildActionAdapter$2.getModel(InternalBuildActionAdapter.java:74)
at org.gradle.tooling.internal.consumer.connection.BuildControllerAdapter.getModel(BuildControllerAdapter.java:62)
at org.gradle.tooling.internal.consumer.connection.AbstractBuildController.findModel(AbstractBuildController.java:57)
at org.gradle.tooling.internal.consumer.connection.AbstractBuildController.findModel(AbstractBuildController.java:44)
at com.android.tools.idea.gradle.run.OutputBuildAction$PostBuildModuleModels.findAndAddModel(OutputBuildAction.java:136)
at com.android.tools.idea.gradle.run.OutputBuildAction$PostBuildModuleModels.populate(OutputBuildAction.java:116)
at com.android.tools.idea.gradle.run.OutputBuildAction$PostBuildModuleModels.access$200(OutputBuildAction.java:106)
at com.android.tools.idea.gradle.run.OutputBuildAction$PostBuildProjectModels.populateModule(OutputBuildAction.java:95)
at com.android.tools.idea.gradle.run.OutputBuildAction$PostBuildProjectModels.populate(OutputBuildAction.java:80)
at com.android.tools.idea.gradle.run.OutputBuildAction.execute(OutputBuildAction.java:64)
at com.android.tools.idea.gradle.run.OutputBuildAction.execute(OutputBuildAction.java:43)
at org.gradle.tooling.internal.consumer.connection.InternalBuildActionAdapter.execute(InternalBuildActionAdapter.java:77)
at org.gradle.tooling.internal.provider.runner.ClientProvidedBuildActionRunner$ResultBuildingListener.buildResult(ClientProvidedBuildActionRunner.java:114)
at org.gradle.tooling.internal.provider.runner.ClientProvidedBuildActionRunner$ResultBuildingListener.buildFinished(ClientProvidedBuildActionRunner.java:106)
at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:36)
at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
at org.gradle.internal.event.DefaultListenerManager$ListenerDetails.dispatch(DefaultListenerManager.java:382)
at org.gradle.internal.event.DefaultListenerManager$ListenerDetails.dispatch(DefaultListenerManager.java:364)
at org.gradle.internal.event.AbstractBroadcastDispatch.dispatch(AbstractBroadcastDispatch.java:58)
at org.gradle.internal.event.DefaultListenerManager$EventBroadcast$ListenerDispatch.dispatch(DefaultListenerManager.java:352)
at org.gradle.internal.event.DefaultListenerManager$EventBroadcast$ListenerDispatch.dispatch(DefaultListenerManager.java:339)
at org.gradle.internal.event.AbstractBroadcastDispatch.dispatch(AbstractBroadcastDispatch.java:42)
at org.gradle.internal.event.BroadcastDispatch$SingletonDispatch.dispatch(BroadcastDispatch.java:231)
at org.gradle.internal.event.BroadcastDispatch$SingletonDispatch.dispatch(BroadcastDispatch.java:150)
at org.gradle.internal.event.AbstractBroadcastDispatch.dispatch(AbstractBroadcastDispatch.java:58)
at org.gradle.internal.event.BroadcastDispatch$CompositeDispatch.dispatch(BroadcastDispatch.java:325)
at org.gradle.internal.event.BroadcastDispatch$CompositeDispatch.dispatch(BroadcastDispatch.java:235)
at org.gradle.internal.event.ListenerBroadcast.dispatch(ListenerBroadcast.java:141)
at org.gradle.internal.event.ListenerBroadcast.dispatch(ListenerBroadcast.java:37)
at org.gradle.internal.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:94)
at com.sun.proxy.$Proxy15.buildFinished(Unknown Source)
at org.gradle.initialization.DefaultGradleLauncher.finishBuild(DefaultGradleLauncher.java:174)
at org.gradle.initialization.DefaultGradleLauncher.finishBuild(DefaultGradleLauncher.java:117)
at org.gradle.internal.invocation.GradleBuildController$3.create(GradleBuildController.java:86)
at org.gradle.internal.invocation.GradleBuildController$3.create(GradleBuildController.java:78)
at org.gradle.internal.work.DefaultWorkerLeaseService.withLocks(DefaultWorkerLeaseService.java:189)
at org.gradle.internal.work.StopShieldingWorkerLeaseService.withLocks(StopShieldingWorkerLeaseService.java:40)
at org.gradle.internal.invocation.GradleBuildController.doBuild(GradleBuildController.java:78)
at org.gradle.internal.invocation.GradleBuildController.run(GradleBuildController.java:57)
at org.gradle.tooling.internal.provider.runner.ClientProvidedBuildActionRunner.run(ClientProvidedBuildActionRunner.java:55)
at org.gradle.launcher.exec.ChainingBuildActionRunner.run(ChainingBuildActionRunner.java:35)
at org.gradle.launcher.exec.ChainingBuildActionRunner.run(ChainingBuildActionRunner.java:35)
at org.gradle.launcher.exec.BuildOutcomeReportingBuildActionRunner.run(BuildOutcomeReportingBuildActionRunner.java:63)
at org.gradle.tooling.internal.provider.ValidatingBuildActionRunner.run(ValidatingBuildActionRunner.java:32)
at org.gradle.launcher.exec.BuildCompletionNotifyingBuildActionRunner.run(BuildCompletionNotifyingBuildActionRunner.java:39)
at org.gradle.launcher.exec.RunAsBuildOperationBuildActionRunner$3.call(RunAsBuildOperationBuildActionRunner.java:51)
at org.gradle.launcher.exec.RunAsBuildOperationBuildActionRunner$3.call(RunAsBuildOperationBuildActionRunner.java:45)
at org.gradle.internal.operations.DefaultBuildOperationExecutor$CallableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:416)
at org.gradle.internal.operations.DefaultBuildOperationExecutor$CallableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:406)
at org.gradle.internal.operations.DefaultBuildOperationExecutor$1.execute(DefaultBuildOperationExecutor.java:165)
at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:250)
at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:158)
at org.gradle.internal.operations.DefaultBuildOperationExecutor.call(DefaultBuildOperationExecutor.java:102)
at org.gradle.internal.operations.DelegatingBuildOperationExecutor.call(DelegatingBuildOperationExecutor.java:36)
at org.gradle.launcher.exec.RunAsBuildOperationBuildActionRunner.run(RunAsBuildOperationBuildActionRunner.java:45)
at org.gradle.launcher.exec.InProcessBuildActionExecuter$1.transform(InProcessBuildActionExecuter.java:50)
at org.gradle.launcher.exec.InProcessBuildActionExecuter$1.transform(InProcessBuildActionExecuter.java:47)
at org.gradle.composite.internal.DefaultRootBuildState.run(DefaultRootBuildState.java:80)
at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:47)
at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:31)
at org.gradle.launcher.exec.BuildTreeScopeBuildActionExecuter.execute(BuildTreeScopeBuildActionExecuter.java:42)
at org.gradle.launcher.exec.BuildTreeScopeBuildActionExecuter.execute(BuildTreeScopeBuildActionExecuter.java:28)
at org.gradle.tooling.internal.provider.ContinuousBuildActionExecuter.execute(ContinuousBuildActionExecuter.java:78)
at org.gradle.tooling.internal.provider.ContinuousBuildActionExecuter.execute(ContinuousBuildActionExecuter.java:52)
at org.gradle.tooling.internal.provider.SubscribableBuildActionExecuter.execute(SubscribableBuildActionExecuter.java:60)
at org.gradle.tooling.internal.provider.SubscribableBuildActionExecuter.execute(SubscribableBuildActionExecuter.java:38)
at org.gradle.tooling.internal.provider.SessionScopeBuildActionExecuter.execute(SessionScopeBuildActionExecuter.java:68)
at org.gradle.tooling.internal.provider.SessionScopeBuildActionExecuter.execute(SessionScopeBuildActionExecuter.java:38)
at org.gradle.tooling.internal.provider.GradleThreadBuildActionExecuter.execute(GradleThreadBuildActionExecuter.java:37)
at org.gradle.tooling.internal.provider.GradleThreadBuildActionExecuter.execute(GradleThreadBuildActionExecuter.java:26)
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:60)
at org.gradle.tooling.internal.provider.StartParamsValidatingActionExecuter.execute(StartParamsValidatingActionExecuter.java:32)
at org.gradle.tooling.internal.provider.SessionFailureReportingActionExecuter.execute(SessionFailureReportingActionExecuter.java:55)
at org.gradle.tooling.internal.provider.SessionFailureReportingActionExecuter.execute(SessionFailureReportingActionExecuter.java:41)
at org.gradle.tooling.internal.provider.SetupLoggingActionExecuter.execute(SetupLoggingActionExecuter.java:48)
at org.gradle.tooling.internal.provider.SetupLoggingActionExecuter.execute(SetupLoggingActionExecuter.java:32)
at org.gradle.launcher.daemon.server.exec.ExecuteBuild.doBuild(ExecuteBuild.java:68)
at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:37)
at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:104)
at org.gradle.launcher.daemon.server.exec.WatchForDisconnection.execute(WatchForDisconnection.java:39)
at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:104)
at org.gradle.launcher.daemon.server.exec.ResetDeprecationLogger.execute(ResetDeprecationLogger.java:27)
at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:104)
at org.gradle.launcher.daemon.server.exec.RequestStopIfSingleUsedDaemon.execute(RequestStopIfSingleUsedDaemon.java:35)
at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:104)
at org.gradle.launcher.daemon.server.exec.ForwardClientInput$2.create(ForwardClientInput.java:78)
at org.gradle.launcher.daemon.server.exec.ForwardClientInput$2.create(ForwardClientInput.java:75)
at org.gradle.util.Swapper.swap(Swapper.java:38)
at org.gradle.launcher.daemon.server.exec.ForwardClientInput.execute(ForwardClientInput.java:75)
at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:104)
at org.gradle.launcher.daemon.server.exec.LogAndCheckHealth.execute(LogAndCheckHealth.java:55)
at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:104)
at org.gradle.launcher.daemon.server.exec.LogToClient.doBuild(LogToClient.java:63)
at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:37)
at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:104)
at org.gradle.launcher.daemon.server.exec.EstablishBuildEnvironment.doBuild(EstablishBuildEnvironment.java:82)
at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:37)
at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:104)
at org.gradle.launcher.daemon.server.exec.StartBuildOrRespondWithBusy$1.run(StartBuildOrRespondWithBusy.java:52)
at org.gradle.launcher.daemon.server.DaemonStateCoordinator$1.run(DaemonStateCoordinator.java:297)
at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:64)
at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:48)
at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:56)
Caused by: java.lang.IllegalStateException: Expected BEGIN_OBJECT but was BEGIN_ARRAY at line 1 column 2 path $
at com.google.gson.stream.JsonReader.beginObject(JsonReader.java:385)
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:215)
... 132 more
* Get more help at https://help.gradle.org
BUILD FAILED in 34s
32 actionable tasks: 8 executed, 24 up-to-date
最佳答案
使用Android Studio的预发布版本可能会不时引起问题,特别是对于现有项目。总体而言,我尝试仅将预发布Studio版本与在这些版本中创建的项目一起使用,而不与现有项目一起使用。
但是,基于this issue,清理和重建项目应该可以解决此问题...并且基于your comment,显然可以。
我的解释:现有项目构建文件中的某些内容(例如.idea/
中)具有指向JSON文档的URL,并且该文档的结构已更改。清理项目会将其切换到新的URL,指向结构与预发行版Android Gradle Plugin期望匹配的文档。
关于android - 可以构建Android Project(Cmd F9),但由于GSON BEGIN_OBJECT BEGIN_ARRAY问题而导致运行(Ctrl R)错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60252509/
我在改造方面遇到问题。 CryptoCompareClient.java public interface CryptoCompareClient { @GET("/data/pricemulti")
我正在尝试将 errorBody 转换为我的 RegistrationResponse 但它总是抛出一个 Expected BEGIN_ARRAY but was BEGIN_OBJECT 注册响应
我是初学者,我正在我的应用中使用 Retrofit 2。我有这个 JSON。 (我尝试了很多解决方案,但对我没有任何帮助)。感谢您的帮助 我遇到的错误:应为 BEGIN_ARRAY 但在第 1 行第
我是java初学者,我需要一些帮助,我看过很多关于的帖子,但没有解决他们的问题 我有来自 url 的 json 对象,就像这样 { 'history':[{ 'id':
我正在使用 Retrofit 2 发送 HTTP 请求,我已经定期完成了所有操作,但是,情况“不标准”。我有一个问题,响应类中要接收的对象之一曾经作为对象发送,而另一个作为列表发送。所以我不知道是在响
我从 .NET WS 获取 JSON 响应(项目列表),因此我想在 Android 应用程序中转换为列表。但是当使用 GSON 库时,出现以下异常: com.google.gson.JsonSynta
如何使用 Retrofit 解析此内容?我收到错误 BEGIN_OBJECT but was BEGIN_ARRAY Json 如下,它包含一个结果数组对象,该对象有一个为 null 的数组对象和信息
我正在努力通过改造和 RXAndroid 从 Android 与我的 REST API 进行交互,但遇到了问题。 当我向“api/users/{id}/{id}/classes”发送 GET 请求时,
我在使用 retrofit 调用进行解析时遇到问题。这不是重复的问题。我尝试了太多的谷歌搜索也尝试了很多解决方案,但它在我的情况下不起作用。所以请不要对这个问题投反对票。 错误 05-04 04:18
我今天才开始使用 Retrofit 库。我在获取一些 json 数据时遇到问题。 我尝试获取的 JSON 数据如下所示: [ {"id":"1","genre_id":"27","name":"
我正在尝试解析 the JSON response from this link我得到了这个异常(exception): Expected BEGIN_ARRAY but was BEGIN_OBJE
我正在努力学习 MVP。我在教程和 YouTube 视频的帮助下编写了代码。首先,我使用了 Json2Class 插件。之后,我创建了一个 Json-Server,只是为了从 REST API 获取一
在api响应中有时可以是数组,有时可以是字符串。 这里的细节是Array { "ts": "2015-06-16 11:28:33","success": true,"error": false,
您好,我是 Retrofit 库的新手,我在解析某些 json 时遇到问题。我已经查看了 Stackoverflow 上的其他一些解决方案,但对我的问题不太满意。我试图让一个简单的网络服务工作。任何建
这是我的 JSON 数据: [ { "page": 0, "threads": [ { "
我对 JSON 解析相当陌生,我正在使用 Square 的 Retrofit 库并遇到了这个问题。 我正在尝试解析这个 JSON 响应: [ { "id": 3,
我从服务中得到一个 json 结果,如下所示: { "result": { "totalCount": 15, "resultCount": 2,
我在 gson 反序列化方面遇到问题。传入的 json 看起来像这样 {"roles":{"name":"bla""perm": "bla"}} 或者当有更多可用角色时,它看起来像这样 {"roles
首先,我知道其他一些用户之前已经问过类似的问题,所以您可能认为这是一个重复的问题,但事实并非如此。 我想创建一个模型类来解析 GoogleMaps-Direction API 响应从 JSON 格式到
我目前正在使用 Retrofit 来调用此 URL 。我正在努力理解如何基于 JSON 映射 POJO。这是我的代码: final ApiInterface apiInterface = retr
我是一名优秀的程序员,十分优秀!