无法导入 gradle 约束布局 2.0

can't import gradle constraintlayout 2.0

我尝试导入 constraintlayout 2.0 但没有成功 如果尝试将其导入 gradle 但无法解析。但是如果我导入 constraintlayout 1.1.0 它就像一个魅力

作品:

compile 'com.android.support.constraint:constraint-layout:1.1.0'

无效:

compile 'com.android.support.constraint:constraint-layout:2.+'

为了尝试新的约束布局,我安装了 android studio 3.2。我也有它附带的最新工具。 我检查了 sdk 工具,但在支持存储库下看不到 constraintlayout 2.0。

android {
    compileSdkVersion 'android-P'
    defaultConfig {
        applicationId "com.example.pteran_pc.test28"
        minSdkVersion 'P'
        targetSdkVersion 'P'
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'androidx.appcompat:appcompat:1.0.0-alpha1'
    implementation 'androidx.constraintlayout:constraintlayout:2.+'
    implementation 'androidx.lifecycle:lifecycle-extensions:2.0.0-alpha1'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test:runner:1.1.0-alpha1'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0-alpha1'
}

主要构建gradle

buildscript {

    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.2.0-alpha14'


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

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

根据 Android Studio Release Updates' webpage,可用于 ConstraintLayout 的最新版本是 1.1.0

所以我认为 ConstraintLayout 2.0 还不可用是安全的。

alpha 版本现已推出:)

implementation 'com.android.support.constraint:constraint-layout:2.0.0-alpha1'

https://androidstudio.googleblog.com/2018/06/constraintlayout-200-alpha-1.html