當我運行Mainactivity
我收到錯誤並在content_main.xml
顯示錯誤(Error inflating class com.algolia.instantsearch.ui.views.Hits
)。我無法解決它。我也改變了風格。請幫幫我。在啓動活動時出現錯誤android
10-29 16:26:35.405 20712-20712/com.google.tho.oe E/dalvikvm: Could not find class 'android.graphics.drawable.RippleDrawable', referenced from method android.support.v7.widget.AppCompatImageHelper.hasOverlappingRendering
10-29 16:26:35.405 20712-20712/com.google.tho.oe W/dalvikvm: VFY: unable to resolve instanceof 354 (Landroid/graphics/drawable/RippleDrawable;) in Landroid/support/v7/widget/AppCompatImageHelper;
10-29 16:26:35.415 20712-20712/com.google.tho.oe D/dalvikvm: VFY: replacing opcode 0x20 at 0x000c
10-29 16:26:36.055 20712-20712/com.google.tho.oe D/dalvikvm: GC_FOR_ALLOC freed 1340K, 26% free 11327K/15299K, paused 115ms, total 148ms
10-29 16:26:36.655 20712-20712/com.google.tho.oe I/dalvikvm: Could not find method org.greenrobot.eventbus.EventBus.getDefault, referenced from method com.algolia.instantsearch.ui.views.Hits.<init>
10-29 16:26:36.665 20712-20712/com.google.tho.oe W/dalvikvm: VFY: unable to resolve static method 64964: Lorg/greenrobot/eventbus/EventBus;.getDefault()Lorg/greenrobot/eventbus/EventBus;
10-29 16:26:36.665 20712-20712/com.google.tho.oe D/dalvikvm: VFY: replacing opcode 0x71 at 0x00a6
10-29 16:26:36.675 20712-20712/com.google.tho.oe I/dalvikvm: Could not find method android.app.Activity.isDestroyed, referenced from method com.algolia.instantsearch.ui.views.Hits$HitsAdapter.onBindViewHolder
10-29 16:26:36.715 20712-20712/com.google.tho.oe W/dalvikvm: VFY: unable to resolve virtual method 111: Landroid/app/Activity;.isDestroyed()Z
10-29 16:26:36.715 20712-20712/com.google.tho.oe D/dalvikvm: VFY: replacing opcode 0x6e at 0x00c4
10-29 16:26:36.745 20712-20712/com.google.tho.oe D/AndroidRuntime: Shutting down VM
10-29 16:26:36.745 20712-20712/com.google.tho.oe W/dalvikvm: threadid=1: thread exiting with uncaught exception (group=0x40e30438)
10-29 16:26:36.885 20712-20712/com.google.tho.oe E/AndroidRuntime: FATAL EXCEPTION: main
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.google.tho.oe/com.google.tho.oe.MainActivity}: android.view.InflateException: Binary XML file line #27: Error inflating class com.algolia.instantsearch.ui.views.Hits
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2114)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2139)
at android.app.ActivityThread.access$700(ActivityThread.java:143)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1241)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4960)
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:1038)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:805)
at dalvik.system.NativeStart.main(Native Method)
Caused by: android.view.InflateException: Binary XML file line #27: Error inflating class com.algolia.instantsearch.ui.views.Hits
at android.view.LayoutInflater.createView(LayoutInflater.java:619)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:693)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:752)
at android.view.LayoutInflater.inflate(LayoutInflater.java:495)
at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:292)
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)
at com.google.tho.oe.MainActivity.onCreate(MainActivity.java:63)
at android.app.Activity.performCreate(Activity.java:5203)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1094)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2078)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2139)
at android.app.ActivityThread.access$700(ActivityThread.java:143)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1241)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4960)
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:1038)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:805)
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:417)
at android.view.LayoutInflater.createView(LayoutInflater.java:593)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:693)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:752)
at android.view.LayoutInflater.inflate(LayoutInflater.java:495)
at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:292)
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)
at com.google.tho.oe.MainActivity.onCreate(MainActivity.java:63)
at android.app.Activity.performCreate(Activity.java:5203)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1094)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2078)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2139)
at android.app.ActivityThread.access$700(ActivityThread.java:143)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1241)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4960)
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:1038)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:805)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.NoClassDefFoundError: org.greenrobot.eventbus.EventBus
at com.algolia.instantsearch.ui.views.Hits.<init>(Hits.java:162)
at java.lang.reflect.Constructor.constructNative(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:417)
at android.view.LayoutInflater.createView(LayoutInflater.java:593)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:693)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:752)
at android.view.LayoutInflater.inflate(LayoutInflater.java:495)
at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:292)
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)
at com.google.tho.oe.MainActivity.onCreate(MainActivity.java:63)
at android.app.Activity.performCreate(Activity.java:5203)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1094)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2078)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2139)
at android.app.ActivityThread.access$700(ActivityThread.java:143)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1241)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4960)
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:1038)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:805)
at dalvik.system.NativeStart.main(Native Method)
style.xml
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.NoActionBar">
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
<item name="drawerArrowStyle">@style/DrawerHamburgerStyle</item>
<item name="actionBarWidgetTheme">@style/MyActionBarWidgetTheme</item>
</style>
activity_main.xml中
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="#fff"
android:fitsSystemWindows="true"
tools:openDrawer="start"
tools:context="com.google.tho.oes.MainActivity">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:orientation="horizontal"
android:background="@drawable/side_nav_bar_four">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="@android:color/transparent"
android:id="@+id/temp">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:titleTextColor="#fff"
/>
</android.support.design.widget.AppBarLayout>
</LinearLayout>
<com.algolia.instantsearch.ui.views.SearchBox
android:id="@+id/search_barer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/side_nav_bar_four"
android:searchHintIcon="@drawable/common_google_signin_btn_icon_dark"/>
<include layout="@layout/content_main"
/>
</LinearLayout>
contain_main.xml
我的應用程序的搖籃文件:模塊的
android {
compileSdkVersion 25
buildToolsVersion '25.0.3'
defaultConfig {
applicationId "com.google.tho.oe"
minSdkVersion 16
targetSdkVersion 25
versionCode 1
versionName "1.0"
multiDexEnabled true
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
搖籃文件:
android {
dataBinding {
enabled true
}
compileSdkVersion 25
buildToolsVersion '25.0.2'
defaultConfig {
minSdkVersion 16
targetSdkVersion 25
versionCode 1
versionName project.ext.VERSION
consumerProguardFiles "proguard-rules.pro"
}
你可以試試[這](https://stackoverflow.com/questions/28857860/classnotfoundexception-didnt-find-class-android- os-persistablebundle-otto-an#answer-28858364)。 – KeLiuyue
不,我得到同樣的錯誤。 –
請幫幫我我患了一個多星期。 –