5

I have a module called TestGUILib and I have specified testview.xml with a simple FrameLayout.

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <TextView
        android:id="@+id/textView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Testing View!" />

</FrameLayout>

I tried to use this layout in my main app activity_main. Here is my code:

<?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="com.example.sam.testapp1.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" />

    <include layout="@layout/testview"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        />

</android.support.constraint.ConstraintLayout>

Everything works fine. It compiles ok and runs ok. But the preview doesn't work. It shows the blank screen (ie. when I clicked on "Design", it turns blank) with render errors:

Could not find layout resource matching value 0x7F04002F (resolved name: testview) in current configuration.

Also, there is a line under testview (ie. include layout="@layout/testview"). When I rolled my mouse over, it said

Typo in the word 'testview'

Spellchecker inspection helps locate typos and misspelling in your code, comments and literals, and fix them in one click.

Any idea? Thanks

3 Answers 3

5

go to "File > Invalidate Caches/Restart...", click "Invalidate and Restart". it should work.

Sign up to request clarification or add additional context in comments.

Comments

2

Lets assume you have moduleOne and moduleTwo and if you want to use moduleTwo resources in moduleOne add following (sample) code in moduleOne gradle

    dependencies {
    compile project(':moduleTwo')
   }

This will include moduleOne into you moduleTwo in order to use its resouces including layouts.

Comments

1

Possible you have forgotten to enable

buildFeatures {
    viewBinding true
}

in the second module. In that case viewbinding will not find view and show it red like an unknown element

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.