【问题标题】:ApolloGraphql FileNotFoundException: source/apollo/generatedIR/debug/src (Is a directory)ApolloGraphql FileNotFoundException: source/apollo/generatedIR/debug/src (是一个目录)
【发布时间】:2019-01-03 13:10:09
【问题描述】:

我正在尝试将 ApolloGraphql 添加到我的 android 项目中,但是当我尝试重建项目时,我得到:

org.gradle.api.UncheckedIOException: java.io.FileNotFoundException: /Users/mcebotari/Downloads/Projects/Barcloud/app/build/generated/source/apollo/generatedIR/snapshotDebug/src (Is a directory)

在 build.gradle 我添加了所需的依赖项:

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'

apply plugin: 'com.apollographql.android'


android {
  compileSdkVersion 27
  defaultConfig {
    applicationId "barcloud.com"
    minSdkVersion 21
    targetSdkVersion 27
    versionCode 1
    versionName "1.0"
    testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
  }
  buildTypes {
    release {
      minifyEnabled false
      proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
  }
}

dependencies {
  implementation fileTree(dir: 'libs', include: ['*.jar'])
  implementation "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
  implementation 'com.android.support:appcompat-v7:27.1.1'
  implementation 'com.android.support:design:27.1.1'

  //Design
  implementation 'com.github.rasoulmiri:buttonloading:v1.0.8'

  //Vision Library
  implementation 'com.google.android.gms:play-services-vision:15.0.2'

  // RxJava
  implementation "io.reactivex.rxjava2:rxjava:2.1.16"
  implementation "io.reactivex:rxandroid:1.2.1"
  implementation "com.jakewharton.rxbinding:rxbinding:1.0.1"
  implementation "com.squareup.retrofit2:adapter-rxjava:2.3.0"
  implementation 'com.jakewharton.rxbinding:rxbinding-appcompat-v7:1.0.1'

  //RxPermissions
  implementation 'com.tbruyelle.rxpermissions2:rxpermissions:0.9.5@aar'

  //Retrofit
  implementation "com.squareup.retrofit2:retrofit:2.4.0"
  implementation "com.squareup.retrofit2:adapter-rxjava2:2.4.0"
  implementation "com.squareup.retrofit2:converter-gson:2.4.0"

  // rxandroid
  implementation "io.reactivex.rxjava2:rxandroid:2.0.1"

  // Dagger
  implementation "com.google.dagger:dagger:2.12"
  kapt "com.google.dagger:dagger-compiler:2.12"

  //GraphQL
  implementation 'com.apollographql.apollo:apollo-runtime:1.0.0-alpha'
  implementation 'com.apollographql.apollo:apollo-rx2-support:1.0.0-alpha'

  testImplementation 'junit:junit:4.12'
  androidTestImplementation 'com.android.support.test:runner:1.0.2'
  androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}

还有依赖:

classpath 'com.apollographql.apollo:apollo-gradle-plugin:1.0.0-alpha'

尝试重建我得到的项目:

org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':app:generateDebugApolloClasses'.
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:100)
...
Caused by: org.gradle.api.UncheckedIOException: java.io.FileNotFoundException: /Users/mcebotari/Downloads/samples/Barcloud/app/build/generated/source/apollo/generatedIR/debug/src (Is a directory)
    at org.gradle.internal.UncheckedException.throwAsUncheckedException(UncheckedException.java:57)
...
Caused by: java.io.FileNotFoundException: /Users/mcebotari/Downloads/samples/Barcloud/app/build/generated/source/apollo/generatedIR/debug/src (Is a directory)
    at java.io.FileInputStream.open0(Native Method)

graphql 文件来自官方示例 - GithuntFeedQuery.graphql 及其 schema.json,粘贴在主文件夹中。

有什么想法吗?

【问题讨论】:

    标签: android kotlin graphql apollo


    【解决方案1】:

    与 prodRelease 配置有同样的问题,通过重命名 prod flavor 来解决。 在应用程序 build.gradle 我有:

    buildTypes { 
      debug {...}
      release {...}
    }
    productFlavors {
      dev {...}
      stage {...}
      prod {...}
    }
    

    这给了我 6 个 buildVariants

    devDebug
    devRelease
    stageDebug
    stageRelease
    prodDebug
    prodRelease
    

    前 5 个在本地和 CI 上构建没有问题,而 prodRelease 给了我与你描述的相同的错误,没有任何逻辑解释。 GraphQL 文件对于 dev、stage 和 prod 是相同的......我尝试为“prod”创建特定文件夹,然后为“prodRelease”创建特定文件夹,检查它们的访问权限 - 所有变体都相同,没有任何帮助。 prodDebug 一直在正确构建。然后我重命名了 prod flavor(不要忘记相应地重命名 graphql 文件夹),它现在就像一个魅力。

    【讨论】:

      【解决方案2】:

      我在研究这个问题时遇到了两种解决方案:

      1. 从您的项目中移除 apollo,(by editing your gradle files) 清理您的项目,然后再次添加 apollo。

      2. 尝试更改项目 gradle 文件中的 apollo 版本, IE。我的合作过

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

      原来是0.3.2

      【讨论】:

        猜你喜欢
        • 2015-06-28
        • 2021-05-30
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2013-03-24
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多