外部库不支持

时间:2016-02-04 05:27:06

标签: android android-layout android-activity android-library

我在项目中使用了一些外部库。早些时候工作正常,但现在已经停止工作了。

显示错误:

java.lang.RuntimeException: Unable to start activity ComponentInfo{app.aguai.medieazy/app.aguai.medieazy.activities.MyOrders}: android.view.InflateException: Binary XML file line #13: Error inflating class it.neokree.materialtabs.MaterialTabHost
                                                                    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2338)
                                                                    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2390)
                                                                    at android.app.ActivityThread.access$800(ActivityThread.java:151)
                                                                    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1321)
                                                                    at android.os.Handler.dispatchMessage(Handler.java:110)
                                                                    at android.os.Looper.loop(Looper.java:193)
                                                                    at android.app.ActivityThread.main(ActivityThread.java:5299)
                                                                    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:829)
                                                                    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:645)
                                                                    at dalvik.system.NativeStart.main(Native Method)
                                                                 Caused by: android.view.InflateException: Binary XML file line #13: Error inflating class it.neokree.materialtabs.MaterialTabHost
                                                                    at android.view.LayoutInflater.createView(LayoutInflater.java:620)
                                                                    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:696)
                                                                    at android.view.LayoutInflater.rInflate(LayoutInflater.java:755)
                                                                    at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
                                                                    at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
                                                                    at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
                                                                    at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:249)
                                                                    at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:106)
                                                                    at app.aguai.medieazy.activities.MyOrders.onCreate(MyOrders.java:32)
                                                                    at android.app.Activity.performCreate(Activity.java:5275)
                                                                    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1088)
                                                                    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2302)
                                                                    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2390) 
                                                                    at android.app.ActivityThread.access$800(ActivityThread.java:151) 
                                                                    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1321) 
                                                                    at android.os.Handler.dispatchMessage(Handler.java:110) 
                                                                    at android.os.Looper.loop(Looper.java:193) 
                                                                    at android.app.ActivityThread.main(ActivityThread.java:5299) 
                                                                    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:829) 
                                                                    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:645) 
                                                                    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:594)
                                                                    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:696) 
                                                                    at android.view.LayoutInflater.rInflate(LayoutInflater.java:755) 
                                                                    at android.view.LayoutInflater.inflate(LayoutInflater.java:492) 
                                                                    at android.view.LayoutInflater.inflate(LayoutInflater.java:397) 
                                                                    at android.view.LayoutInflater.inflate(LayoutInflater.java:353) 
                                                                    at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:249) 
                                                                    at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:106) 
                                                                    at app.aguai.medieazy.activities.MyOrders.onCreate(MyOrders.java:32) 
                                                                    at android.app.Activity.performCreate(Activity.java:5275) 
                                                                    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1088) 
                                                                    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2302) 
                                                                    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2390) 
                                                                    at android.app.ActivityThread.access$800(ActivityThread.java:151) 
                                                                    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1321) 
                                                                    at android.os.Handler.dispatchMessage(Handler.java:110) 
                                                                    at android.os.Looper.loop(Looper.java:193) 
                                                                    at android.app.ActivityThread.main(ActivityThread.java:5299) 
                                                                    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:829) 
                                                                    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:645) 
                                                                    at dalvik.system.NativeStart.main(Native Method) 
                                                                 Caused by: java.lang.NoClassDefFoundError: it.neokree.materialtabs.R$styleable
                                                                    at it.neokree.materialtabs.MaterialTabHost.<init>(MaterialTabHost.java:71)
                                                                    at it.neokree.materialtabs.MaterialTabHost.<init>(MaterialTabHost.java:57)
                                                                    at java.lang.reflect.Constructor.constructNative(Native Method) 
                                                                    at java.lang.reflect.Constructor.newInstance(Constructor.java:423) 
                                                                    at android.view.LayoutInflater.createView(LayoutInflater.java:594) 
                                                                    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:696) 
                                                                    at android.view.LayoutInflater.rInflate(LayoutInflater.java:755) 
                                                                    at android.view.LayoutInflater.inflate(LayoutInflater.java:492) 
                                                                    at android.view.LayoutInflater.inflate(LayoutInflater.java:397) 
                                                                    at android.view.LayoutInflater.inflate(LayoutInflater.java:353) 
                                                                    at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:249) 
                                                                    at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:106) 
                                                                    at app.aguai.medieazy.activities.MyOrders.onCreate(MyOrders.java:32) 
                                                                    at android.app.Activity.performCreate(Activity.java:5275) 
                                                                    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1088) 
                                                                    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2302) 
                                                                    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2390) 
                                                                    at android.app.ActivityThread.access$800(ActivityThread.java:151) 
                                                                    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1321) 
                                                                    at android.os.Handler.dispatchMessage(Handler.java:110) 
                                                                    at android.os.Looper.loop(Looper.java:193) 
                                                                    at android.app.ActivityThread.main(ActivityThread.java:5299) 
                                                                    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:829) 
                                                                    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:645) 
                                                                    at dalvik.system.NativeStart.main(Native Method) 

