【发布时间】:2019-02-19 10:12:19
【问题描述】:
[在此处输入图片描述]
在右上角,缩放按钮旁边会出现一个蓝色警告,基本上是:
未能启动一门或多门课程
以下类无法实例化:
- android.support.constraint.ConstraintLayout
带有异常详情:
异常详情 java.lang.NoClassDefFoundError: android/support/constraint/R$styleable android.support.constraint.ConstraintLayout.init(ConstraintLayout.java:599) android.support.constraint.ConstraintLayout.(ConstraintLayout.java:576 ) java.lang.reflect.Constructor.newInstance(Constructor.java:423) android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:730) android.view.LayoutInflater.inflate(LayoutInflater.java:492) android.view.LayoutInflater.inflate(LayoutInflater.java:394)
还有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>
在 tools:context=".MainActivity" 行上,.MainActivity 以红色显示“Unresolved class MainActivity”
这是我的 AndroidManifest.xml 文件:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.kaan.asd">
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
我是 Android Studio 的新手,我已经尝试解决这个问题很长一段时间了,我尝试过清除缓存、清理/重建项目,但都没有解决我的问题。 我在 Windows 上使用带有 4.10.1 gradle 版本的 Android Studio 3.3.1 版本。 如果有人能帮我解决它,我会很高兴的。
【问题讨论】:
-
您使用的是新的 mdc 还是支持库?
标签: android android-studio android-layout android-constraintlayout