Панель предварительного просмотра не отображается.Проблема рендеринга с расположением координат - PullRequest
0 голосов
/ 21 июня 2019

Я изучаю и внедряю раскладку координат с помощью AppBarLayout и CollapsingToolbarLayout.Я перешел на AndroidX.После того, как я собрал панель предварительного просмотра, отображается проблема рендеринга

Я уже пробовал:

  1. Очистить проект
  2. Перестроить проект
  3. Импорт и внедрение темы дизайна материалов
  4. Перенос библиотеки вAndroidX

Мои зависимости

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test:runner:1.2.0'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'

    // MY DEPENDENCIES

    // Retrofit
    implementation "com.squareup.retrofit2:retrofit:2.5.0"
    implementation "com.squareup.retrofit2:converter-gson:2.5.0"

    // com.squareup.okhttp3
    implementation 'com.squareup.okhttp3:logging-interceptor:4.0.0-alpha01'

    // ViewModel and LiveData
    implementation "androidx.lifecycle:lifecycle-extensions:2.0.0"

    // AndroidX libraries use this lightweight import for Lifecycle
    implementation "androidx.lifecycle:lifecycle-runtime:2.0.0"

    // Room Components
    implementation "androidx.room:room-runtime:2.1.0"
    annotationProcessor "androidx.room:room-compiler:2.1.0"

    //Material Design Support Library
    implementation 'com.google.android.material:material:1.1.0-alpha07'


    // Okio
    implementation "com.squareup.okio:okio:2.2.2"

    // spots-dialog
    implementation 'com.github.d-max:spots-dialog:1.1@aar'

    // v7 appcompat library
    implementation 'androidx.appcompat:appcompat:1.0.2'

    // CardView
    implementation 'androidx.cardview:cardview:1.0.0'

    //RecyclerView
    implementation 'androidx.recyclerview:recyclerview:1.0.0'

    // GSON
    implementation 'com.google.code.gson:gson:2.8.5'

    //JACKSON (JSON)
    implementation 'com.fasterxml.jackson.core:jackson-core:2.9.9'
    implementation 'com.fasterxml.jackson.core:jackson-annotations:2.9.9'
    implementation 'com.fasterxml.jackson.core:jackson-databind:2.9.9'

    //ReactiveX or RxJava
    implementation "io.reactivex.rxjava2:rxjava:2.2.9"
    implementation 'io.reactivex.rxjava2:rxandroid:2.1.1'

    //Paging
    //https://developer.android.com/jetpack/androidx/releases/paging
    implementation "androidx.paging:paging-runtime:2.1.0" // For Kotlin use paging-runtime-ktx

    //Picasso
    implementation 'com.squareup.picasso:picasso:2.71828'

    //Collection
    implementation group: 'org.apache.commons', name: 'commons-collections4', version: '4.0'

    //ConstraintLayout
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
}

Мой файл макета activity_main.xml , как показано ниже

<com.google.android.material.appbar.AppBarLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:fitsSystemWindows="true"
    android:theme="@style/Theme.MaterialComponents.Light.DarkActionBar.Bridge">

    <com.google.android.material.appbar.CollapsingToolbarLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:fitsSystemWindows="true"
        android:theme="@style/Theme.MaterialComponents.Light.DarkActionBar.Bridge">
        >

        <androidx.core.widget.NestedScrollView
            android:layout_width="match_parent"
            android:layout_height="match_parent">

            <TableLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent">

                <TableRow
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:weightSum="12">

                    <androidx.appcompat.widget.AppCompatTextView
                        android:id="@+id/lblStaffID"
                        android:layout_width="0dp"
                        android:layout_height="wrap_content"
                        android:layout_weight="12"
                        android:paddingStart="6dp"
                        android:paddingEnd="6dp"
                        android:text="Staff ID"

                        />
                </TableRow>
            </TableLayout>
        </androidx.core.widget.NestedScrollView>
    </com.google.android.material.appbar.CollapsingToolbarLayout>
</com.google.android.material.appbar.AppBarLayout>

Ниже моя трассировка стека из редактора макетов.

java.lang.IllegalArgumentException: java.lang.ClassCastException@1138a649
at sun.reflect.GeneratedMethodAccessor683.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at android.animation.PropertyValuesHolder_Delegate.callMethod(PropertyValuesHolder_Delegate.java:108)
at android.animation.PropertyValuesHolder_Delegate.nCallFloatMethod(PropertyValuesHolder_Delegate.java:143)
at android.animation.PropertyValuesHolder.nCallFloatMethod(PropertyValuesHolder.java)
at android.animation.PropertyValuesHolder.access$400(PropertyValuesHolder.java:38)
at android.animation.PropertyValuesHolder$FloatPropertyValuesHolder.setAnimatedValue(PropertyValuesHolder.java:1387)
at android.animation.ObjectAnimator.animateValue(ObjectAnimator.java:990)
at android.animation.ValueAnimator.setCurrentFraction(ValueAnimator.java:674)
at android.animation.ValueAnimator.setCurrentPlayTime(ValueAnimator.java:637)
at android.animation.ValueAnimator.start(ValueAnimator.java:1069)
at android.animation.ValueAnimator.start(ValueAnimator.java:1088)
at android.animation.ObjectAnimator.start(ObjectAnimator.java:852)
at android.animation.StateListAnimator.start(StateListAnimator.java:188)
at android.animation.StateListAnimator.setState(StateListAnimator.java:181)
at android.view.View.drawableStateChanged(View.java:21105)
at android.view.ViewGroup.drawableStateChanged(ViewGroup.java:7101)
at com.google.android.material.appbar.AppBarLayout.drawableStateChanged(AppBarLayout.java:393)
at android.view.View.refreshDrawableState(View.java:21160)
at android.view.View.dispatchAttachedToWindow(View.java:18379)
at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3397)
at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3404)
at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3404)
at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3404)
at android.view.AttachInfo_Accessor.setAttachInfo(AttachInfo_Accessor.java:42)
at com.android.layoutlib.bridge.impl.RenderSessionImpl.inflate(RenderSessionImpl.java:335)
at com.android.layoutlib.bridge.Bridge.createSession(Bridge.java:391)
at com.android.tools.idea.layoutlib.LayoutLibrary.createSession(LayoutLibrary.java:195)
at com.android.tools.idea.rendering.RenderTask.createRenderSession(RenderTask.java:540)
at com.android.tools.idea.rendering.RenderTask.lambda$inflate$5(RenderTask.java:666)
at java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1590)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)

1 Ответ

0 голосов
/ 10 июля 2019

У меня тоже была такая же проблема, как и у моих товарищей по команде ... Я думаю, что проблема идет с библиотекой дизайна Если у вас есть элементы AppBarLayout и CollapsingToolbarLayout и Button в вашем проекте ... Это иногда плохо рендерится ... Я попытался Invalidating Caches / Restart , и у меня это сработало

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