android studio 1.3.2创建的Hello World工程在老版本系统的手机上运行错误

本文记录了一次因VectorDrawable兼容性问题导致的应用崩溃错误,并提供了具体的解决方案,即将依赖库版本从24.0.0-alpha2回退到23.0.1。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

运行后出现下面的错误:

02-27 00:42:13.266: E/VdcInflateDelegate(17270): Exception while inflating <vector>
02-27 00:42:13.266: E/VdcInflateDelegate(17270): org.xmlpull.v1.XmlPullParserException: Binary XML file line #17<vector> tag requires viewportWidth > 0
02-27 00:42:13.266: E/VdcInflateDelegate(17270):    at android.support.graphics.drawable.VectorDrawableCompat.updateStateFromTypedArray(VectorDrawableCompat.java:535)
02-27 00:42:13.266: E/VdcInflateDelegate(17270):    at android.support.graphics.drawable.VectorDrawableCompat.inflate(VectorDrawableCompat.java:472)
02-27 00:42:13.266: E/VdcInflateDelegate(17270):    at android.support.graphics.drawable.VectorDrawableCompat.createFromXmlInner(VectorDrawableCompat.java:436)
02-27 00:42:13.266: E/VdcInflateDelegate(17270):    at android.support.v7.widget.AppCompatDrawableManager$VdcInflateDelegate.createFromXmlInner(AppCompatDrawableManager.java:829)
02-27 00:42:13.266: E/VdcInflateDelegate(17270):    at android.support.v7.widget.AppCompatDrawableManager.loadDrawableFromDelegates(AppCompatDrawableManager.java:303)
02-27 00:42:13.266: E/VdcInflateDelegate(17270):    at android.support.v7.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:178)
02-27 00:42:13.266: E/VdcInflateDelegate(17270):    at android.support.v7.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:173)
02-27 00:42:13.266: E/VdcInflateDelegate(17270):    at android.support.v7.widget.TintTypedArray.getDrawable(TintTypedArray.java:60)
02-27 00:42:13.266: E/VdcInflateDelegate(17270):    at android.support.v7.widget.Toolbar.<init>(Toolbar.java:254)
02-27 00:42:13.266: E/VdcInflateDelegate(17270):    at android.support.v7.widget.Toolbar.<init>(Toolbar.java:196)
02-27 00:42:13.266: E/VdcInflateDelegate(17270):    at java.lang.reflect.Constructor.constructNative(Native Method)
02-27 00:42:13.266: E/VdcInflateDelegate(17270):    at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
02-27 00:42:13.266: E/VdcInflateDelegate(17270):    at android.view.LayoutInflater.createView(LayoutInflater.java:600)
02-27 00:42:13.266: E/VdcInflateDelegate(17270):    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:702)
02-27 00:42:13.266: E/VdcInflateDelegate(17270):    at android.view.LayoutInflater.rInflate(LayoutInflater.java:761)
02-27 00:42:13.266: E/VdcInflateDelegate(17270):    at android.view.LayoutInflater.rInflate(LayoutInflater.java:769)
02-27 00:42:13.266: E/VdcInflateDelegate(17270):    at android.view.LayoutInflater.inflate(LayoutInflater.java:498)
02-27 00:42:13.266: E/VdcInflateDelegate(17270):    at android.view.LayoutInflater.inflate(LayoutInflater.java:398)
02-27 00:42:13.266: E/VdcInflateDelegate(17270):    at android.view.LayoutInflater.inflate(LayoutInflater.java:354)
02-27 00:42:13.266: E/VdcInflateDelegate(17270):    at android.support.v7.app.AppCompatDelegateImplV7.createSubDecor(AppCompatDelegateImplV7.java:379)
02-27 00:42:13.266: E/VdcInflateDelegate(17270):    at android.support.v7.app.AppCompatDelegateImplV7.ensureSubDecor(AppCompatDelegateImplV7.java:300)
02-27 00:42:13.266: E/VdcInflateDelegate(17270):    at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:264)
02-27 00:42:13.266: E/VdcInflateDelegate(17270):    at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:129)
02-27 00:42:13.266: E/VdcInflateDelegate(17270):    at com.testing.name.MainActivity.onCreate(MainActivity.java:13)
02-27 00:42:13.266: E/VdcInflateDelegate(17270):    at android.app.Activity.performCreate(Activity.java:5451)
02-27 00:42:13.266: E/VdcInflateDelegate(17270):    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1093)
02-27 00:42:13.266: E/VdcInflateDelegate(17270):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2292)
02-27 00:42:13.266: E/VdcInflateDelegate(17270):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2386)
02-27 00:42:13.266: E/VdcInflateDelegate(17270):    at android.app.ActivityThread.access$900(ActivityThread.java:169)
02-27 00:42:13.266: E/VdcInflateDelegate(17270):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1277)
02-27 00:42:13.266: E/VdcInflateDelegate(17270):    at android.os.Handler.dispatchMessage(Handler.java:102)
02-27 00:42:13.266: E/VdcInflateDelegate(17270):    at android.os.Looper.loop(Looper.java:136)
02-27 00:42:13.266: E/VdcInflateDelegate(17270):    at android.app.ActivityThread.main(ActivityThread.java:5476)
02-27 00:42:13.266: E/VdcInflateDelegate(17270):    at java.lang.reflect.Method.invokeNative(Native Method)
02-27 00:42:13.266: E/VdcInflateDelegate(17270):    at java.lang.reflect.Method.invoke(Method.java:515)
02-27 00:42:13.266: E/VdcInflateDelegate(17270):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1268)
02-27 00:42:13.266: E/VdcInflateDelegate(17270):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1084)
02-27 00:42:13.266: E/VdcInflateDelegate(17270):    at dalvik.system.NativeStart.main(Native Method)
02-27 00:42:13.276: E/AndroidRuntime(17270): FATAL EXCEPTION: main
02-27 00:42:13.276: E/AndroidRuntime(17270): Process: com.testing.name, PID: 17270
02-27 00:42:13.276: E/AndroidRuntime(17270): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.testing.name/com.testing.name.MainActivity}: android.view.InflateException: Binary XML file line #36: Error inflating class android.support.v7.widget.Toolbar
02-27 00:42:13.276: E/AndroidRuntime(17270):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2328)
02-27 00:42:13.276: E/AndroidRuntime(17270):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2386)
02-27 00:42:13.276: E/AndroidRuntime(17270):    at android.app.ActivityThread.access$900(ActivityThread.java:169)
02-27 00:42:13.276: E/AndroidRuntime(17270):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1277)
02-27 00:42:13.276: E/AndroidRuntime(17270):    at android.os.Handler.dispatchMessage(Handler.java:102)
02-27 00:42:13.276: E/AndroidRuntime(17270):    at android.os.Looper.loop(Looper.java:136)
02-27 00:42:13.276: E/AndroidRuntime(17270):    at android.app.ActivityThread.main(ActivityThread.java:5476)
02-27 00:42:13.276: E/AndroidRuntime(17270):    at java.lang.reflect.Method.invokeNative(Native Method)
02-27 00:42:13.276: E/AndroidRuntime(17270):    at java.lang.reflect.Method.invoke(Method.java:515)
02-27 00:42:13.276: E/AndroidRuntime(17270):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1268)
02-27 00:42:13.276: E/AndroidRuntime(17270):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1084)
02-27 00:42:13.276: E/AndroidRuntime(17270):    at dalvik.system.NativeStart.main(Native Method)
02-27 00:42:13.276: E/AndroidRuntime(17270): Caused by: android.view.InflateException: Binary XML file line #36: Error infl

解决方法:
将工程中app/build.gradle文件中
dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:24.0.0-alpha2'
}
修改为
dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:23.0.1'
}


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值