【问题标题】:No layout preview in Newly Created Android Studio Project新创建的 Android Studio 项目中没有布局预览
【发布时间】:2018-08-21 21:41:31
【问题描述】:

我刚刚在更新 Android Studio 和 SDK 后创建了新项目。这也是 28.0.0 alpha 中的问题,现在在 beta 之后,仍然面临它。有人知道解决方法吗?

这是毕业典礼:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 28
    defaultConfig {
        applicationId "me.innovativeapps.test"
        minSdkVersion 21
        targetSdkVersion 28
        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:28.0.0-beta01'
    implementation 'com.android.support.constraint:constraint-layout:1.1.2'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}

和项目 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.4'


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

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

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

下面是activity_main.xml的代码

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity">

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Hello World!"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

</android.support.constraint.ConstraintLayout>

我提到了几个链接,如https://stackoverflow.com/questions/51630511/conflicting-versions-of-the-support-library-because-of-the-firebase-library,但没有得到任何可行的解决方案。如何获取 xml 代码的蓝图和设计视图。

【问题讨论】:

  • 我知道 27 工作正常,我想使用最新的 API 版本。
  • @Panache 我尝试了所有我知道的方法,但我没有成功,如果你找到任何答案,请告诉我
  • 令人惊讶的谷歌更新到测试版,但仍然留下这么大的问题。
  • android pie 不再处于测试阶段,昨天发布了Check this out

标签: android


【解决方案1】:

使用实现 'com.android.support:design:28.0.0-rc01' 更新 android studio 并修复问题。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-12-23
    • 1970-01-01
    • 2018-12-03
    • 1970-01-01
    • 1970-01-01
    • 2019-04-16
    • 2013-11-18
    相关资源
    最近更新 更多