Android Studio не может инициировать макет ограничения - PullRequest
0 голосов
/ 19 февраля 2019

[введите описание изображения здесь]

В правом верхнем углу, рядом с кнопками масштабирования, появляется синее предупреждение, которое в основном гласит:

Не удалось инициировать один или несколько классов

Следующие классы не могут быть созданы:

  • 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) javaflect.stru.lan.newInstance (Constructor.java:423) android.view.LayoutInflater.createViewFromTag (LayoutInflater.java:730) android.view.LayoutInflater.inflate (LayoutInflater.java:492) android.view.LayoutInflater.inflatej:)

А также в текстовом формате 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>

Об инструментах: context = ". MainActivity" line .MainActivity aПоявляется красным цветом, говоря: «Неразрешенный класс 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 и пытаюсь решить эту проблему.в течение довольно долгого времени я пытался очистить кеш, очистить / перестроить проект, но ни один из них не решил мою проблемуЯ использую версию Android Studio 3.3.1 с версией 4.10.1 для Windows.Я бы оценил это, если бы кто-нибудь мог помочь мне исправить это.

1 Ответ

0 голосов
/ 19 февраля 2019

Вы должны добавить репозиторий макета ограничений в каталог android: app / build.gradle , как показано ниже:

implementation 'com.android.support.constraint:constraint-layout:1.1.3'

Затем синхронизируйте ваш проект и наслаждайтесь идеальным макетом.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...