android - Android Studio:需要更改版本号,但如果执行失败,则无法解决

标签 android gradle

我是Android Studio的新手,在搜索该网站上的问题解决方案后,我似乎遇到了一个全新的问题。

尝试同步Grandle文件时遇到的主要问题通常是“请更新版本至(版本号)”

我这样做了,但是到这一点,我将收到一个或多个错误,提示“无法解决:[应用名称和版本]”

此时我该怎么办?考虑到我基于此发现的所有其他信息都应该修复它,现在似乎没有任何意义。

我的代码如下

    apply plugin: 'com.android.application'

android {
    compileSdkVersion 27
    defaultConfig {
        applicationId "twitchy.groupchatapp"
        minSdkVersion 25
        targetSdkVersion 27
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.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.1.0'
    implementation 'com.android.support.constraint:constraint-layout:1.0.2'
    implementation 'com.android.support:design:23.4.0'
    implementation 'com.google.firebase:firebase-core:11.8.0'
    implementation 'com.firebaseui:firebase-ui:0.6.0'
    implementation 'com.google.firebase:firebase-auth:9.2.1'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.1'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
}


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

非常感谢您的协助
*注意:代码是在我将每个代码更改为具有相同的版本号之前
以下是我执行此操作时收到的错误
Failed to resolve: com.android.support.constraint:constraint-layout:11.4.2
Show in File
Show in Project Structure dialog


Failed to resolve: com.android.support:design:11.4.2
Show in File
Show in Project Structure dialog


Failed to resolve: com.firebaseui:firebase-ui:11.4.2
Show in File
Show in Project Structure dialog

现在添加了构建级别Gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {

    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.1.0'
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
        classpath 'com.google.gms:google-services:3.1.0'

    }
}

allprojects {
    repositories {
        google()
        jcenter()
    }
}

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

最佳答案

com.android.support:项目和FirebaseUI都不具有版本11.4.2依赖性。

这些必须与文件顶部的compileSdk版本匹配。

对于您的用例,

implementation 'com.android.support:appcompat-v7:27.+'
implementation 'com.android.support:design:27.+'

然后,ConstraintLayout,look at the documentation

这行是正确的,并且与您的错误不符。
implementation 'com.android.support.constraint:constraint-layout:1.0.2'

该11.4.2数字用于Google Play services, and Firebase only,如果您要启动一个新的应用程序,则应进行相应的更新。

例如,
implementation 'com.google.firebase:firebase-core:11.8.0'
implementation 'com.google.firebase:firebase-auth:11.8.0'

Firebase UI版本must be compatible with those, not the same

关于android - Android Studio:需要更改版本号,但如果执行失败,则无法解决,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49734309/

相关文章:

android - 如何通过编程获取联系人的最大联系人ID?

android - Crashlytics 无法解析 Android 项目结构

maven - 如何排除Gradle生成的POM文件中的依赖

Android Twitter Fabric SDK 与 Google GSON 冲突

android - 无法获取 'EclipseProject'类型的模型

android - 如何禁用 Android 中的抽屉指示器移动?

android - 循环音频延迟启动-Crosswalk + Howler + Android

android - 检查谷歌地图集群管理器的大小返回 0 然后再次进行相同的调用并返回一个数字

maven - Jenkins Artifactory插件未生成POM文件

android - 问题覆盖方法