java.lang.NoSuchMethodError: No static method setFactory2(Landroid/view/LayoutInflater;Landroid/view/LayoutInflater$Factory2;)

Viewed 1096

Ok this is very weird. I'm suddenly getting this crash in my logcat when I run the app in the emulator, when before I've never had it, and I've not made any changes to my app since the last time I ran it in the emulator a few weeks ago and it was working.

Here's the full error:

java.lang.NoSuchMethodError: No static method setFactory2(Landroid/view/LayoutInflater;Landroid/view/LayoutInflater$Factory2;)V in class Landroid/support/v4/view/LayoutInflaterCompat; or its super classes (declaration of 'android.support.v4.view.LayoutInflaterCompat' appears in /data/app/com.pa.myapp-2/base.apk)
    at android.support.v7.app.AppCompatDelegateImplV9.installViewFactory(AppCompatDelegateImplV9.java:1060)
    at android.support.v7.app.AppCompatActivity.onCreate(AppCompatActivity.java:71)
    at com.pa.myapp.SplashActivity.onCreate(SplashActivity.java:36)
    at android.app.Activity.performCreate(Activity.java:6662)
    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1118)
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2599)
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2707)
    at android.app.ActivityThread.-wrap12(ActivityThread.java)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1460)
    at android.os.Handler.dispatchMessage(Handler.java:102)
    at android.os.Looper.loop(Looper.java:154)
    at android.app.ActivityThread.main(ActivityThread.java:6077)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:866)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:756)

I tried Google searching but can't find this crash error anywhere else. I tried reinstalling Android Studio but it didn't help. Some "similar" errors I've found on stackoverflow says it may be related to appcompat version, but I've tried different versions with no luck. Here's my gradle compiles:

dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
    exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:multidex:1.0.1'
compile 'com.github.johnhiott:DarkSkyApi:v0.1.5'
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support:design:25.3.1'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.google.android.gms:play-services-maps:11.0.4'
compile 'com.google.android.gms:play-services-ads:11.0.4'
compile 'com.google.code.gson:gson:2.7'
compile 'com.sickmartian.calendarview:calendarview:1.0.0'
compile 'com.squareup.retrofit2:converter-scalars:2.2.0'
compile 'com.squareup.retrofit2:retrofit:2.2.0'
compile 'com.anjlab.android.iab.v3:library:1.0.38'
compile 'com.google.maps.android:android-maps-utils:0.5'
compile 'com.github.robertsimoes:Shareable:0.1.0'
compile 'com.zendesk:sdk:1.10.0.1'
compile 'com.zopim.android:sdk:1.3.3.1'
compile 'com.google.firebase:firebase-messaging:11.0.4'
compile 'com.google.firebase:firebase-core:11.0.4'
testCompile 'junit:junit:4.12'
compile 'com.github.amlcurran.showcaseview:library:5.4.3'
compile 'com.codemybrainsout.rating:ratingdialog:1.0.8'

}

The logcat error says this line is to blame in my SplashActivity.java file, but I haven't modified this java file at all since I originally created the app 2 years ago.

super.onCreate(savedInstanceState);
2 Answers

This is not the exact answer but I have the same issue and I resolved it by changing the dependency versions, your issue could be similar so you can change the external dependencies version and see if your issue is resolved or not.

may be this error occurs because of your old dependency versions, try upgrading them. If the problem persist even after that please drop your splash activity code.

Also you should try upgrading your version.

Related