设计视图未在Android Studio

时间:2017-11-23 03:31:59

标签: android-studio android-constraintlayout designview

我刚刚导入了一个项目,但是当我尝试进入设计视图时,会显示:Design view

我目前的gradle版本是最新的26.0.2。我不知道该怎么做,有人有想法吗?

以下是一些Gradle脚本:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion

    defaultConfig {
        applicationId "com.example.Ron.myapp"
        minSdkVersion 15
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:23.1.1'
    compile 'com.android.support:design:23.1.1'
}

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

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.0.1'

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

allprojects {
    repositories {
        jcenter()
    }
}

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

3 个答案:

答案 0 :(得分:1)

我自己解决了这个问题。我升级了compileSdkVersion以及minSdkVersion以及依赖项。它现在看起来像这样:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 26
    buildToolsVersion

    defaultConfig {
        applicationId "com.example.Ron.myapp"
        minSdkVersion 18
        targetSdkVersion 26
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}


dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:26.0.2'
    compile 'com.android.support:design:26.0.2'
    compile 'com.android.support:cardview-v7:26.0.2'
}

答案 1 :(得分:0)

请更新您的support libcompileSdkVersion,如下所示。

compileSdkVersion   = 25
    buildToolsVersion   = "25.0.2"
    minSdkVersion       = 18 

    // Library versions
    supportLibraryVersion = "25.0.0"

还在ConstraintLauout文件中添加gradle gradle

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

有关详细信息,请查看:https://stackoverflow.com/a/45115111/1343788

答案 2 :(得分:0)

已知问题 只需添加

compile 'com.android.support.constraint:constraint-layout:1.0.2'
在你的gradle文件中

它会修复它