致命异常:主要java.lang.NoClassDefFoundError:android.support.v7.internal.widget.TintManager

时间:2015-12-01 08:05:28

标签: android android-fragments android-intent android-activity

我在运行项目时遇到错误。我只是关注这个tutorial并在我的项目中使用它。

我的代码在教程

中完全相同
btnNext.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View view) {
                Intent i = new Intent(MainActivity.this, MainEventActivity.class);
                startActivity(i);
                finish();
            }
        });

我这样调用MainEventActivity:

12-01 08:00:29.903  22530-22530/com.erlawkward.albarol.eventlocatorapp
E/AndroidRuntime﹕ FATAL EXCEPTION: main
    java.lang.NoClassDefFoundError: android.support.v7.internal.widget.TintManager
            at android.support.design.widget.TabLayout$TabView.<init>(TabLayout.java:1145)
            at android.support.design.widget.TabLayout.createTabView(TabLayout.java:635)
            at android.support.design.widget.TabLayout.addTabView(TabLayout.java:669)
            at android.support.design.widget.TabLayout.addTab(TabLayout.java:365)
            at android.support.design.widget.TabLayout.addTab(TabLayout.java:340)
            at android.support.design.widget.TabLayout.setTabsFromPagerAdapter(TabLayout.java:624)
            at android.support.design.widget.TabLayout.setupWithViewPager(TabLayout.java:595)
            at com.erlawkward.albarol.eventlocatorapp.activity.activity.MainEventActivity.onCreate(MainEventActivity.java:41)
            at android.app.Activity.performCreate(Activity.java:5104)
            at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144)
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
            at android.app.ActivityThread.access$600(ActivityThread.java:141)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
            at android.os.Handler.dispatchMessage(Handler.java:99)
            at android.os.Looper.loop(Looper.java:137)
            at android.app.ActivityThread.main(ActivityThread.java:5041)
            at java.lang.reflect.Method.invokeNative(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:511)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
            at dalvik.system.NativeStart.main(Native Method)

我的错误日志:

    tabLayout.setupWithViewPager(viewPager);

错误在这一行:

std::getline(std::cin, row)

9 个答案:

答案 0 :(得分:56)

所有支持库必须是相同的版本。尝试将appcompat-v7和support-v4更改为23.0.1或设计为23.1.1

答案 1 :(得分:4)

如果您下载更高版本的支持库,即使您定义为23.1.1,gradle也会使用高级版本静默

您可以查看gradlew app:dependencies -q是否使用了正确的版本。

要修复其上层版本切换,请将force = true设置为所有支持库,如下所示。

compile ('com.android.support:support-v4:23.1.1'){
    force = true;
}
compile ('com.android.support:appcompat-v7:23.1.1'){
    force = true;
}
compile ('com.android.support:design:23.1.1'){
    force = true;
}
compile ('com.android.support:cardview-v7:23.1.1'){
    force = true;
}
compile ('com.android.support:recyclerview-v7:23.1.1'){
    force = true;
}

答案 2 :(得分:2)

我通过改变我的依赖来解决类似的问题:

编译'com.android.support:design:23.1.1'

编译'com.android.support:design:23.+'

最后我的单位是这样的:

compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:support-v4:23.0.0'
compile 'com.android.support:cardview-v7:23.0.0'
compile 'com.android.support:design:23.+'

答案 3 :(得分:1)

我认为这是因为lib&#34; compile&#39; com.mcxiaoke.volley:library-aaa:1.0.0&#39; &#34;在您的gradle中使用,包括不同版本的&#39; com.android.support:&#39;在你的gradle中定义。

所以你应该这样做:

<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet" />

<div class="container">
  <div class="row">
    <div class="col-xs-4">
      <div class="panel panel-default">
        <div class="panel-heading">
          <h2>People</h2>
        </div>
        <ul class="list-group">
          <li class="list-group-item">
            Results in death or permanent disability of employees.
          </li>
          <li class="list-group-item">
            Results in partial permanent disability, injuries or illness of 3 employees or more.</li>
          <li class="list-group-item">
            Injury or illness resulting in one or more work days lost.
          </li>
          <li class="list-group-item">
            Minor illness or injury to employees resulting in one day's absence.</li>
          <li class="list-group-item">Minor illness or injury to employees with no absent days.</li>
        </ul>
      </div>
    </div>
    <div class="col-xs-4">
      <div class="panel panel-default">
        <div class="panel-heading">
          <h2>Environment</h2>
        </div>
        <ul class="list-group">
          <li class="list-group-item">Irreversible environmental damage.</li>
          <li class="list-group-item">Reversible environment damage.</li>
          <li class="list-group-item">Mitigable environment damage where restoration activities can be done.</li>
          <li class="list-group-item">Little environmental damage.</li>
          <li class="list-group-item">Minimal environmental damage.</li>
        </ul>
      </div>
    </div>
    <div class="col-xs-4">
      <div class="panel panel-default">
        <div class="panel-heading">
          <h2>Financial</h2>
        </div>
        <ul class="list-group">
          <li class="list-group-item">Amount of loss: 1M or more.</li>
          <li class="list-group-item">Amount of loss: 200,000 but less than 1M.></li>
          <li class="list-group-item">Amount of loss: 10,000 but less than 200,000.</li>
          <li class="list-group-item">Amount of loss: 5,000 but les than 10,000.</li>
          <li class="list-group-item">Amount of loss: Less than 5,000.</li>
        </ul>
      </div>
    </div>
  </div>
</div>

答案 4 :(得分:1)

我通过添加编译'com.android.support:design:23.+'解决了这个问题,尽管我的支持依赖关系是相似的

之前

   compile 'com.android.support:appcompat-v7:23.1.1'
   compile 'com.android.support:support-v4:23.1.1' 
   compile 'com.android.support:design:23.1.1'

之后 - 这对我有用

   compile 'com.android.support:appcompat-v7:23.1.1'
   compile 'com.android.support:support-v4:23.1.1' 
   compile 'com.android.support:design:23.+'

答案 5 :(得分:1)

compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.android.support:design:23.4.0'

您必须使用与上述相同的版本

答案 6 :(得分:0)

尝试使用相同的verion设置所有支持lib,例如

compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:recyclerview-v7:23.1.1'
compile 'com.android.support:design:23.1.1'

答案 7 :(得分:0)

似乎他们已经用AppCompatDrawableManager取代了TintManager。

至少我确定我在任何地方都使用了相同的支持库版本(24.0.0),直到我刚刚替换了TintManager与AppCompatDrawableManager一起使用的所有地方时它仍然无效。

here AppCompatDrawableManager仍标记TintManager。

答案 8 :(得分:0)

编译'com.android.support:appcompat-v7:23.2.0' 编译'com.android.support:design:23.2.0' 编译'com.android.support:recyclerview-v7:23.2.0' 编译'com.android.support:support-v4:23.2.0' 编译'com.android.support:cardview-v7:23.2.0'