gpt4 book ai didi

android - 错误 : Android Gradle Plugin: Cannot Access Publisher

转载 作者:行者123 更新时间:2023-11-29 22:57:00 26 4
gpt4 key购买 nike

我正在使用 Android studio 3.4.2

我的build.gradle文件如下

自升级 android studio 以来,我收到此错误并且无法运行该应用程序。

我把代码转成了androidx。

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

buildscript {

ext.realmVersion = '5.9.1'
ext.googleServiceVersion = '4.2.0'
repositories {

mavenCentral()
google()
jcenter()
maven {
url "http://storage.googleapis.com/r8-releases/raw/master"
}
maven { url "https://jitpack.io" }

}
dependencies {
classpath 'com.android.tools:r8:522bd9fc1d398753fed5134b6c4fe32cdae482be' // Must be before the Gradle Plugin for Android.
classpath 'com.android.tools.build:gradle:3.4.2'
// classpath 'com.android.tools.build:gradle:3.5.0-alpha13'
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.2'
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.4.1'
classpath "io.realm:realm-gradle-plugin:$realmVersion"
classpath "com.google.gms:google-services:$googleServiceVersion"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}

allprojects {

repositories {

mavenCentral()
maven { url "https://jitpack.io" }
google()
jcenter()
}
}

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

我的 App 级构建 gradle

apply plugin: 'com.android.application'

buildscript {
repositories {
maven { url 'https://maven.fabric.io/public' }
maven { url "https://jitpack.io" }
}

dependencies {
classpath 'io.fabric.tools:gradle:+'
}
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'


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

lintOptions {
disable 'RestrictedApi'
disable 'MissingTranslation'
}//this until Google release a fix .bottomsheet super

dexOptions {
preDexLibraries true
javaMaxHeapSize "4g"
dexInProcess = true
}

packagingOptions {
exclude '.readme'
exclude 'LICENSE.txt'
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/DEPENDENCIES.txt'
exclude 'META-INF/LGPL2.1'
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/README.txt'
exclude 'META-INF/dependencies.txt'
exclude 'META-INF/license.txt'
exclude 'META-INF/notice.txt'
exclude 'META-INF/services/javax.annotation.processing.Processor'
exclude 'META-INF/MANIFEST.MF'
}
sourceSets {
main {
jniLibs.srcDirs = ['libs']
}
}
}

dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
//noinspection GradleCompatible

def supportLibsVer = '1.0.0-beta01'

implementation "androidx.appcompat:appcompat:1.1.0-rc01"
implementation "androidx.cardview:cardview:$supportLibsVer"
implementation "androidx.recyclerview:recyclerview:1.1.0-beta01"

implementation 'com.google.android.gms:play-services-maps:17.0.0'
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'

implementation('com.android.support:multidex:1.0.1') {
exclude module: 'support-v4'
}
implementation files('libs/DataVaultLib-2.3.3.13.jar')
implementation 'org.apache.commons:commons-lang3:3.6'

//CardView

implementation 'com.google.code.gson:gson:2.8.5'
implementation 'com.squareup.retrofit2:retrofit:2.5.0'
implementation 'com.squareup.retrofit2:converter-gson:2.4.0'
implementation 'com.squareup.retrofit2:adapter-rxjava2:2.4.0'
implementation 'com.squareup.okhttp3:okhttp:3.12.0'
implementation 'com.squareup.okhttp3:logging-interceptor:3.11.0'


//Image Picker

implementation 'com.github.jrvansuita:PickImage:2.2.4'
implementation 'com.squareup.picasso:picasso:2.71828'

implementation('com.mikepenz:materialdrawer:6.0.7@aar') {
transitive = true
}

//For Firebase
implementation 'com.google.firebase:firebase-auth:18.1.0'
implementation 'com.google.android.gms:play-services-auth:17.0.0'
implementation 'com.google.firebase:firebase-core:17.0.1'
implementation 'com.google.firebase:firebase-messaging:19.0.1'

//For Google Places

implementation('com.google.android.gms:play-services-places:16.1.0') {
exclude module: 'support-v4'
}
implementation('com.google.android.gms:play-services-location:16.0.0') {
exclude module: 'support-v4'
}
implementation('com.google.android.gms:play-services-maps:16.1.0') {
exclude module: 'support-v4'
}

//for event bus
implementation 'org.greenrobot:eventbus:3.1.1'


//Room Database
// Room
implementation 'android.arch.persistence.room:runtime:1.1.1'
annotationProcessor 'android.arch.persistence.room:compiler:1.1.1'


implementation('com.paytm:pgplussdk:1.3.3') {
transitive = true;
}
//
// implementation 'com.google.android.libraries.places:places:1.1.0'


}
apply plugin: 'com.google.gms.google-services'

我经历了stackoverflow的这个问题solve error: cannot access Publisher in Android Studio?

但这并没有帮助。

最佳答案

我一升级到 gradle 5.x(插件 3.4+)就遇到了同样的问题。就我而言,它是由两个看似无关的条件引起的:

1) 依赖于 retrofit 的 adapter-rxjava2 插件(没有附带的io.reactivex.rxjava2 依赖项):

implementation 'com.squareup.retrofit2:adapter-rxjava2:2.4.0'

2) 拥有一个带有直接返回列表的查询函数的 Room DAO:

@Dao
interface UserDao {
@Query("SELECT * FROM user")
fun getUsers(): List<User>
}

最简单的解决方案是删除 adapter-rxjava2 依赖项,因为我不再使用它了(而且你可能也不会,因为你不包含 io.reactivex.rxjava2 依赖项,因此错误)。

我还发现,无论出于何种原因,将 DAO 函数的返回类型从 List 更改为 Array 也解决了问题。不过,关于为什么这两件事结合导致此错误的实际根本原因对我来说仍然是个谜。

关于android - 错误 : Android Gradle Plugin: Cannot Access Publisher,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57331045/

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