Ich versuche, Layout mit ContraintsLayout zu erstellen.Androind 2.2 Vorschau 1 - Verwenden von ConstraintsLayout mit GuideLine App stürzt ab
In meinem Layout habe ich horizontale GuideLine
hinzugefügt.
Aber wenn ich die App laufen, stürzt es ab und wenn ich die GuideLine
entferne es funktioniert.
Ich habe auch die APK, und es gibt eine Klasse java.awt.Rectagle
StackStrace
java.lang.NoClassDefFoundError: Failed resolution of: Ljava/awt/Rectangle;
at android.support.constraint.solver.widgets.Guideline.<init>(Guideline.java:43)
at android.support.constraint.ConstraintLayout.setChildrenConstraints(ConstraintLayout.java:128)
at android.support.constraint.ConstraintLayout.updateHierarchy(ConstraintLayout.java:106)
at android.support.constraint.ConstraintLayout.onFinishInflate(ConstraintLayout.java:87)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:867)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:821)
at android.view.LayoutInflater.inflate(LayoutInflater.java:518)
at android.view.LayoutInflater.inflate(LayoutInflater.java:426)
at android.view.LayoutInflater.inflate(LayoutInflater.java:377)
at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:280)
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)
at com.infostretch.app.MainActivity.onCreate(MainActivity.java:11)
at android.app.Activity.performCreate(Activity.java:6669)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1118)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2578)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2686)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1440)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:5969)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:801)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:691)
Caused by: java.lang.ClassNotFoundException: Didn't find class "java.awt.Rectangle" on path: DexPathList[[zip file "/data/app/com.infostretch.app-1/base.apk"],nativeLibraryDirectories=[/data/app/com.infostretch.app-1/lib/x86_64, /system/lib64, /vendor/lib64]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:380)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
at android.support.constraint.solver.widgets.Guideline.<init>(Guideline.java:43)
at android.support.constraint.ConstraintLayout.setChildrenConstraints(ConstraintLayout.java:128)
at android.support.constraint.ConstraintLayout.updateHierarchy(ConstraintLayout.java:106)
at android.support.constraint.ConstraintLayout.onFinishInflate(ConstraintLayout.java:87)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:867)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:821)
at android.view.LayoutInflater.inflate(LayoutInflater.java:518)
at android.view.LayoutInflater.inflate(LayoutInflater.java:426)
at android.view.LayoutInflater.inflate(LayoutInflater.java:377)
at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:280)
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)
at com.infostretch.app.MainActivity.onCreate(MainActivity.java:11)
at android.app.Activity.performCreate(Activity.java:6669)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1118)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2578)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2686)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1440)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:5969)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:801)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:691)
Layout-XML-Datei
<?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:id="@+id/constraintLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/white"
android:orientation="vertical"
tools:layout_editor_absoluteX="0dp"
tools:layout_editor_absoluteY="80dp">
<ImageView
android:id="@+id/imageView"
android:layout_width="48dp"
android:layout_height="48dp"
android:layout_marginStart="16dp"
android:layout_marginTop="16dp"
android:src="@color/accent_material_light"
app:layout_constraintLeft_toLeftOf="@+id/constraintLayout"
app:layout_constraintTop_toTopOf="@+id/constraintLayout"
tools:layout_constraintLeft_creator="0"
tools:layout_constraintTop_creator="0"
tools:layout_editor_absoluteX="16dp"
tools:layout_editor_absoluteY="16dp" />
<TextView
android:id="@+id/textView11"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginEnd="16dp"
android:layout_marginStart="16dp"
android:layout_marginTop="16dp"
android:text="TextView"
app:layout_constraintLeft_toRightOf="@+id/imageView"
app:layout_constraintRight_toRightOf="@+id/constraintLayout"
app:layout_constraintTop_toTopOf="@+id/constraintLayout"
tools:layout_constraintLeft_creator="0"
tools:layout_constraintRight_creator="0"
tools:layout_constraintTop_creator="0"
tools:layout_editor_absoluteX="80dp"
tools:layout_editor_absoluteY="16dp" />
<ImageView
android:id="@+id/imageView2"
android:layout_width="28dp"
android:layout_height="28dp"
android:layout_marginEnd="16dp"
android:layout_marginTop="8dp"
android:src="@color/abc_input_method_navigation_guard"
app:layout_constraintRight_toRightOf="@+id/constraintLayout"
app:layout_constraintTop_toBottomOf="@+id/textView11"
tools:layout_constraintRight_creator="0"
tools:layout_constraintTop_creator="0"
tools:layout_editor_absoluteX="367dp"
tools:layout_editor_absoluteY="40dp" />
<android.support.constraint.Guideline
android:id="@+id/guideline"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:orientation="horizontal"
app:relativeBegin="83dp"
tools:layout_editor_absoluteX="0dp"
tools:layout_editor_absoluteY="83dp" />
<LinearLayout
android:id="@+id/linearLayout"
android:layout_width="0dp"
android:layout_height="120dp"
android:layout_marginEnd="16dp"
android:layout_marginStart="16dp"
android:layout_marginTop="16dp"
android:gravity="center"
android:orientation="vertical"
app:layout_constraintLeft_toLeftOf="@+id/constraintLayout"
app:layout_constraintRight_toRightOf="@+id/constraintLayout"
app:layout_constraintTop_toTopOf="@+id/guideline"
tools:layout_constraintLeft_creator="0"
tools:layout_constraintRight_creator="0"
tools:layout_constraintTop_creator="0"
tools:layout_editor_absoluteX="16dp"
tools:layout_editor_absoluteY="99dp">
<TextView
android:id="@+id/textView12"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="MapView"
tools:layout_editor_absoluteX="16dp"
tools:layout_editor_absoluteY="230dp" />
</LinearLayout>
<LinearLayout
android:id="@+id/linearLayout2"
android:layout_width="0dp"
android:layout_height="120dp"
android:layout_marginEnd="16dp"
android:layout_marginStart="16dp"
android:layout_marginTop="8dp"
android:gravity="center"
android:orientation="vertical"
app:layout_constraintLeft_toLeftOf="@+id/constraintLayout"
app:layout_constraintRight_toRightOf="@+id/constraintLayout"
app:layout_constraintTop_toBottomOf="@+id/linearLayout"
tools:layout_constraintLeft_creator="0"
tools:layout_constraintRight_creator="0"
tools:layout_constraintTop_creator="0"
tools:layout_editor_absoluteX="16dp"
tools:layout_editor_absoluteY="227dp">
<TextView
android:id="@+id/textView13"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="Alert View"
tools:layout_editor_absoluteX="16dp"
tools:layout_editor_absoluteY="358dp" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginBottom="8dp"
android:layout_marginEnd="16dp"
android:layout_marginStart="16dp"
android:layout_marginTop="8dp"
android:gravity="center"
android:orientation="vertical"
app:layout_constraintBottom_toTopOf="@+id/linearLayout3"
app:layout_constraintLeft_toLeftOf="@+id/constraintLayout"
app:layout_constraintRight_toRightOf="@+id/constraintLayout"
app:layout_constraintTop_toBottomOf="@+id/linearLayout2"
tools:layout_constraintBottom_creator="0"
tools:layout_constraintLeft_creator="0"
tools:layout_constraintRight_creator="0"
tools:layout_constraintTop_creator="0"
tools:layout_editor_absoluteX="16dp"
tools:layout_editor_absoluteY="355dp">
<TextView
android:id="@+id/textView14"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="Recycler View"
tools:layout_editor_absoluteX="16dp"
tools:layout_editor_absoluteY="522dp" />
</LinearLayout>
<LinearLayout
android:id="@+id/linearLayout3"
android:layout_width="0dp"
android:layout_height="48dp"
android:orientation="horizontal"
app:layout_constraintBottom_toBottomOf="@+id/constraintLayout"
app:layout_constraintLeft_toLeftOf="@+id/constraintLayout"
app:layout_constraintRight_toRightOf="@+id/constraintLayout"
tools:layout_constraintBottom_creator="0"
tools:layout_constraintLeft_creator="0"
tools:layout_constraintRight_creator="0"
tools:layout_editor_absoluteX="0dp"
tools:layout_editor_absoluteY="554dp">
</LinearLayout>
</android.support.constraint.ConstraintLayout>
1. Haben Sie die "Vorschau 1" im Namen dieser Version von Android Studio gesehen? 2. Falls ja, dann wäre https://code.google.com/p/android/issues ein besserer Ort, um ein solches Problem zu posten. – Selvin
@Blackbelt - Ich habe die GuideLine-Ansicht in der XML-Datei und nicht in der Java-Datei hinzugefügt. Es ist also nicht notwendig, es zu importieren. –
@MohitSoni Haben Sie diese Abhängigkeiten 'compile 'com.android.support.constraint hinzugefügt: constraint-layout: 1.0.0-alpha1' ' für den Fall, wenn Sie dies nicht hinzufügen. –