web-dev-qa-db-fra.com

Android Studio 3.3: la nouvelle synchronisation Gradle n'est pas prise en charge car elle contient des modules Kotlin (code de type non valide: 68)

dans un hybride Java-kotlin utilisant Android Studio 3.3 et supérieur, j'obtiens un message d'erreur code de type invalide: 68. Lorsque j'utilise gradle 5.1 et supérieur, j'obtiens un message disant "la nouvelle synchronisation Gradle n'est pas prise en charge en raison de la présence de modules Kotlin"

Comment reproduire dans Android studio 3.3:

1) créer un nouveau projet Android dans Java avec une activité vierge)

2) créer un fichier de classe kotlin

3) cliquez sur le bouton configurer kotlin pour ajouter les plugins et la bibliothèque kotlin au projet

4) synchroniser le gradle

Mes projets fonctionnaient bien sur la précédente Android version stable de Studio (3.2.1)

trace complète de la pile:

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
17
Ruben

Modifier les préférences> Expérimental> Synchroniser uniquement la variante active (décochez-la).

Alternativement, pour modifier manuellement le paramètre correspondant dans vos fichiers de projet: Essayez de définir not.eligible.for.single.variant.sync sur true dans .idea/workspace.xml

Vous pouvez soit modifier le XML directement comme indiqué ci-dessous, soit utiliser l'interface utilisateur des paramètres d'IntelliJ:

  <component name="PropertiesComponent">
    <property name="not.eligible.for.single.variant.sync" value="true" />
  </component>

En effet, la synchronisation à variante unique n'est pas prise en charge dans Kotlin

Remarque: Cette optimisation prend entièrement en charge les projets qui incluent Java et langages C++, et prend en charge Kotlin. Lorsque vous activez l'optimisation pour les projets avec du contenu Kotlin, la synchronisation Gradle revient à utiliser des variantes complètes en interne.

https://developer.Android.com/studio/build/optimize-your-build#single_variant_sync

Quant à savoir pourquoi Gradle ne parvient pas à revenir automatiquement à la synchronisation complète des variantes, ou pourquoi Android Studio ne définit pas automatiquement ce drapeau pour vous, je n'en ai aucune idée.

25
lbenedetto