繁体   English   中英

Kotlin Android Apollo 客户端未生成 Schema 类

[英]Kotlin Android Apollo client is not generating Schema classes

我正在开发一个 Android 应用程序。 在我的应用程序中,我使用 Apollo 客户端来使用 GraphQL API。 当我构建项目时,它没有根据 schema.json 文件生成类。 这是我迄今为止所做的。

这是我的应用程序

apply plugin: 'com.android.application'

apply plugin: 'kotlin-android'

apply plugin: 'kotlin-android-extensions'

apply plugin: 'com.apollographql.android'

android {
    compileSdkVersion 29
    buildToolsVersion "29.0.2"
    defaultConfig {
        applicationId "com.example.memento"
        minSdkVersion 21
        targetSdkVersion 29
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation"org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    implementation 'androidx.appcompat:appcompat:1.0.2'
    implementation 'androidx.core:core-ktx:1.0.2'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    implementation 'com.apollographql.apollo:apollo-runtime:1.1.3'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test:runner:1.1.1'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
    compileOnly 'org.jetbrains:annotations:13.0'
    testCompileOnly 'org.jetbrains:annotations:13.0'
}

这是我的项目盛大

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    ext.kotlin_version = '1.3.41'
    repositories {
        google()
        jcenter()
        maven { url 'https://oss.sonatype.org/content/repositories/snapshots/' }

    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.5.0'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        classpath 'com.apollographql.apollo:apollo-gradle-plugin:1.1.3'
        classpath 'com.apollographql.apollo:apollo-gradle-plugin:1.2.0-SNAPSHOT'
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        google()
        jcenter()

    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

我有 schema.json,这是项目结构

在此处输入图片说明

当我构建项目时,类在此文件夹中生成

在此处输入图片说明

但是我不能在我的代码中调用这些类。 它显示此错误。

在此处输入图片说明

如何在我的代码中使用这些类?

您需要在与.graphql相同的位置上以.graphql扩展名的文件中进行查询。 然后重建您的项目,它将生成类。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM