androidandroid-layoutgradleandroid-layout-editor

RecyclerView is displayed as a grey box with it's name in the center. Same for an implemented audio Visualizer view


Here an image to better show the problem I'm having...

Around a week ago I implemented a music Viusalizer from here. I noticed that it didn't display correctly as it showed up as a grey window (see image above), but thinking that it wasn't a native plugin, I didn't give it too much thought.

Then two days ago I needed to use a RecyclerView, and when I downloaded it, it had the same 'broken' look (see image above). When I saw that, then I knew there was something wrong with the project or Android Studio.

I've already looked to everything I could find on the internet in the past couple of days and I tried everything, from downgrading the sdk compile version, to updating Android Studio to the latest version, to do "Invalidate Cache / Restart" from the 'File' menu.

this, this, this, this, this, this, this and this are all the things I found and tried, but so far, none helped...

This is my activity java file

package com.franchini.myapplication;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
    }
}

This is my activity xml file

<?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">

    <com.gauravk.audiovisualizer.visualizer.BlastVisualizer
        xmlns:custom="http://schemas.android.com/apk/res-auto"
        android:id="@+id/blast"
        android:layout_width="0dp"
        android:layout_height="0dp"
        android:layout_marginBottom="16dp"
        custom:avColor="@color/av_dark_blue"
        custom:avDensity="0.8"
        custom:avSpeed="normal"
        custom:avType="fill"
        custom:layout_constraintBottom_toTopOf="@+id/textView"
        custom:layout_constraintEnd_toEndOf="parent"
        custom:layout_constraintStart_toStartOf="parent"
        custom:layout_constraintTop_toTopOf="parent" />

    <TextView
        android:id="@+id/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.v7.widget.RecyclerView
        android:layout_width="0dp"
        android:layout_height="0dp"
        android:layout_marginTop="16dp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="0.0"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/textView" />

</android.support.constraint.ConstraintLayout>

This is my styles xml file

<resources>

    <!-- Base application theme. -->
    <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
        <!-- Customize your theme here. -->
        <item name="colorPrimary">@color/colorPrimary</item>
        <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
        <item name="colorAccent">@color/colorAccent</item>
    </style>

</resources>

This is my build.gradle (project) file

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    repositories {
        google()
        jcenter()

    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.3.2'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        google()
        jcenter()

    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

This is my build.gradle (app) file

apply plugin: 'com.android.application'

android {
    compileSdkVersion 28
    defaultConfig {
        applicationId "com.franchini.myapplication"
        minSdkVersion 21
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:28.0.0'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'

    implementation 'com.gauravk.audiovisualizer:audiovisualizer:0.9.1'

    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
    implementation 'com.android.support:recyclerview-v7:28.0.0'
}

Now, this problem seems to appear only on the Editor, because when I test it on Android directly, it works like a charm...

Can anyone help me figure this out? Am I missing something really stupid?

[Edit]: I wanted to point out that I get no errors whatsoever with this problem...


Solution

  • There is no problem with what you are doing.

    That is probably a bug that happens sometimes. Just go ahead and clean and rebuild your project. if that does not help, Go try invalidating caches by going File > Invalidate Caches / Restart.