Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build error upgrading to 2.x #2886

Closed
rudas23 opened this issue Jan 19, 2021 · 4 comments
Closed

Build error upgrading to 2.x #2886

rudas23 opened this issue Jan 19, 2021 · 4 comments

Comments

@rudas23
Copy link

rudas23 commented Jan 19, 2021

I'm getting build errors when upgrading to 2.x

Basically the project structure is:
App -> Feature A -> ApolloGraphQL

Project build.gradle

plugins {
    id("com.apollographql.apollo").version("2.5.2").apply(false)
}

ApolloGraphQL/build.gradle

apply plugin: 'com.apollographql.apollo'

apollo {
    generateKotlinModels = true

    service("product") {
        sourceFolder.set("com/example/app/product")
        rootPackageName.set("com.example.app.product")
    }
    ... 
    ...
}

dependencies {
    implementation "com.apollographql.apollo:apollo-runtime:2.5.2"
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.4.21"
}

Build error when building module

Execution failed for task ':ApolloGraphQL:generateDebugCartApolloSources'.
> Could not initialize class com.apollographql.apollo.compiler.parser.introspection.IntrospectionSchema
* Try:
Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Exception is:
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':ApolloGraphQL:generateDebugCartApolloSources'.
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.lambda$executeIfValid$1(ExecuteActionsTaskExecuter.java:200)
...
...
Caused by: java.lang.NoClassDefFoundError: Could not initialize class com.apollographql.apollo.compiler.parser.introspection.IntrospectionSchema
    at com.apollographql.apollo.compiler.GraphQLCompiler$Companion.getSchemaInfo(GraphQLCompiler.kt:304)
    at com.apollographql.apollo.compiler.GraphQLCompiler$Companion.access$getSchemaInfo(GraphQLCompiler.kt:269)
    at com.apollographql.apollo.compiler.GraphQLCompiler.write(GraphQLCompiler.kt:42)
    at com.apollographql.apollo.gradle.internal.ApolloGenerateSourcesTask.taskAction(ApolloGenerateSourcesTask.kt:190)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

Module dependecies

...
...
com.apollographql.apollo:apollo-runtime:2.5.2
  com.apollographql.apollo:apollo-api:2.5.2
    com.apollographql.apollo:apollo-api-metadata:2.5.2
      com.squareup.okio:okio-multiplatform:2.9.0
        com.squareup.okio:okio-metadata:2.9.0
          org.jetbrains.kotlin:kotlin-stdlib-common:1.4.10 ➡ 1.4.21
       org.jetbrains.kotlin:kotlin-stdlib-common:1.4.10 ➡ 1.4.21
  com.apollographql.apollo:apollo-normalized-cache:2.5.2
com.apollographql.apollo:apollo-normalized-cache-metadata:2.5.2
  com.apollographql.apollo:apollo-api:2.5.2
  com.apollographql.apollo:apollo-normalized-cache-api:2.5.2
    com.apollographql.apollo:apollo-normalized-cache-api-metadata:2.5.2
      com.apollographql.apollo:apollo-api:2.5.2
      com.benasher44:uuid:0.2.0
        com.benasher44:uuid-metadata:0.2.0
      org.jetbrains.kotlin:kotlin-stdlib-common:1.4.10 ➡ 1.4.21
    org.jetbrains.kotlin:kotlin-stdlib-common:1.4.10 ➡ 1.4.21
  com.apollographql.apollo:apollo-http-cache-api:2.5.2
    com.squareup.okio:okio-multiplatform:2.9.0
    org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.4.10 ➡ 1.4.21
      org.jetbrains.kotlin:kotlin-stdlib:1.4.21
        org.jetbrains.kotlin:kotlin-stdlib-common:1.4.21
        org.jetbrains:annotations:13.0
      org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.4.21
        org.jetbrains.kotlin:kotlin-stdlib:1.4.21
  com.squareup.okhttp3:okhttp:3.12.11
    com.squareup.okio:okio:1.15.0
      org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.4.10 ➡ 1.4.21

Have tested upgrading okio lib without success as well...
Have also checked responses in here and here

@martinbonnin
Copy link
Contributor

martinbonnin commented Jan 19, 2021

Hi 👋 , yep, that looks like this okio decodeHex extension method that is only in recent versions. Do you use buildSrc ? If yes, could share the contents of buildSrc/build.gradle[.kts]?

@rudas23
Copy link
Author

rudas23 commented Jan 19, 2021

plugins {
    id 'org.jetbrains.kotlin.jvm' version '1.3.41'
}
repositories {
    maven {
        url "${mavenUrl}"
        credentials {
            username "${mavenUsername}"
            password "${mavenToken}"
        }
    }
}
dependencies {
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8"
    implementation gradleApi()
    implementation 'com.squareup.retrofit2:retrofit:2.6.0'
    implementation 'com.squareup.retrofit2:converter-gson:2.6.0'
    implementation 'com.squareup.okhttp3:logging-interceptor:3.14.2'
}
compileKotlin {
    kotlinOptions {
        jvmTarget = "1.8"
    }
}
compileTestKotlin {
    kotlinOptions {
        jvmTarget = "1.8"
    }
}
apply from: rootProject.file('../gradle/ktlint.gradle')

@martinbonnin
Copy link
Contributor

Can you add okio there ?

dependencies {
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8"
    ...
    implementation 'com.squareup.okio:okio:2.9.0'
}

@rudas23
Copy link
Author

rudas23 commented Jan 20, 2021

Changing okhttp version in buildSrc seems solved the problem. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants