【问题标题】:Failed to resolve: com.android.support after building gradle but my app can still be installed无法解决:构建 gradle 后 com.android.support 但我的应用仍然可以安装
【发布时间】:2018-09-05 19:24:39
【问题描述】:

我浏览了所有 stackoverflow 示例,但找不到解决问题的方法。我试图降级 mz sdk vesrion 和 android:support 但它没有用。 我在 build.gradle 中有以下代码。但是,每当我尝试构建我的 gradle 时,它​​都会显示错误:无法解析:com.android.support... 无论如何,我能够成功地将 apk 安装到我的设备上并且它运行良好。我只是不希望他的依赖会在未来引起一些错误。 谢谢!

    apply plugin: 'com.android.application'

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

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:27.0.1-alpha1'
    implementation 'com.android.support:design:27.1.1'
    implementation 'com.squareup.picasso:picasso:2.71828'
    implementation 'de.hdodenhof:circleimageview:1.3.0'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.navigation_menu:runner:1.0.2'
    androidTestImplementation 'com.android.support.navigation_menu.espresso:espresso-core:3.0.2'
    implementation 'com.facebook.android:facebook-android-sdk:4.36.0'
}

【问题讨论】:

  • 你使用的是什么 gradle 版本
  • 使用最新的 gradle 版本为什么要在较低的 gradle 上创建项目
  • 我使用我认为是最新的 Gradle 版本 3.1.4?
  • 那么为什么你使用旧的库使用最新的:实现 'com.android.support:appcompat-v7:28.0.0-alpha3'
  • 同样的故事。我还必须将 compileSdkVersion 从 27 更改为 28。

标签: android android-gradle-plugin


【解决方案1】:

您正在使用不同版本的 com.android.support。 这是你的代码:

    implementation 'com.android.support:appcompat-v7:27.0.1-alpha1'
    implementation 'com.android.support:design:27.1.1'

应该是这样的:

    implementation 'com.android.support:appcompat-v7:27.1.1'
    implementation 'com.android.support:design:27.1.1'

【讨论】:

  • 我已经尝试过了,但没有找到解决方案,无论如何,谢谢。
  • 发送您的 build.gradle 文件项目级别的屏幕截图
【解决方案2】:

您对 gradle 本地设置有疑问。您可以尝试使缓存无效并重新启动。 Click File -> Invalidate caches

有时您甚至可能在更新到新的 Gradle 级别时遇到其他问题。对于这种情况,请从 Project Room 中删除 .idea.gradle 文件夹,然后从 Idea 开始屏幕再次导入

【讨论】:

  • 如何重新导入回来?我刚建了项目就这些了吗?
  • 我的意思是,只要你更新了 gradle。在这种情况下,回滚不应该有帮助。试试上面的方法,它会从scrath收集所有的项目和依赖。
猜你喜欢
  • 2022-09-29
  • 2012-04-23
  • 2014-12-10
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多