Ris*_*mar 5 android kotlin android-studio graphql
我正在尝试在我的 Kotlin Android 项目中安装 apollo graphql 插件。
根据Kotlin Apollographql 安装的说明,我正在尝试使用旧语法进行安装过程。
我的 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"
}
Run Code Online (Sandbox Code Playgroud)
我的 build.gradle(项目) 文件:
// 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
}
Run Code Online (Sandbox Code Playgroud)
当我尝试同步 gradle 文件时出现以下错误:
Plugin with id 'com.apollographql.apollo' not found.
Run Code Online (Sandbox Code Playgroud)
我一直试图找出问题所在,但无法做到。对此的任何帮助将不胜感激。
所以我只是想知道为什么 gradle 没有同步。首先,build.gradle(app) 文件是完全正确的。没有任何变化。其次,要使其正常工作,您必须做的主要更改或添加是在 build.gradle(project) 文件中添加以下行:
classpath "com.apollographql.apollo:apollo-gradle-plugin:2.3.1"
Run Code Online (Sandbox Code Playgroud)
就在依赖项 {} 块中的注释上方。
因此,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
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4092 次 |
| 最近记录: |