【问题标题】:java.lang.NoSuchMethodError: No static method setFactory2(Landroid/view/LayoutInflater;Landroid/view/LayoutInflater$Factory2;)java.lang.NoSuchMethodError: 没有静态方法 setFactory2(Landroid/view/LayoutInflater;Landroid/view/LayoutInflater$Factory2;)
【发布时间】:2017-11-28 02:21:20
【问题描述】:

好的,这很奇怪。当我在模拟器中运行应用程序时,我的 logcat 突然崩溃了,之前我从未拥有过它,而且自从我上次在模拟器中运行它以来,我没有对我的应用程序进行任何更改几周前,它正在工作。

这是完整的错误:

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)

我尝试了 Google 搜索,但在其他任何地方都找不到此崩溃错误。我尝试重新安装 Android Studio,但没有帮助。我在 stackoverflow 上发现的一些“类似”错误说它可能与 appcompat 版本有关,但我尝试了不同的版本但没有运气。这是我的 gradle 编译:

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'

}

logcat 错误说这行是我的 SplashActivity.java 文件的原因,但自从我 2 年前最初创建应用程序以来,我根本没有修改过这个 java 文件。

super.onCreate(savedInstanceState);

【问题讨论】:

    标签: java android crash


    【解决方案1】:

    可能是由于您的旧依赖版本而发生此错误,请尝试升级它们。如果在此之后问题仍然存在,请删除您的启动活动代码。

    你也应该尝试升级你的版本。

    【讨论】:

      【解决方案2】:

      这不是确切的答案,但我有同样的问题,我通过更改依赖版本解决了它,您的问题可能相似,因此您可以更改外部依赖版本并查看您的问题是否已解决。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2019-09-05
        • 2018-04-10
        • 2023-03-02
        • 1970-01-01
        • 2017-11-13
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多