xml – Render Problem with Android Studio 2021 2.1.15 (the style does not change in the emulator)

I am learning to build an app with android studio and using Kotlin. I just started changing the style of the “TextView” element but the view in the emulator isn’t changing. Here is the code of “activity_main.xml” :

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.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="@string/app_name"
        android:layout_marginLeft="@dimen/default_margin"
        android:layout_marginTop="@dimen/default_margin"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        style="@style/DefaultTextStyle"/>

</androidx.constraintlayout.widget.ConstraintLayout>

Here is the code of “valuesthemes.xml”

<resources xmlns:tools="http://schemas.android.com/tools">
    <!-- Base application theme. -->
    <style name="Theme.NatureCollection" parent="Theme.AppCompat.Light.NoActionBar">
        <!-- Primary brand color. -->
        <item name="colorPrimary">@color/purple_500</item>
        <item name="colorPrimaryVariant">@color/purple_700</item>
        <item name="colorOnPrimary">@color/white</item>
        <!-- Secondary brand color. -->
        <item name="colorSecondary">@color/teal_200</item>
        <item name="colorSecondaryVariant">@color/teal_700</item>
        <item name="colorOnSecondary">@color/black</item>
        <!-- Status bar color. -->
        <item name="android:statusBarColor" tools:targetApi="l">?attr/colorPrimaryVariant</item>
        <!-- Customize your theme here. -->
    </style>

    <!-- Créer le composant poour le titre par défaut -->
    <style name="DefaultTextStyle">
        <item name="android:textColor">@color/lightGray</item>
        <item name="android:textSize">18sp</item>
        <item name="android:fontFamily">@font/Kanit-Regular</item>
    </style>

    <style name="SubtitleTextStyle" parent="DefaultTextStyle">
        <item name="android:textColor">@color/darkGray</item>
    </style>

    <style name="TitleTextStyle" parent="SubtitleTextStyle">
        <item name="android:textSize">24sp</item>
    </style>

</resources>

Here is the code of “dimen.xml” :

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <dimen name="default_margin">20dp</dimen>
</resources>

Here is the name of “colors.xml” :

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <color name="purple_200">#FFBB86FC</color>
    <color name="purple_500">#FF6200EE</color>
    <color name="purple_700">#FF3700B3</color>
    <color name="teal_200">#FF03DAC5</color>
    <color name="teal_700">#FF018786</color>
    <color name="black">#FF000000</color>
    <color name="white">#FFFFFFFF</color>

    <color name="darkGray">#202122</color>
    <color name="lightGray">#989ca0</color>
    <color name="Green">#77d353</color>
    <color name="darkGreen">#5c9447</color>
</resources>

Here is the code of “strings.xml” :

<resources>
    <string name="app_name">Nature Emoi</string>

    <!-- Page d'accueil -->
    <string name="home_page_title">A découvrir</string>
    <string name="home_page_last_plant_section">Dernières Plantes</string>

    <!-- Page de collection -->
    <string name="collection_page_title">Ma Collection</string>

    <!-- Page d'ajout de plantes -->
    <string name="add_plant_page_title">Ajout d'une planet</string>
    <string name="add_plant_page_upload_button">Charger Image</string>
    <string name="add_plant_page_name_input">@string/item_plant_name</string>
    <string name="add_plant_page_description_input">@string/item_plant_description</string>

    <string-array name="add_plant_page_grow_spinner_input">
        <item>Croissance : Lente</item>
        <item>Croissance : Moyenne</item>
        <item>Croissance : Rapide</item>
    </string-array>

    <string-array name="add_plant_page_water_spinner_input">
        <item>Consommation : Lente</item>
        <item>Consommation : Moyenne</item>
        <item>Consommation : Elevée</item>
    </string-array>

    <string name="add_plant_page_confirm_button">Confirmer</string>

    <!-- Fenêtre Pop Up de détails -->
    <string name="popup_plant_name">Plant Name</string>
    <string name="popup_plant_description_title">Description</string>
    <string name="popup_plant_description_subtitle">Une petite description</string>
    <string name="popup_plant_grow_title">Croissance</string>
    <string name="popup_plant_grow_subtitle">Lente</string>
    <string name="popup_plant_water_title">Consommation d'eau</string>
    <string name="popup_plant_water_subtitle">Faible</string>


    <!-- Plante Customisée -->
    <string name="item_plant_name">Nom de la plante</string>
    <string name="item_plant_description">Description de la plante</string>
</resources>

The emulator is also giving me this error message :

Render Problem

java.lang.reflect.InvocationTargetException at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(NativeMethodAccessorImpl.java:-2) at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:-2) at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeccessorImpl.invoke:jdk.internal.reflector.NativeMethodAccessorImpl.invoke(NativeccessorIthompl.invoke): jdk.internal. .invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:566) at android.view.LayoutInflater.onCreateView(LayoutInflater.java:934) at android.view.LayoutreInflater.onC LayoutInflater.java:954) at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:1008) at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:965) at android.view.LayoutInflater.rInflate_Original:Inflater.La ) at android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:72) at android.view.LayoutInflater.rInflate(LayoutInflater.java:1101) at android.view.LayoutInflater.rInflateChildren(LayoutInflater.rInflater) android. .LayoutInflater.inflate(LayoutInflater.java:686) at android.view.LayoutInflater.inflate(LayoutInflater.java:505)

And here is the screenshot of the emulator render :

Thank you in advance for your reply

Leave a Comment