Cabezz Cabezz Cabezz Cabezz - 1 month ago 15
Android Question

RecyclerView doesnt work on API 17 Android 4.2.2

I have a Recyclerview working on a MotoG but when i try to make it run on a device Android 4.2.2 API17 Huawei Y330-u05 the Recycleview doesn't work, the application it closes itself.
I attach my gradle file

apply plugin: 'com.android.application'

android {
compileSdkVersion 25
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "com.deitel.materialdesigncardviewsrecyclerdesign"
minSdkVersion 14
targetSdkVersion 25
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'])
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:25.0.0'
testCompile 'junit:junit:4.12'
compile 'com.android.support:design:25.0.0'
compile 'com.android.support:cardview-v7:25.0.0'
compile 'com.android.support:recyclerview-v7:25.0.0'

}


and here's my Logcat message

11-09 19:53:04.573 1019-019/com.deitel.materialdesigncardviewsrecyclerdesign E/AndroidRuntime: FATAL EXCEPTION: main
java.lang.NoClassDefFoundError: android.view.ViewAnimationUtils
at com.deitel.materialdesigncardviewsrecyclerdesign.SampleMaterialAdapter.animateCircularReveal(SampleMaterialAdapter.java:75)
at com.deitel.materialdesigncardviewsrecyclerdesign.SampleMaterialAdapter.onViewAttachedToWindow(SampleMaterialAdapter.java:65)
at com.deitel.materialdesigncardviewsrecyclerdesign.SampleMaterialAdapter.onViewAttachedToWindow(SampleMaterialAdapter.java:24)
at android.support.v7.widget.RecyclerView.dispatchChildAttached(RecyclerView.java:6541)
at android.support.v7.widget.RecyclerView$5.addView(RecyclerView.java:677)
at android.support.v7.widget.ChildHelper.addView(ChildHelper.java:107)
at android.support.v7.widget.RecyclerView$LayoutManager.addViewInt(RecyclerView.java:7399)
at android.support.v7.widget.RecyclerView$LayoutManager.addView(RecyclerView.java:7357)
at android.support.v7.widget.RecyclerView$LayoutManager.addView(RecyclerView.java:7345)
at android.support.v7.widget.LinearLayoutManager.layoutChunk(LinearLayoutManager.java:1459)
at android.support.v7.widget.LinearLayoutManager.fill(LinearLayoutManager.java:1408)
at android.support.v7.widget.LinearLayoutManager.onLayoutChildren(LinearLayoutManager.java:580)
at android.support.v7.widget.RecyclerView.dispatchLayoutStep2(RecyclerView.java:3374)
at android.support.v7.widget.RecyclerView.dispatchLayout(RecyclerView.java:3183)
at android.support.v7.widget.RecyclerView.onLayout(RecyclerView.java:3627)
at android.view.View.layout(View.java:14150)
at android.view.ViewGroup.layout(ViewGroup.java:4478)
at android.widget.RelativeLayout.onLayout(RelativeLayout.java:1021)
at android.view.View.layout(View.java:14150)
at android.view.ViewGroup.layout(ViewGroup.java:4478)
at android.widget.FrameLayout.onLayout(FrameLayout.java:448)
at android.view.View.layout(View.java:14150)
at android.view.ViewGroup.layout(ViewGroup.java:4478)
at android.support.v7.widget.ActionBarOverlayLayout.onLayout(ActionBarOverlayLayout.java:437)
at android.view.View.layout(View.java:14150)
at android.view.ViewGroup.layout(ViewGroup.java:4478)
at android.widget.FrameLayout.onLayout(FrameLayout.java:448)
at android.view.View.layout(View.java:14150)
at android.view.ViewGroup.layout(ViewGroup.java:4478)
at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1694)
at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1552)
at android.widget.LinearLayout.onLayout(LinearLayout.java:1465)
at android.view.View.layout(View.java:14150)
at android.view.ViewGroup.layout(ViewGroup.java:4478)
at android.widget.FrameLayout.onLayout(FrameLayout.java:448)
at android.view.View.layout(View.java:14150)
at android.view.ViewGroup.layout(ViewGroup.java:4478)
at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:2223)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1987)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1165)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:4962)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:776)
at android.view.Choreographer.doCallbacks(Choreographer.java:579)
at android.view.Choreographer.doFrame(Choreographer.java:548)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:762)
at android.os.Handler.handleCallback(Handler.java:800)
at android.os.Handler.dispatchMessage(Handler.java:100)
at android.os.Looper.loop(Looper.java:194)
at android.app.ActivityThread.main(ActivityThread.java:5455)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:525)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:966)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:733)
at dalvik.system.NativeStart.main(Native Method)
11-09 19:53:04.756 1019-1042/com.deitel.materialdesigncardviewsrecyclerdesign D/jdwp: processIncoming
11-09 19:53:04.756 1019-1042/com.deitel.materialdesigncardviewsrecyclerdesign D/jdwp: handlePacket : cmd=0x1, cmdSet=0xC7, len=0x14, id=0x400000C2, flags=0x0, dataLen=0x9
11-09 19:53:04.756 1019-1042/com.deitel.materialdesigncardviewsrecyclerdesign D/jdwp: sendBufferedRequest : len=0x34
11-09 19:53:05.258 1019-1042/com.deitel.materialdesigncardviewsrecyclerdesign D/jdwp: processIncoming
11-09 19:53:05.258 1019-1042/com.deitel.materialdesigncardviewsrecyclerdesign D/jdwp: handlePacket : cmd=0x1, cmdSet=0xC7, len=0x14, id=0x400000C3, flags=0x0, dataLen=0x9
11-09 19:53:05.259 1019-1042/com.deitel.materialdesigncardviewsrecyclerdesign D/jdwp: sendBufferedRequest : len=0x34
11-09 19:53:05.758 1019-1042/com.deitel.materialdesigncardviewsrecyclerdesign D/jdwp: processIncoming
11-09 19:53:05.758 1019-1042/com.deitel.materialdesigncardviewsrecyclerdesign D/jdwp: handlePacket : cmd=0x1, cmdSet=0xC7, len=0x14, id=0x400000C4, flags=0x0, dataLen=0x9
11-09 19:53:05.758 1019-1042/com.deitel.materialdesigncardviewsrecyclerdesign D/jdwp: sendBufferedRequest : len=0x34
11-09 19:53:06.259 1019-1042/com.deitel.materialdesigncardviewsrecyclerdesign D/jdwp: processIncoming
11-09 19:53:06.260 1019-1042/com.deitel.materialdesigncardviewsrecyclerdesign D/jdwp: handlePacket : cmd=0x1, cmdSet=0xC7, len=0x14, id=0x400000C5, flags=0x0, dataLen=0x9
11-09 19:53:06.260 1019-1042/com.deitel.materialdesigncardviewsrecyclerdesign D/jdwp: sendBufferedRequest : len=0x34
11-09 19:53:06.770 1019-1042/com.deitel.materialdesigncardviewsrecyclerdesign D/jdwp: processIncoming
11-09 19:53:06.771 1019-1042/com.deitel.materialdesigncardviewsrecyclerdesign D/jdwp: handlePacket : cmd=0x1, cmdSet=0xC7, len=0x14, id=0x400000C6, flags=0x0, dataLen=0x9
11-09 19:53:06.771 1019-1042/com.deitel.materialdesigncardviewsrecyclerdesign D/jdwp: sendBufferedRequest : len=0x34
11-09 19:53:07.261 1019-1042/com.deitel.materialdesigncardviewsrecyclerdesign D/jdwp: processIncoming
11-09 19:53:07.263 1019-1042/com.deitel.materialdesigncardviewsrecyclerdesign D/jdwp: handlePacket : cmd=0x1, cmdSet=0xC7, len=0x14, id=0x400000C7, flags=0x0, dataLen=0x9
11-09 19:53:07.263 1019-1042/com.deitel.materialdesigncardviewsrecyclerdesign D/jdwp: sendBufferedRequest : len=0x34
11-09 19:53:07.775 1019-1042/com.deitel.materialdesigncardviewsrecyclerdesign D/jdwp: processIncoming
11-09 19:53:07.775 1019-1042/com.deitel.materialdesigncardviewsrecyclerdesign D/jdwp: handlePacket : cmd=0x1, cmdSet=0xC7, len=0x14, id=0x400000C8, flags=0x0, dataLen=0x9
11-09 19:53:07.819 1019-1042/com.deitel.materialdesigncardviewsrecyclerdesign D/jdwp: sendBufferedRequest : len=0x34
11-09 19:53:08.264 1019-1042/com.deitel.materialdesigncardviewsrecyclerdesign D/jdwp: processIncoming
11-09 19:53:08.269 1019-1042/com.deitel.materialdesigncardviewsrecyclerdesign D/jdwp: handlePacket : cmd=0x1, cmdSet=0xC7, len=0x14, id=0x400000C9, flags=0x0, dataLen=0x9
11-09 19:53:08.275 1019-1042/com.deitel.materialdesigncardviewsrecyclerdesign D/jdwp: sendBufferedRequest : len=0x34
11-09 19:53:08.766 1019-1042/com.deitel.materialdesigncardviewsrecyclerdesign D/jdwp: processIncoming
11-09 19:53:08.767 1019-1042/com.deitel.materialdesigncardviewsrecyclerdesign D/jdwp: handlePacket : cmd=0x1, cmdSet=0xC7, len=0x14, id=0x400000CA, flags=0x0, dataLen=0x9
11-09 19:53:08.767 1019-1042/com.deitel.materialdesigncardviewsrecyclerdesign D/jdwp: sendBufferedRequest : len=0x34
11-09 19:53:09.269 1019-1042/com.deitel.materialdesigncardviewsrecyclerdesign D/jdwp: processIncoming
11-09 19:53:09.269 1019-1042/com.deitel.materialdesigncardviewsrecyclerdesign D/jdwp: handlePacket : cmd=0x1, cmdSet=0xC7, len=0x14, id=0x400000CB, flags=0x0, dataLen=0x9
11-09 19:53:09.269 1019-1042/com.deitel.materialdesigncardviewsrecyclerdesign D/jdwp: sendBufferedRequest : len=0x34
11-09 19:53:09.774 1019-1042/com.deitel.materialdesigncardviewsrecyclerdesign D/jdwp: processIncoming
11-09 19:53:09.778 1019-1042/com.deitel.materialdesigncardviewsrecyclerdesign D/jdwp: handlePacket : cmd=0x1, cmdSet=0xC7, len=0x14, id=0x400000CC, flags=0x0, dataLen=0x9
11-09 19:53:09.786 1019-1042/com.deitel.materialdesigncardviewsrecyclerdesign D/jdwp: sendBufferedRequest : len=0x34
11-09 19:53:10.277 1019-1042/com.deitel.materialdesigncardviewsrecyclerdesign D/jdwp: processIncoming
11-09 19:53:10.281 1019-1042/com.deitel.materialdesigncardviewsrecyclerdesign D/jdwp: handlePacket : cmd=0x1, cmdSet=0xC7, len=0x14, id=0x400000CD, flags=0x0, dataLen=0x9
11-09 19:53:10.293 1019-1042/com.deitel.materialdesigncardviewsrecyclerdesign D/jdwp: sendBufferedRequest : len=0x34
11-09 19:53:10.772 1019-1042/com.deitel.materialdesigncardviewsrecyclerdesign D/jdwp: processIncoming
11-09 19:53:10.782 1019-1042/com.deitel.materialdesigncardviewsrecyclerdesign D/jdwp: handlePacket : cmd=0x1, cmdSet=0xC7, len=0x14, id=0x400000CE, flags=0x0, dataLen=0x9
11-09 19:53:10.782 1019-1042/com.deitel.materialdesigncardviewsrecyclerdesign D/jdwp: sendBufferedRequest : len=0x34
11-09 19:53:11.285 1019-1042/com.deitel.materialdesigncardviewsrecyclerdesign D/jdwp: processIncoming
11-09 19:53:11.290 1019-1042/com.deitel.materialdesigncardviewsrecyclerdesign D/jdwp: handlePacket : cmd=0x1, cmdSet=0xC7, len=0x14, id=0x400000CF, flags=0x0, dataLen=0x9
11-09 19:53:11.291 1019-1042/com.deitel.materialdesigncardviewsrecyclerdesign D/jdwp: sendBufferedRequest : len=0x34
11-09 19:53:11.771 1019-1042/com.deitel.materialdesigncardviewsrecyclerdesign D/jdwp: processIncoming
11-09 19:53:11.771 1019-1042/com.deitel.materialdesigncardviewsrecyclerdesign D/jdwp: handlePacket : cmd=0x1, cmdSet=0xC7, len=0x14, id=0x400000D0, flags=0x0, dataLen=0x9
11-09 19:53:11.780 1019-1042/com.deitel.materialdesigncardviewsrecyclerdesign D/jdwp: sendBufferedRequest : len=0x34
11-09 19:53:12.299 1019-1042/com.deitel.materialdesigncardviewsrecyclerdesign D/jdwp: processIncoming
11-09 19:53:12.305 1019-1042/com.deitel.materialdesigncardviewsrecyclerdesign D/jdwp: handlePacket : cmd=0x1, cmdSet=0xC7, len=0x14, id=0x400000D1, flags=0x0, dataLen=0x9
11-09 19:53:12.321 1019-1042/com.deitel.materialdesigncardviewsrecyclerdesign D/jdwp: sendBufferedRequest : len=0x34
11-09 19:53:12.773 1019-1042/com.deitel.materialdesigncardviewsrecyclerdesign D/jdwp: processIncoming
11-09 19:53:12.773 1019-1042/com.deitel.materialdesigncardviewsrecyclerdesign D/jdwp: handlePacket : cmd=0x1, cmdSet=0xC7, len=0x14, id=0x400000D2, flags=0x0, dataLen=0x9
11-09 19:53:12.773 1019-1042/com.deitel.materialdesigncardviewsrecyclerdesign D/jdwp: sendBufferedRequest : len=0x34
11-09 19:53:13.274 1019-1042/com.deitel.materialdesigncardviewsrecyclerdesign D/jdwp: processIncoming
11-09 19:53:13.274 1019-1042/com.deitel.materialdesigncardviewsrecyclerdesign D/jdwp: handlePacket : cmd=0x1, cmdSet=0xC7, len=0x14, id=0x400000D3, flags=0x0, dataLen=0x9
11-09 19:53:13.274 1019-1042/com.deitel.materialdesigncardviewsrecyclerdesign D/jdwp: sendBufferedRequest : len=0x34
11-09 19:53:13.775 1019-1042/com.deitel.materialdesigncardviewsrecyclerdesign D/jdwp: processIncoming
11-09 19:53:13.776 1019-1042/com.deitel.materialdesigncardviewsrecyclerdesign D/jdwp: handlePacket : cmd=0x1, cmdSet=0xC7, len=0x14, id=0x400000D4, flags=0x0, dataLen=0x9
11-09 19:53:13.779 1019-1042/com.deitel.materialdesigncardviewsrecyclerdesign D/jdwp: sendBufferedRequest : len=0x34
11-09 19:53:14.276 1019-1042/com.deitel.materialdesigncardviewsrecyclerdesign D/jdwp: processIncoming
11-09 19:53:14.276 1019-1042/com.deitel.materialdesigncardviewsrecyclerdesign D/jdwp: handlePacket : cmd=0x1, cmdSet=0xC7, len=0x14, id=0x400000D5, flags=0x0, dataLen=0x9
11-09 19:53:14.277 1019-1042/com.deitel.materialdesigncardviewsrecyclerdesign D/jdwp: sendBufferedRequest : len=0x34


I repeat it again, it works on Motorola MotoG but not on Huawei whic is a low version

Answer

Try to change the buildToolsVersion to 25.0.0
buildToolsVersion "25.0.0"

ViewAnimationUtils is added in Android 5.0, so try to :

if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        // to use ViewAnimationUtils
}