Android Studio:需要更改版本号,但如果我这样做则无法解决

时间:2018-04-09 13:34:20

标签: android gradle

我对Android工作室很陌生,在搜索这个网站以寻找问题时,我似乎遇到了一个全新的问题。

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

我是这样做的,但到那时我会得到一个或多个错误,上面写着“无法解决:[app name and version]”

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

我的代码如下

    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

现在添加了Build level 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
}

1 个答案:

答案 0 :(得分:0)

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用户界面版must be compatible with those, not the same