android - 新创建的 Android Studio 项目中没有布局预览
问题描述
我刚刚在更新 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 代码的蓝图和设计视图。
解决方案
使用实现 'com.android.support:design:28.0.0-rc01' 更新 android studio 并修复问题。
推荐阅读
- java - 如何在 SQL 中获取记录删除日期?
- javascript - JavaScript 中解构赋值的顺序是否有保证?
- javascript - 单击链接时Angular会创建滚动条,但它不应该吗?
- java - 多对一中的Spring未解决的前向引用
- mysql - 在 SQL 中选择部分匹配输入的行
- sql - 从 BigQuery 中具有无效令牌的列中解析 JSON 文件
- push-notification - Swift iOS 13:单击推送通知如何打开文本字段?
- testing - 如何让我的 TestCafe 框架处理 Web 应用程序上的 A/B 实验?
- java - OpenJDK 11 和 Eclipse 中的 javax.xml 问题
- asp.net-mvc - ASP.NET MVC 中同一视图/控制器上的多个操作