2017-04-09 21 views
1

私は怒鳴るサンプルから使ってますが、私はライブラリを追加するときに私のエラーを取得しています:Android用apollo graphqlクライアントを使用していますか?

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

答えて

3

エラーは「スキーマファイルが見つかりませんでした。有効なschema.jsonファイルは「のsourceSetディレクトリに存在することを確認してください。

このJSONを作成するapollo-codegen download-schemaコマンドを使用します。これは--output続くパラメータとしてGraphQLエンドポイントのURLを、取り、JSONへのパス。JSONプロジェクトのsrc/main/graphql/を移動し、そこにあなたのコードは、(例えば、--output src/main/graphql/com/commonsware/graphql/trips/api/schema.json)に行ってみたいJavaパッケージを表すサブディレクトリになければならない格納する必要があります

ので、全体的に、あなたが持っているかもしれません:。

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

どうすればよいですか? 'apollo-codegen'は、内部または外部のコマンド、 操作可能なプログラムまたはバッチファイルとして認識されません。 –

+0

@JoJoRoid: 'apollo-codegen'はNodeパッケージです。 ** 'npm install -g apollo-codegen' **コマンドを実行してください。これは 'apollo-codegen'を"グローバルに "インストールするので、あなたはApollo-Androidを使いたいAndroidプロジェクトで利用できます。ただし、グローバルインストールに '-g'スイッチを使用すると、あなたの 開発マシンでスーパーユーザ権限(例えば' sudo')が必要になることに注意してください。 – CommonsWare

+1

このエラーを取得します。エラー: ':app:installApolloCodegen'タスクの実行に失敗しました。 >プロセス 'コマンド' D:\ AndroidStudioProject \ TestApollo \ app \ .gradle \ nodejs \ node-v6.7.0-win-x64 \ node.exe ''終了値が0以外の値-4048 –

2

古いバージョンのApolloを使用しています。これらの警告は、最近の安定版で修正されています。

私はあなたが

classpath 'com.apollographql.apollo:gradle-plugin:0.3.0' 

classpath 'com.apollographql.android:gradle-plugin:0.1.0' 

を交換し、generateClasses = trueブロックとconverter-pojoapollo-apiの依存関係を取り除く示唆しています。最新バージョンでは不要になりました。

その後、クリーンビルドを実行します。

関連する問題