Kaitlyn Kaitlyn - 27 days ago 7
Android Question

How to totally clear a Gradle dependency (Android app)

I'm a newbie building an Android application in Android studio. I keep getting this Render error when I try to preview my layout file that looks like it traces back to the RecyclerView widget. I realized I wasn't actually using RecyclerView in my code, so I removed the line

compile 'com.android.support:cardview-v7:24.2.0'
from the dependency section in my
build.gradle
. But after I clean and rebuild and even delete everything from the
.gradle/caches
folder, I'm still getting the error. When I do a search of 'RecyclerView' in my code, I can see that there is still a package
android.support.v7.recyclerview
inside my
app
folder (even though I can't see these files in my actual directories?).

How can I fully get rid of RecyclerView?

Here is the stack trace for the error I'm seeing:


java.lang.IllegalStateException: Unable to locate mode 0 at
android.view.DisplayInfo.findMode(DisplayInfo.java:458) at
android.view.DisplayInfo.getMode(DisplayInfo.java:445) at
android.view.Display.getRefreshRate(Display.java:648) at
android.support.v7.widget.RecyclerView.onAttachedToWindow(RecyclerView.java:2392)
at android.view.View.dispatchAttachedToWindow(View.java:15392) at
android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:2953)
at
android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:2960)
at
android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:2960)
at
android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:2960)
at
android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:2960)
at
android.view.AttachInfo_Accessor.setAttachInfo(AttachInfo_Accessor.java:42)
at
com.android.layoutlib.bridge.impl.RenderSessionImpl.inflate(RenderSessionImpl.java:333)
at com.android.layoutlib.bridge.Bridge.createSession(Bridge.java:429)
at
com.android.ide.common.rendering.LayoutLibrary.createSession(LayoutLibrary.java:389)
at
com.android.tools.idea.rendering.RenderTask$2.compute(RenderTask.java:548)
at
com.android.tools.idea.rendering.RenderTask$2.compute(RenderTask.java:533)
at
com.intellij.openapi.application.impl.ApplicationImpl.runReadAction(ApplicationImpl.java:966)
at
com.android.tools.idea.rendering.RenderTask.createRenderSession(RenderTask.java:533)
at
com.android.tools.idea.rendering.RenderTask.lambda$inflate$53(RenderTask.java:659)
at java.util.concurrent.FutureTask.run(FutureTask.java:266) 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)


Any idea what is going on here?

EDIT:

Here is my
build.gradle
:

apply plugin: 'com.android.application'

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

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:24.2.0'
compile 'com.android.support:design:+'
compile 'com.android.support:cardview-v7:24.2.0'
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:24.2.1'
testCompile 'junit:junit:4.12'
}

Answer

Change

compile 'com.android.support:design:+'

To

compile 'com.android.support:design:24.2.0'

The design library has the recycler view as a dependency. You also have a duplicate AppCompat. Make sure all support library versions are the same.