2016-08-16 130 views
4

當在平板電腦上運行我的應用程序而不是在手機上時(我以前從未嘗試過),當我開始某個活動時收到此堆棧跟蹤。我查看了該活動的.xml文件以查找運行時可能爲0的任何內容,並替換了想到的所有內容(例如?attr/actionBarSize),但它沒有改變任何內容。我最大的問題:堆棧跟蹤太長,無法找到例外的原點。任何想法如何找到我的錯誤? PS:我不知道該活動的任何位圖,這使得它更加混亂IllegalArgumentException:活動中的寬度和高度必須大於0

java.lang.IllegalArgumentException: width and height must be > 0                   
    at android.graphics.Bitmap.createBitmap(Bitmap.java:933)                   
    at android.graphics.Bitmap.createBitmap(Bitmap.java:912)                   
    at android.graphics.Bitmap.createBitmap(Bitmap.java:879)                  
    at android.graphics.drawable.VectorDrawable$VectorDrawableState.createCachedBitmapIfNeeded(VectorDrawable.java:711) 
    at android.graphics.drawable.VectorDrawable.draw(VectorDrawable.java:278) 
    at android.graphics.drawable.DrawableContainer.draw(DrawableContainer.java:76) 
    at android.widget.ExpandableListView.dispatchDraw(ExpandableListView.java:460) 
    at android.view.View.draw(View.java:16272) 
    at android.widget.AbsListView.draw(AbsListView.java:5983) 
    at android.view.View.updateDisplayListIfDirty(View.java:15192) 
    at android.view.View.getDisplayList(View.java:15215) 
    at android.view.View.draw(View.java:15990) 
    at android.view.ViewGroup.drawChild(ViewGroup.java:3708) 
    at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3502) 
    at android.view.View.draw(View.java:16272) 
    at android.view.View.updateDisplayListIfDirty(View.java:15192) 
    at android.view.View.getDisplayList(View.java:15215) 
    at android.view.View.draw(View.java:15990) 
    at android.view.ViewGroup.drawChild(ViewGroup.java:3708) 
    at android.support.design.widget.CoordinatorLayout.drawChild(CoordinatorLayout.java:1127) 
    at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3502) 
    at android.view.View.updateDisplayListIfDirty(View.java:15187) 
    at android.view.View.getDisplayList(View.java:15215) 
    at android.view.View.draw(View.java:15990) 
    at android.view.ViewGroup.drawChild(ViewGroup.java:3708) 
    at android.support.v4.widget.DrawerLayout.drawChild(DrawerLayout.java:1369) 
    at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3502) 
    at android.view.View.draw(View.java:16272) 
    at android.view.View.updateDisplayListIfDirty(View.java:15192) 
    at android.view.View.getDisplayList(View.java:15215) 
    at android.view.View.draw(View.java:15990) 
    at android.view.ViewGroup.drawChild(ViewGroup.java:3708) 
    at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3502) 
    at android.view.View.updateDisplayListIfDirty(View.java:15187) 
    at android.view.View.getDisplayList(View.java:15215) 
    at android.view.View.draw(View.java:15990) 
    at android.view.ViewGroup.drawChild(ViewGroup.java:3708) 
    at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3502) 
    at android.view.View.updateDisplayListIfDirty(View.java:15187) 
    at android.view.View.getDisplayList(View.java:15215) 
    at android.view.View.draw(View.java:15990) 
    at android.view.ViewGroup.drawChild(ViewGroup.java:3708) 
    at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3502) 
    at android.view.View.updateDisplayListIfDirty(View.java:15187) 
    at android.view.View.getDisplayList(View.java:15215) 
    at android.view.View.draw(View.java:15990) 
    at android.view.ViewGroup.drawChild(ViewGroup.java:3708) 
    at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3502) 
    at android.view.View.updateDisplayListIfDirty(View.java:15187) 
    at android.view.View.getDisplayList(View.java:15215) 
    at android.view.View.draw(View.java:15990) 
    at android.view.ViewGroup.drawChild(ViewGroup.java:3708) 
    at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3502) 
    at android.view.View.draw(View.java:16272) 
    at android.widget.FrameLayout.draw(FrameLayout.java:592) 
    at com.android.internal.policy.impl.PhoneWindow$DecorView.draw(PhoneWindow.java:3047) 
    at android.view.View.updateDisplayListIfDirty(View.java:15192) 
    at android.view.View.getDisplayList(View.java:15215) 
    at android.view.ThreadedRenderer.updateViewTreeDisplayList(ThreadedRenderer.java:307) 
    at android.view.ThreadedRenderer.updateRootDisplayList(ThreadedRenderer.java:313) 
    at android.view.ThreadedRenderer.draw(ThreadedRenderer.java:352) 
    at android.view.ViewRootImpl.draw(ViewRootImpl.java:2815) 
    at android.view.ViewRootImpl.performDraw(ViewRootImpl.java:2638) 
    at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2226) 
    at android.view.ViewRootImpl.doTraversal(ViewRootIm 

好了,這裏是我的depenencies從gradle這個,我現在使用的24個庫,但錯誤堅持...

dependencies { 
    compile fileTree(include: ['*.jar'], dir: 'libs') 
    wearApp project(':wear') 
    testCompile 'junit:junit:4.12' 
    compile 'com.google.android.gms:play-services:9.4.0' 
    compile 'org.postgresql:postgresql:9.4.1208.jre7' 
    compile 'com.google.android.gms:play-services-ads:9.4.0' 
    compile 'com.google.android.gms:play-services-identity:9.4.0' 
    compile 'com.google.android.gms:play-services-gcm:9.4.0' 
    compile 'com.android.support:multidex:1.0.0' 
    compile 'com.google.android.support:wearable:1.4.0' 
    compile 'com.google.firebase:firebase-core:9.4.0' 
    compile 'com.google.firebase:firebase-crash:9.4.0' 
    compile 'com.google.firebase:firebase-messaging:9.4.0' 
    compile 'com.android.support:support-v4:24.2.1' 
    compile 'com.android.support:recyclerview-v7:24.2.1' 
    compile 'com.android.support:design:24.2.1' 
    compile 'com.android.support:palette-v7:24.2.1' 
} 

這裏來的.XML代碼爲崩潰的活動:像你可能要使用的支持庫

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout 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:background="@color/colorPrimary" 
    app:layout_behavior="@string/appbar_scrolling_view_behavior" 
    tools:context="org.pbdevelopement.cineapp.SpielplanActivity" 
    tools:showIn="@layout/app_bar_spielplan"> 

    <ExpandableListView 
     android:id="@+id/spielplan_list_view" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:divider="@color/Grey600" 
     android:dividerHeight="1dp" 
     android:groupIndicator="@drawable/group_selector_icon" 
     android:layout_alignParentStart="true" 
     android:layout_alignParentTop="true" /> 
</RelativeLayout> 
+1

你能發佈你的佈局XML和活動代碼嗎? –

+0

@MobileDeveloper添加了xml,您感興趣的是哪部分活動代碼?這是相當一堆...... – Maverick283

回答

3

聽起來?我遇到了同樣的錯誤,並將其跟蹤到23.4.0中的DrawableCompat.wrap()錯誤,該錯誤在較早版本的&支持庫的較新版本中不存在。此錯誤錯誤地將可繪製邊界設置爲0(或者在插入drawable的情況下爲負)。我已經看到這導致Android 5.1崩潰。

我沒有看到爲此打開的具體問題,但看着DrawableWrapperDonut/DrawableWrapperGingerbread的代碼,我可以看到問題是在23.4.0左右引入的,後來修復了,所以如果你使用的是buggy版本,切換到一個好的版本應該解決這個崩潰。

+1

謝謝,這可能是原因。不幸的是,我無法再看到那臺平板電腦了,但我一定會嘗試一下......現在收集你的觀點;) – Maverick283

+0

好吧,這不是原因:/檢查我的問題編輯的依賴關係,我已經把它們全部更新到了現在(儘管Android Studio認爲在23版本中仍然有針對性和編譯時有24版本是個不錯的主意......這是一個問題嗎?) – Maverick283

+0

雖然你有點正確,但它只是發生在棒棒糖,在kitkat和棉花糖工作正常...... – Maverick283

相關問題