gpt4 book ai didi

android - Gradle 插件 'com.apollographql.apollo' 未在 Android Studio 中同步

转载 作者:行者123 更新时间:2023-12-04 23:54:17 34 4
gpt4 key购买 nike

我正在尝试在我的 Kotlin Android 项目中安装 apollo graphql 插件。

根据 Apollographql installation for Kotlin 的说明,我正在尝试使用旧语法进行安装。

我的 build.gradle(app) 文件:

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'com.apollographql.apollo'

android {
compileSdkVersion 29

defaultConfig {
applicationId "com.example.goonlinepackagescanner"
minSdkVersion 26
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:$kotlin_version"
implementation 'androidx.core:core-ktx:1.3.1'
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.1'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'

implementation "com.apollographql.apollo:apollo-gradle-plugin:2.3.1"
implementation "com.apollographql.apollo:apollo-runtime:2.3.1"
implementation "com.apollographql.apollo:apollo-coroutines-support:2.3.1"
}

我的 build.gradle(project) 文件:

// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext.kotlin_version = '1.4.10'
repositories {
google()
jcenter()
}
dependencies {
classpath "com.android.tools.build:gradle:4.0.0"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"

// 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
}

当我尝试同步 gradle 文件时出现以下错误:

Plugin with id 'com.apollographql.apollo' not found.

我一直在努力找出哪里出了问题,但无法做到。对此的任何帮助将不胜感激。

最佳答案

所以我只是想出了为什么 gradle 没有同步。首先,build.gradle(app) 文件是完全正确的。它没有任何变化。其次,您必须做的主要更改或添加是在 build.gradle(project) 文件中添加以下行:

classpath "com.apollographql.apollo:apollo-gradle-plugin:2.3.1"

就在依赖项 {} block 中的注释上方。

因此,build.gradle(project) 文件现在如下所示:

//顶级构建文件,您可以在其中添加所有子项目/模块通用的配置选项。

buildscript {
ext.kotlin_version = '1.4.10'
repositories {
google()
jcenter()
}
dependencies {
classpath "com.android.tools.build:gradle:4.0.0"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "com.apollographql.apollo:apollo-gradle-plugin:2.3.1"
// 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
}

关于android - Gradle 插件 'com.apollographql.apollo' 未在 Android Studio 中同步,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63938943/

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