gpt4 book ai didi

android - 使用适用于 Android 的 apollo graphql 客户端?

转载 作者:行者123 更新时间:2023-11-29 14:23:59 24 4
gpt4 key购买 nike

我正在使用下面的示例,但在添加库时出现错误:

Using the apollo graphql client for Android

下面是我的build.gradle (project):

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

buildscript {
repositories {
jcenter()
maven { url "https://jitpack.io" }
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.1'
classpath 'com.apollographql.android:gradle-plugin:0.1.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}

allprojects {
repositories {
jcenter()
mavenCentral()
}
}

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

下面是我的 build.gradle (Module):

apply plugin: 'com.android.application'

android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "com.example.admin.apollotest"
minSdkVersion 15
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support.constraint:constraint-layout:1.0.1'
testCompile 'junit:junit:4.12'

compile 'com.apollographql.android:api:0.1.0' // the apollo runtime classes needed by auto-generated code
compile 'com.squareup.retrofit2:retrofit:2.1.0' // retrofit2
compile 'com.jakewharton.retrofit:retrofit2-rxjava2-adapter:1.0.0' // rxjava2 to use the Observables stuff
compile 'com.apollographql.android:converter-pojo:0.1.0' // converts retrofit responses to pojos (ApolloConverterFactory)
}
apply plugin: 'com.apollographql.android'

apollo {
// this tells the apollo compiler to generate actual static classes instead of just interfaces (more on that later)
generateClasses = true
}

让我遇到错误:

enter image description here

最佳答案

错误是“找不到架构文件。请确保 sourceSet 目录中存在有效的 schema.json 文件”。

使用 apollo-codegen download-schema 命令创建此 JSON。这将 GraphQL 端点的 URL 作为参数,后跟 --output 和应该存储 JSON 的路径。 JSON 应该进入项目的 src/main/graphql/,并在其中进入代表您希望代码进入的 Java 包的子目录(例如,--output src/main/graphql/com/commonsware/graphql/trips/api/schema.json).

所以,总的来说,你可能有:

apollo-codegen download-schema https://graphql-demo.commonsware.com/0.1/graphql --output src/main/graphql/com/commonsware/graphql/trips/api/schema.json

关于android - 使用适用于 Android 的 apollo graphql 客户端?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43304986/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com