0

The app crash on startup this is the crash log:

 java.lang.RuntimeException: Unable to start activity ComponentInfo{com.test/com.test.activities.SplashActivity}: android.view.InflateException: Binary XML file line #10: Error inflating class com.test.ui.shimmer.ShimmerTextView
            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2447)
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2507)
            at android.app.ActivityThread.access$900(ActivityThread.java:172)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1308)
            at android.os.Handler.dispatchMessage(Handler.java:102)
            at android.os.Looper.loop(Looper.java:146)
            at android.app.ActivityThread.main(ActivityThread.java:5692)
            at java.lang.reflect.Method.invokeNative(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:515)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1291)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1107)
            at dalvik.system.NativeStart.main(Native Method)
     Caused by: android.view.InflateException: Binary XML file line #10: Error inflating class com.test.ui.shimmer.ShimmerTextView
            at android.view.LayoutInflater.createView(LayoutInflater.java:626)
            at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:702)
            at android.view.LayoutInflater.rInflate(LayoutInflater.java:761)
            at android.view.LayoutInflater.inflate(LayoutInflater.java:498)
            at android.view.LayoutInflater.inflate(LayoutInflater.java:398)
            at android.view.LayoutInflater.inflate(LayoutInflater.java:354)
            at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:350)
            at android.app.Activity.setContentView(Activity.java:2059)
            at com.framework.base.fragment.base.MCFragmentActivity.setContentView(MCFragmentActivity.java:160)
            at com.test.activities.SplashActivity.setOrientation(SplashActivity.java:50)
            at com.test.activities.SplashActivity.onCreate(SplashActivity.java:42)
            at android.app.Activity.performCreate(Activity.java:5541)
            at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1093)
            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2411)
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2507)
            at android.app.ActivityThread.access$900(ActivityThread.java:172)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1308)
            at android.os.Handler.dispatchMessage(Handler.java:102)
            at android.os.Looper.loop(Looper.java:146)
            at android.app.ActivityThread.main(ActivityThread.java:5692)
            at java.lang.reflect.Method.invokeNative(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:515)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1291)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1107)
            at dalvik.system.NativeStart.main(Native Method)
     Caused by: java.lang.reflect.InvocationTargetException
            at java.lang.reflect.Constructor.constructNative(Native Method)
            at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
            at android.view.LayoutInflater.createView(LayoutInflater.java:600)
            at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:702)
            at android.view.LayoutInflater.rInflate(LayoutInflater.java:761)
            at android.view.LayoutInflater.inflate(LayoutInflater.java:498)
            at android.view.LayoutInflater.inflate(LayoutInflater.java:398)
            at android.view.LayoutInflater.inflate(LayoutInflater.java:354)
            at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:350)
            at android.app.Activity.setContentView(Activity.java:2059)
            at com.framework.base.fragment.base.MCFragmentActivity.setContentView(MCFragmentActivity.java:160)
            at com.test.activities.SplashActivity.setOrientation(SplashActivity.java:50)
            at com.test.activities.SplashActivity.onCreate(SplashActivity.java:42)
            at android.app.Activity.performCreate(Activity.java:5541)
            at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1093)
            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2411)
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2507)
            at android.app.ActivityThread.access$900(ActivityThread.java:172)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1308)
            at android.os.Handler.dispatchMessage(Handler.java:102)
            at android.os.Looper.loop(Looper.java:146)
            at android.app.ActivityThread.main(ActivityThread.java:5692)
            at java.lang.reflect.Method.invokeNative(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:515)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1291)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1107)
            at dalvik.system.NativeStart.main(Native Method)
     Caused by: java.lang.NoClassDefFoundError: com.test.ui.shimmer.ShimmerViewHelper
            at com.test.ui.shimmer.ShimmerTextView.<init>(ShimmerTextView.java:33)
            at java.lang.reflect.Constructor.constructNative(Native Method)
            at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
            at android.view.LayoutInflater.createView(LayoutInflater.java:600)
            at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:702)
            at android.view.LayoutInflater.rInflate(LayoutInflater.java:761)
            at android.view.LayoutInflater.inflate(LayoutInflater.java:498)
            at android.view.LayoutInflater.inflate(LayoutInflater.java:398)
            at android.view.LayoutInflater.inflate(LayoutInflater.java:354)
            at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:350)
            at android.app.Activity.setContentView(Activity.java:2059)
            at com.framework.base.fragment.base.MCFragmentActivity.setContentView(MCFragmentActivity.java:160)
            at com.test.activities.SplashActivity.setOrientation(SplashActivity.java:50)
            at com.test.activities.SplashActivity.onCreate(SplashActivity.java:42)
            at android.app.Activity.performCreate(Activity.java:5541)
            at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1093)
            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2411)
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2507)
            at android.app.ActivityThread.access$900(ActivityThread.java:172)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1308)
            at android.os.Handler.dispatchMessage(Handler.java:102)
            at android.os.Looper.loop(Looper.java:146)
            at android.app.ActivityThread.main(ActivityThread.java:5692)
            at java.lang.reflect.Method.invokeNative(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:515)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1291)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1107)
            at dalvik.system.NativeStart.main(Native Method)

