Android Studio 3.3以降を使用するJava-kotlinハイブリッドでは、無効なタイプコード:68エラーメッセージが表示されます。gradle5.1以降を使用すると、追加で「Kotlinモジュールが含まれているため、新しいGradle Syncはサポートされていません」というメッセージ
Android studio 3.3で再現する方法:
1)AndroidプロジェクトをJavaに空のアクティビティで作成します
2)kotlinクラスファイルを作成する
3)[kotlinの構成]ボタンをクリックして、kotlinプラグインとライブラリをプロジェクトに追加します
4)Gradleを同期する
以前のプロジェクトは以前のAndroid Studio安定版リリース(3.2.1))で正常に動作していました
完全なスタックトレース:
org.gradle.tooling.GradleConnectionException: Could not run build action using Gradle distribution 'https://services.gradle.org/distributions/gradle-5.1.1-all.Zip'.
at org.gradle.tooling.internal.consumer.ExceptionTransformer.transform(ExceptionTransformer.Java:55)
at org.gradle.tooling.internal.consumer.ExceptionTransformer.transform(ExceptionTransformer.Java:29)
at org.gradle.tooling.internal.consumer.ResultHandlerAdapter.onFailure(ResultHandlerAdapter.Java:41)
at org.gradle.tooling.internal.consumer.async.DefaultAsyncConsumerActionExecutor$1$1.run(DefaultAsyncConsumerActionExecutor.Java:57)
at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.Java:63)
at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.Java:46)
at Java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.Java:1142)
at Java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.Java:617)
at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.Java:55)
at Java.lang.Thread.run(Thread.Java:745)
at org.gradle.tooling.internal.consumer.BlockingResultHandler.getResult(BlockingResultHandler.Java:46)
at org.gradle.tooling.internal.consumer.DefaultBuildActionExecuter.run(DefaultBuildActionExecuter.Java:65)
at com.Android.tools.idea.gradle.project.sync.ng.SyncExecutor.doFetchModels(SyncExecutor.Java:255)
at com.Android.tools.idea.gradle.project.sync.ng.SyncExecutor.executeFullSync(SyncExecutor.Java:239)
at com.Android.tools.idea.gradle.project.sync.ng.SyncExecutor.syncProject(SyncExecutor.Java:197)
at com.Android.tools.idea.gradle.project.sync.ng.SyncExecutor.lambda$syncProject$1(SyncExecutor.Java:134)
at org.jetbrains.plugins.gradle.service.execution.GradleExecutionHelper.execute(GradleExecutionHelper.Java:209)
at com.Android.tools.idea.gradle.project.sync.ng.SyncExecutor.syncProject(SyncExecutor.Java:139)
at com.Android.tools.idea.gradle.project.sync.ng.NewGradleSync.sync(NewGradleSync.Java:185)
at com.Android.tools.idea.gradle.project.sync.ng.NewGradleSync.access$000(NewGradleSync.Java:59)
at com.Android.tools.idea.gradle.project.sync.ng.NewGradleSync$2.run(NewGradleSync.Java:151)
at com.intellij.openapi.progress.impl.CoreProgressManager$TaskRunnable.run(CoreProgressManager.Java:736)
at com.intellij.openapi.progress.impl.CoreProgressManager.lambda$runProcess$1(CoreProgressManager.Java:157)
at com.intellij.openapi.progress.impl.CoreProgressManager.registerIndicatorAndRun(CoreProgressManager.Java:580)
at com.intellij.openapi.progress.impl.CoreProgressManager.executeProcessUnderProgress(CoreProgressManager.Java:525)
at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.Java:85)
at com.intellij.openapi.progress.impl.CoreProgressManager.runProcess(CoreProgressManager.Java:144)
at com.intellij.openapi.progress.impl.CoreProgressManager$4.run(CoreProgressManager.Java:395)
at com.intellij.openapi.application.impl.ApplicationImpl$1.run(ApplicationImpl.Java:314)
at Java.util.concurrent.Executors$RunnableAdapter.call(Executors.Java:511)
at Java.util.concurrent.FutureTask.run(FutureTask.Java:266)
at Java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.Java:1142)
at Java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.Java:617)
at Java.lang.Thread.run(Thread.Java:745)
Caused by: org.gradle.api.UncheckedIOException: Java.io.StreamCorruptedException: invalid type code: 68
at org.gradle.internal.UncheckedException.throwAsUncheckedException(UncheckedException.Java:61)
at org.gradle.internal.UncheckedException.throwAsUncheckedException(UncheckedException.Java:41)
at org.gradle.tooling.internal.provider.serialization.PayloadSerializer.deserialize(PayloadSerializer.Java:76)
at org.gradle.tooling.internal.provider.ProviderConnection.throwFailure(ProviderConnection.Java:205)
at org.gradle.tooling.internal.provider.ProviderConnection.run(ProviderConnection.Java:193)
at org.gradle.tooling.internal.provider.ProviderConnection.runClientAction(ProviderConnection.Java:153)
at org.gradle.tooling.internal.provider.ProviderConnection.run(ProviderConnection.Java:143)
at org.gradle.tooling.internal.provider.DefaultConnection.run(DefaultConnection.Java:222)
at org.gradle.tooling.internal.consumer.connection.ParametrizedActionRunner.execute(ParametrizedActionRunner.Java:36)
at org.gradle.tooling.internal.consumer.connection.CancellableActionRunner.run(CancellableActionRunner.Java:51)
at org.gradle.tooling.internal.consumer.connection.AbstractConsumerConnection.run(AbstractConsumerConnection.Java:63)
at org.gradle.tooling.internal.consumer.connection.ParameterValidatingConsumerConnection.run(ParameterValidatingConsumerConnection.Java:54)
at org.gradle.tooling.internal.consumer.DefaultBuildActionExecuter$1.run(DefaultBuildActionExecuter.Java:76)
at org.gradle.tooling.internal.consumer.connection.LazyConsumerActionExecutor.run(LazyConsumerActionExecutor.Java:84)
at org.gradle.tooling.internal.consumer.connection.CancellableConsumerActionExecutor.run(CancellableConsumerActionExecutor.Java:45)
at org.gradle.tooling.internal.consumer.connection.ProgressLoggingConsumerActionExecutor.run(ProgressLoggingConsumerActionExecutor.Java:58)
at org.gradle.tooling.internal.consumer.connection.RethrowingErrorsConsumerActionExecutor.run(RethrowingErrorsConsumerActionExecutor.Java:38)
at org.gradle.tooling.internal.consumer.async.DefaultAsyncConsumerActionExecutor$1$1.run(DefaultAsyncConsumerActionExecutor.Java:55)
at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.Java:63)
at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.Java:46)
at Java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.Java:1142)
at Java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.Java:617)
at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.Java:55)
... 1 more
Caused by: Java.io.StreamCorruptedException: invalid type code: 68
at Java.io.ObjectInputStream.readObject0(ObjectInputStream.Java:1563)
at Java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.Java:2231)
at Java.io.ObjectInputStream.readSerialData(ObjectInputStream.Java:2155)
at Java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.Java:2013)
at Java.io.ObjectInputStream.readObject0(ObjectInputStream.Java:1535)
at Java.io.ObjectInputStream.readArray(ObjectInputStream.Java:1919)
at Java.io.ObjectInputStream.readObject0(ObjectInputStream.Java:1529)
at Java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.Java:2231)
at Java.io.ObjectInputStream.readSerialData(ObjectInputStream.Java:2155)
at Java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.Java:2013)
at Java.io.ObjectInputStream.readObject0(ObjectInputStream.Java:1535)
at Java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.Java:2231)
at Java.io.ObjectInputStream.readSerialData(ObjectInputStream.Java:2155)
at Java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.Java:2013)
at Java.io.ObjectInputStream.readObject0(ObjectInputStream.Java:1535)
at Java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.Java:2231)
at Java.io.ObjectInputStream.readSerialData(ObjectInputStream.Java:2155)
at Java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.Java:2013)
at Java.io.ObjectInputStream.readObject0(ObjectInputStream.Java:1535)
at Java.io.ObjectInputStream.readObject(ObjectInputStream.Java:422)
at org.gradle.tooling.internal.provider.serialization.PayloadSerializer.deserialize(PayloadSerializer.Java:74)
... 21 more
[設定]> [実験的]> [アクティブなバリアントのみを同期]を変更します(これをオフにします)。
または、プロジェクトファイルで対応する設定を手動で編集するには、.idea/workspace.xmlでnot.eligible.for.single.variant.syncをtrueに設定してみてください。
以下に示すようにXMLを直接編集するか、IntelliJの設定UIを使用できます。
<component name="PropertiesComponent">
<property name="not.eligible.for.single.variant.sync" value="true" />
</component>
これは、単一バリアント同期がKotlinでサポートされていないためです
注:この最適化は、JavaおよびC++言語を含むプロジェクトを完全にサポートし、Kotlinをサポートします。Kotlinコンテンツを含むプロジェクトの最適化を有効にすると、Gradle同期は内部で完全なバリアントの使用にフォールバックします。
https://developer.Android.com/studio/build/optimize-your-build#single_variant_sync
Gradleが完全なバリアント同期に自動的にフォールバックできない理由、またはAndroid Studioがこのフラグを自動的に設定しない理由については、私にはわかりません。