【问题标题】:Failed to resolve: core Affected Modules: app无法解决:核心受影响的模块:app
【发布时间】:2019-12-31 12:32:48
【问题描述】:

我使用的是 Android Studio 3.5.3,我的 Gradle 版本是 5.4.1 。 添加 butterknife 后,我的项目不同步,并显示“无法解析:核心”错误。

我加了

compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

在 madule:app 中的 android 标签中。

还添加了黄油刀依赖:

implementation 'com.jakewharton:butterknife:10.2.1'
  annotationProcessor 'com.jakewharton:butterknife-compiler:10.2.1'
} 

就像https://github.com/JakeWharton/butterknife中的黄油刀步骤一样

我的 build.gradle(module:app)

apply plugin: 'com.android.application'
apply plugin: 'com.jakewharton.butterknife'


android {
    compileSdkVersion 29
    buildToolsVersion "29.0.2"
    defaultConfig {
        applicationId "com.example.myapplication"
        minSdkVersion 15
        targetSdkVersion 29
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
        multiDexEnabled true

    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'androidx.appcompat:appcompat:1.1.0'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    implementation  'androidx.legacy:legacy-support-v4:1.0.0'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test:runner:1.2.0'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
    implementation 'com.android.support:multidex:1.0.3'
    implementation 'com.jakewharton:butterknife:10.2.1'
    annotationProcessor 'com.jakewharton:butterknife-compiler:10.2.1'


}
repositories {
    mavenCentral()
}

我的 build.gradle(项目:我的应用程序)

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

buildscript {
    repositories {
        google()
        mavenCentral()      
        jcenter()


    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.5.3'
        classpath 'com.jakewharton:butterknife-gradle-plugin:10.2.1'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

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

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

这是我的错误代码

ERROR: Failed to resolve: core
Affected Modules: app

my error code

【问题讨论】:

  • 只是建议您可以使用android数据绑定并避免使用butterKnife
  • @AsadAli 我搜索了我的问题,但没有找到任何解决方案:(。你有像我一样的问题吗?
  • 是任何:你的 gradle,setting.gradle... 文件中的核心词?
  • 你检查你是否处于离线模式吗?
  • @shadow 我只有androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'

标签: java android android-studio gradle butterknife


【解决方案1】:

尝试从“项目结构”->“依赖项”->“库”添加黄油刀依赖项,您可以轻松地在 ButterKnife 上使用“Google”搜索。也可以随意尝试那里的更新建议。

也检查其他库。尝试通过注释来禁用依赖项,直到遇到问题。是命中试炼法,因为事情是不确定的。

如果你可以发布你的 gradle 文件,也许可以帮助你。

您可以尝试使缓存失效并告诉我们它是否有效。

怀疑会有一个名为 core 的模块被删除。可能有任何称为核心的符号,并且没有任何 IDE 能够识别的定义。

【讨论】:

  • 我编辑了我的帖子,我在另一个 Windows 上的 android studio 中有这段代码,它工作正常,但我不知道为什么它在我的 linux 上不起作用:| .
  • 您说您尝试了新项目,但它只是不适用于 Linux。操作系统版本是多少?是乌班图吗?如果没有,请尝试一下。
  • 卸载 Mint 并安装 Ubantu。这是最好的。确保先将所有设置、软件和项目复制到外部存储。
猜你喜欢
  • 1970-01-01
  • 2020-09-30
  • 1970-01-01
  • 2020-01-31
  • 1970-01-01
  • 1970-01-01
  • 2021-10-26
  • 1970-01-01
  • 2021-12-06
相关资源
最近更新 更多