错误行仅为setContentView(R.layout,MYLAYOUT)行。

我的build.gradle是:

 apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
android {
    compileSdkVersion 22
    buildToolsVersion "22.0.1"

    defaultConfig {
        applicationId "app.aguai.medieazy"
        minSdkVersion 15
        targetSdkVersion 22
        versionCode 25
        versionName "2.0"
        multiDexEnabled true
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }

    }
    packagingOptions {
        exclude 'META-INF/DEPENDENCIES'
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/license.txt'
        exclude 'META-INF/NOTICE'
        exclude 'META-INF/NOTICE.txt'
        exclude 'META-INF/notice.txt'
        exclude 'META-INF/ASL2.0'
    }
}


dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile files('libs/httpclient-4.3.6.jar')
    compile files('libs/achartengine-1.0.0.jar')
    compile files('libs/httpcore-4.3.3.jar')
    compile files('libs/httpmime-4.3.6.jar')
    compile files('libs/FlurryAnalytics-5.5.0.jar')
    compile 'com.android.support:appcompat-v7:22.0.1'
    compile 'it.neokree:MaterialTabs:0.11'
    compile 'com.google.android.gms:play-services:8.3.0'
    compile 'com.android.support:design:22.2.1'
    compile 'com.github.blackfizz:eazegraph:1.2.5l@aar'
    compile 'com.appvirality:AppviralityUI:1.1.18+'
    compile 'cn.pedant.sweetalert:library:1.3'
    compile 'com.nineoldandroids:library:2.4.0'
    /*compile 'com.moengage:moe-android-sdk:5.3.27'*/
    compile project(':gestureimageview')
   /* compile 'com.facebook.android:facebook-android-sdk:4.6.0'
    compile 'com.google.android.gms:play-services-auth:8.3.0'*/

}

material-tabs xml代码:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">

<android.support.v7.widget.Toolbar
    android:id="@+id/toolbar_my_orders"
    android:layout_width="match_parent"
    android:layout_height="?attr/actionBarSize"
    android:background="@color/theme"
    />

<it.neokree.materialtabs.MaterialTabHost
    android:id="@+id/tabHost"
    android:layout_width="match_parent"
    android:layout_height="48dp"
    android:layout_marginTop="2dp"
    android:layout_below="@+id/toolbar_my_orders"
    app:primaryColor="@color/theme"
    app:accentColor="#ffffff" />

<android.support.v4.view.ViewPager
    android:id="@+id/pager"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_below="@+id/tabHost" />
</RelativeLayout>

我无法找出问题所在。

3 个答案:

答案 0 :(得分:1)

我找出原因,但我仍然不理解。

早些时候我使用的是compile 'com.google.android.gms:play-services:8.1.0'

然后我将google-play-services更新为compile 'com.google.android.gms:play-services:8.3.0'

因此从8.1到8.3的这种变化导致了问题。 我把它改回了8.3,它又开始工作了。 非常感谢你们所有人......我非常感谢你的帮助。

答案 1 :(得分:0)

尝试在您的graddle文件中添加编译项目(':gifview'),并在布局XML中检查包名是否正确。

答案 2 :(得分:0)

Caused by: java.lang.NoClassDefFoundError: it.neokree.materialtabs.R$styleable

尝试按照说明MaterialTabs