2017-01-23 72 views
5

嗨所以在我们的项目中,我们使用的是书法库,它的工作原理没有问题,但现在我加入其保持与以下堆栈跟踪崩溃的活动之一:InflateException使用chrisjenx CalligraphyLayoutInflater时,android.view.InflateException

01-23 02:25:32.178 3654-3654/? E/AndroidRuntime: FATAL EXCEPTION: main 
Process: com.example, PID: 3654 
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example/com.example.activities.MultipleActivity}: android.view.InflateException: Binary XML file line #98: Error inflating class com.example.components.WLayout 
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2195) 
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245) 
    at android.app.ActivityThread.access$800(ActivityThread.java:135) 
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196) 
    at android.os.Handler.dispatchMessage(Handler.java:102) 
    at android.os.Looper.loop(Looper.java:136) 
    at android.app.ActivityThread.main(ActivityThread.java:5017) 
    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:779) 
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595) 
    at dalvik.system.NativeStart.main(Native Method) 
Caused by: android.view.InflateException: Binary XML file line #98: Error inflating class com.example.components.WLayout 
    at android.view.LayoutInflater.createView(LayoutInflater.java:621) 
    at uk.co.chrisjenx.calligraphy.CalligraphyLayoutInflater.createCustomViewInternal(CalligraphyLayoutInflater.java:211) 
    at uk.co.chrisjenx.calligraphy.CalligraphyLayoutInflater.access$000(CalligraphyLayoutInflater.java:20) 
    at uk.co.chrisjenx.calligraphy.CalligraphyLayoutInflater$PrivateWrapperFactory2.onCreateView(CalligraphyLayoutInflater.java:302) 
    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:690) 
    at android.view.LayoutInflater.rInflate(LayoutInflater.java:756) 
    at android.view.LayoutInflater.rInflate(LayoutInflater.java:759) 
    at android.view.LayoutInflater.rInflate(LayoutInflater.java:759) 
    at android.view.LayoutInflater.rInflate(LayoutInflater.java:759) 
    at android.view.LayoutInflater.inflate(LayoutInflater.java:492) 
    at uk.co.chrisjenx.calligraphy.CalligraphyLayoutInflater.inflate(CalligraphyLayoutInflater.java:60) 
    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:280) 
    at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140) 
    at com.example.activities.MultipleActivity.onCreate(MultipleActivity.java:62) 
    at android.app.Activity.performCreate(Activity.java:5231) 
    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087) 
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2159) 
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245) 
    at android.app.ActivityThread.access$800(ActivityThread.java:135) 
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196) 
    at android.os.Handler.dispatchMessage(Handler.java:102) 
    at android.os.Looper.loop(Looper.java:136) 
    at android.app.ActivityThread.main(ActivityThread.java:5017) 
    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:779) 
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595) 
    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:595) 
    at uk.co.chrisjenx.calligraphy.CalligraphyLayoutInflater.createCustomViewInternal(CalligraphyLayoutInflater.java:211) 
    at uk.co.chrisjenx.calligraphy.CalligraphyLayoutInflater.access$000(CalligraphyLayoutInflater.java:20) 
    at uk.co.chrisjenx.calligraphy.CalligraphyLayoutInflater$PrivateWrapperFactory2.onCreateView(CalligraphyLayoutInflater.java:302) 
    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:690) 
    at android.view.LayoutInflater.rInflate(LayoutInflater.java:756) 
    at android.view.LayoutInflater.rInflate(LayoutInflater.java:759) 
    at android.view.LayoutInflater.rInflate(LayoutInflater.java:759) 
    at android.view.LayoutInflater.rInflate(LayoutInflater.java:759) 
    at android.view.LayoutInflater.inflate(LayoutInflater.java:492) 
    at uk.co.chrisjenx.calligraphy.CalligraphyLayoutInflater.inflate(CalligraphyLayoutInflater.java:60) 
    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:280) 
    at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140) 
    at com.example.activities.MultipleActivity.onCreate(MultipleActivity.java:62) 
    at android.app.Activity.performCreate(Activity.java:5231) 
    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087) 
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2159) 
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245) 
    at android.app.ActivityThread.access$800(ActivityThread.java:135) 
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196) 
    at android.os.Handler.dispatchMessage(Handler.java:102) 
    at android.os.Looper.loop(Looper.java:136) 
    at android.app.ActivityThread.main(ActivityThread.java:5017) 
    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:779) 
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595) 
    at dalvik.system.NativeStart.main(Native Method) 
Caused by: android.view.InflateException: Binary XML file line #13: Error inflating class TextView 
    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:714) 
    at android.view.LayoutInflater.rInflate(LayoutInflater.java:756) 
    at android.view.LayoutInflater.rInflate(LayoutInflater.java:759) 
    at android.view.LayoutInflater.parseInclude(LayoutInflater.java:840) 
    at android.view.LayoutInflater.rInflate(LayoutInflater.java:746) 
    at android.view.LayoutInflater.rInflate(LayoutInflater.java:759) 
    at android.view.LayoutInflater.rInflate(LayoutInflater.java:759) 
    at android.view.LayoutInflater.inflate(LayoutInflater.java:492) 
    at uk.co.chrisjenx.calligraphy.CalligraphyLayoutInflater.inflate(CalligraphyLayoutInflater.java:60) 
    at android.view.LayoutInflater.inflate(LayoutInflater.java:397) 
    at android.view.LayoutInflater.inflate(LayoutInflater.java:353) 

我检查了几个答案,但不能看到任何人遇到与textview问题。

我附上书法在我的活动如下

@Override 
protected void attachBaseContext(Context newBase) { 
    super.attachBaseContext(CalligraphyContextWrapper.wrap(newBase)); 
} 

活动的主题是如下

<style name="AppTheme.Compat.ActionBar.Dark.NoBackground" parent="AppTheme.Compat.ActionBar.Dark"> 
     <item name="android:windowBackground">@null</item> 
     <item name="android:textColor">@color/alert_title</item> 
     <item name="android:textColorPrimary">@color/gray400</item> 
     <item name="android:colorAccent">@color/alert_button</item> 
    </style> 

我注意到工作室给Android的警告:colorAccent和取而代之的是“colorAccent”,它删除了警告,但仍然存在崩溃。任何线索我在这里做错了什么?

+0

添加java代码'multipleActivity.class' – W4R10CK

+0

这个@amIT的运气怎么样? –

+0

能够找到解决方案发布它作为答案@ David Argyle Thacker – amIT

回答

1

终于想通了这个问题,因为这个问题是在TextView中发生的事情按照崩溃日志

产生的原因:android.view.InflateException:二进制XML文件行#13:错误充气类的TextView

TLDR:不要使用setbackbackground TextView它的bug容易(三星),特别是如果其矢量绘制。

我通过删除textview崩溃停止发生验证。问题是我用来设置我的textview的背景图像,这是一个SVG图像,我一直是appCompact库(v23)。只有通过“app:srcCompat”或“setImageResource()”支持设置矢量绘制才是使用矢量绘制的简单方法。

我看了这篇博客文章,看看https://android-developers.googleblog.com/2016/02/android-support-library-232.html我看到以前支持的Textview现在已经被删除,这意味着它不稳定并且容易出错。

我从textview中删除了Vector drawable,并在textview的下方添加了另一个Imageview,并使用“src:compact”向量绘制,这样在视觉上它们看起来仍然是相同的,即具有背景的Text视图。

如果应用程序大小不是问题,您还可以使用png/jpg资源,并避免在布局中创建额外的imageview。

相关问题