I've done the same thing in this link. It works on Android 5.0 and above. But if I try this under android 5.0 devices, I got this error log above.

In my SplashActivity:

@Override
 public void onCreate(Bundle savedInstanceState) {
     super.onCreate(savedInstanceState);
     FacebookSdk.sdkInitialize(getApplicationContext());
     // Initialize the SDK before executing any other operations,
     // especially, if you're using Facebook UI elements.
} 

In build.gradle:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 19
    buildToolsVersion "21.1.2"
    defaultConfig {
        applicationId "com.test"
        minSdkVersion 15
        targetSdkVersion 19
        multiDexEnabled true
    }

    dexOptions {
        incremental true
        javaMaxHeapSize "2048M"
    }

    packagingOptions {
        exclude 'META-INF/LICENSE.txt'
//        exclude 'META-INF/NOTICE.txt
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/NOTICE'
        exclude 'META-INF/DEPENDENCIES'
        exclude 'META-INF/ASL2.0'
    }
    lintOptions {
        checkReleaseBuilds false
    }
    productFlavors {
    }
}

dependencies {
    compile 'com.google.code.gson:gson:2.2.4'
    compile files('libs/android-async-http-1.4.4.jar')
    compile files('libs/DP4Java.jar')
    compile files('libs/SecureStorageSDK.jar')
    compile files('libs/UtilitiesSDK.jar')
    compile 'net.lingala.zip4j:zip4j:1.3.2'
    compile 'com.facebook.android:facebook-android-sdk:4.5.0'
}
apply from: 'rollo.gradle'

In (top-level)app build.gradle:

buildscript {
    repositories {
        jcenter()
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:1.2.3'
    }
}

allprojects {
    repositories {
        jcenter()
        mavenCentral()
    }
}

In manifest:

<meta-data android:name="com.facebook.sdk.ApplicationId"
                   android:value="@string/facebook_app_id"/>

EDIT: I know that there is nothing wrong in my ShimmerTextView. If I remove facebook sdk from build.gradle, I don't get this error log. Everything works like a charm. There is some kind of bug that I could not figure. Maybe I'm doing something wrong. Please help me to solve this issue. Thanks.

Orcun Sevsay
  • 1,310
  • 1
  • 14
  • 44
  • The problem definitely seems to be in the ShimmerTextView, the class ShimmerTextView cannot be found. Check your layout xml and ensure that the package name and class name are correct/identical in your layout file for pre android 5.0. The problem is the class specified in the xml cannot be found. – griffinjm Aug 17 '15 at 15:52

1 Answers1

0

Do you have multiple layout xml, one for >5.0 versions and one for <5.0 versions? Check that the full package name of your custom view is spelled correctly in all xml files. The "Error inflating class com.test.ui.shimmer.ShimmerTextView" indicates that the package name is incorrect or incomplete.

EDIT: Actually it seems that the ShimmerViewHelper cannot be found in the init of the ShimmerTextView, is that referenced correctly? java.lang.NoClassDefFoundError: com.test.ui.shimmer.ShimmerViewHelper

griffinjm
  • 493
  • 2
  • 10
  • No. There is only one layout. This issue is not about ShimmerTextView. If I remove shimmer animation, some other layout gives same error. On the other hand >=5.0 devices works perfectly, no error at all. Other interesting thing is if I remove facebook sdk, this (ShimmerTextView) error does not occur. – Orcun Sevsay Aug 17 '15 at 16:23
  • Something triggers `java.lang.NoClassDefFoundError: com.test.ui.shimmer.ShimmerViewHelper` error when I Add Facebook sdk to my build.gradle. It happens under Android lollipop devices. (Kitkat and lower) If I don't use facebook sdk, everything seems fine, no crashes. Maybe Facebook sdk cause this problem but I don't know why. – Orcun Sevsay Aug 18 '15 at 06:32
  • That's a weird one. Are you adding any facebook UI elements to that layout? – griffinjm Aug 18 '15 at 08:58
  • No I don't use any facebook ui elements in layout's – Orcun Sevsay Aug 18 '15 at 09:15