【开源项目分析】android-UniversalMusicPlayer-master启动crash问题解决

android-UniversalMusicPlayer-master开源音乐项目,从github下载下来,编译运行以后,启动,遇到如下crash:

04-14 12:43:12.439 884-884/com.example.android.uamp E/ccl_VideoCastManager: [vnull] Couldn't find the appropriate version of Google Play Services
04-14 12:43:12.489 884-884/com.example.android.uamp E/dalvikvm: Could not find class 'android.app.ActivityManager$TaskDescription', referenced from method com.example.android.uamp.ui.BaseActivity.onCreate
04-14 12:43:12.569 884-884/com.example.android.uamp E/VdcInflateDelegate: Exception while inflating <vector>
                                                                          org.xmlpull.v1.XmlPullParserException: Binary XML file line #17<vector> tag requires viewportWidth > 0
                                                                              at android.support.graphics.drawable.VectorDrawableCompat.updateStateFromTypedArray(VectorDrawableCompat.java:535)
                                                                              at android.support.graphics.drawable.VectorDrawableCompat.inflate(VectorDrawableCompat.java:472)
                                                                              at android.support.graphics.drawable.VectorDrawableCompat.createFromXmlInner(VectorDrawableCompat.java:436)
                                                                              at android.support.v7.widget.AppCompatDrawableManager$VdcInflateDelegate.createFromXmlInner(AppCompatDrawableManager.java:829)
                                                                              at android.support.v7.widget.AppCompatDrawableManager.loadDrawableFromDelegates(AppCompatDrawableManager.java:303)
                                                                              at android.support.v7.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:178)
                                                                              at android.support.v7.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:173)
                                                                              at android.support.v7.widget.TintTypedArray.getDrawable(TintTypedArray.java:60)
                                                                              at android.support.v7.widget.Toolbar.<init>(Toolbar.java:254)
                                                                              at android.support.v7.widget.Toolbar.<init>(Toolbar.java:196)
                                                                              at java.lang.reflect.Constructor.constructNative(Native Method)
                                                                              at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
                                                                              at android.support.v7.app.AppCompatViewInflater.createView(AppCompatViewInflater.java:226)
                                                                              at android.support.v7.app.AppCompatViewInflater.createViewFromTag(AppCompatViewInflater.java:175)
                                                                              at android.support.v7.app.AppCompatViewInflater.createView(AppCompatViewInflater.java:146)
                                                                              at android.support.v7.app.AppCompatDelegateImplV7.createView(AppCompatDelegateImplV7.java:963)
                                                                              at android.support.v7.app.AppCompatDelegateImplV7.onCreateView(AppCompatDelegateImplV7.java:1022)
                                                                              at android.support.v4.view.LayoutInflaterCompatHC$FactoryWrapperHC.onCreateView(LayoutInflaterCompatHC.java:44)
                                                                              at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:690)
                                                                              at android.view.LayoutInflater.rInflate(LayoutInflater.java:761)
                                                                              at android.view.LayoutInflater.parseInclude(LayoutInflater.java:855)
                                                                              at android.view.LayoutInflater.rInflate(LayoutInflater.java:751)
                                                                              at android.view.LayoutInflater.rInflate(LayoutInflater.java:769)
                                                                              at android.view.LayoutInflater.inflate(LayoutInflater.java:498)
                                                                              at android.view.LayoutInflater.inflate(LayoutInflater.java:398)
                                                                              at android.view.LayoutInflater.inflate(LayoutInflater.java:354)
                                                                              at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:267)
                                                                              at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:129)
                                                                              at com.example.android.uamp.ui.MusicPlayerActivity.onCreate(MusicPlayerActivity.java:60)
                                                                              at android.app.Activity.performCreate(Activity.java:5389)
                                                                              at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1105)
                                                                              at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2246)
                                                                              at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2340)
                                                                              at android.app.ActivityThread.access$800(ActivityThread.java:157)
                                                                              at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1247)
                                                                              at android.os.Handler.dispatchMessage(Handler.java:102)
                                                                              at android.os.Looper.loop(Looper.java:157)
                                                                              at android.app.ActivityThread.main(ActivityThread.java:5293)
                                                                              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:1265)
                                                                              at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1081)
                                                                              at dalvik.system.NativeStart.main(Native Method)
04-14 12:43:12.579 884-884/com.example.android.uamp E/AndroidRuntime: FATAL EXCEPTION: main
                                                                      Process: com.example.android.uamp, PID: 884
                                                                      java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.android.uamp/com.example.android.uamp.ui.MusicPlayerActivity}: android.view.InflateException: Binary XML file line #25: Error inflating class android.support.v7.widget.Toolbar
                                                                          at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2282)
                                                                          at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2340)
                                                                          at android.app.ActivityThread.access$800(ActivityThread.java:157)
                                                                          at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1247)
                                                                          at android.os.Handler.dispatchMessage(Handler.java:102)
                                                                          at android.os.Looper.loop(Looper.java:157)
                                                                          at android.app.ActivityThread.main(ActivityThread.java:5293)
                                                                          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:1265)
                                                                          at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1081)
                                                                          at dalvik.system.NativeStart.main(Native Method)
                                                                       Caused by: android.view.InflateException: Binary XML file line #25: Error inflating class android.support.v7.widget.Toolbar
                                                                          at android.view.LayoutInflater.createView(LayoutInflater.java:626)
                                                                          at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:702)
                                                                          at android.view.LayoutInflater.rInflate(LayoutInflater.java:761)
                                                                          at android.view.LayoutInflater.parseInclude(LayoutInflater.java:855)
                                                                          at android.view.LayoutInflater.rInflate(LayoutInflater.java:751)
                                                                          at android.view.LayoutInflater.rInflate(LayoutInflater.java:769)
                                                                          at android.view.LayoutInflater.inflate(LayoutInflater.java:498)
                                                                          at android.view.LayoutInflater.inflate(LayoutInflater.java:398)
                                                                          at android.view.LayoutInflater.inflate(LayoutInflater.java:354)
                                                                          at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:267)
                                                                          at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:129)
                                                                          at com.example.android.uamp.ui.MusicPlayerActivity.onCreate(MusicPlayerActivity.java:60)
                                                                          at android.app.Activity.performCreate(Activity.java:5389)
                                                                          at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1105)
                                                                          at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2246)
                                                                          at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2340) 
                                                                          at android.app.ActivityThread.access$800(ActivityThread.java:157) 
                                                                          at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1247) 
                                                                          at android.os.Handler.dispatchMessage(Handler.java:102) 
                                                                          at android.os.Looper.loop(Looper.java:157) 
                                                                          at android.app.ActivityThread.main(ActivityThread.java:5293) 
                                                                          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:1265) 
                                                                          at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1081) 
                                                                          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:600)
                                                                          at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:702) 
                                                                          at android.view.LayoutInflater.rInflate(LayoutInflater.java:761) 
                                                                          at android.view.LayoutInflater.parseInclude(LayoutInflater.java:855) 
                                                                          at android.view.LayoutInflater.rInflate(LayoutInflater.java:751) 
                                                                          at android.view.LayoutInflater.rInflate(LayoutInflater.java:769) 
                                                                          at android.view.LayoutInflater.inflate(LayoutInflater.java:498) 
                                                                          at android.view.LayoutInflater.inflate(LayoutInflater.java:398) 
                                                                          at android.view.LayoutInflater.inflate(LayoutInflater.java:354) 
                                                                          at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:267) 
                                                                          at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:129) 
                                                                          at com.example.android.uamp.ui.MusicPlayerActivity.onCreate(MusicPlayerActivity.java:60) 
                                                                          at android.app.Activity.performCreate(Activity.java:5389) 
                                                                          at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1105) 
                                                                          at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2246) 
                                                                          at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2340) 
                                                                          at android.app.ActivityThread.access$800(ActivityThread.java:157) 
                                                                          at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1247) 
                                                                          at android.os.Handler.dispatchMessage(Handler.java:102) 
                                                                          at android.os.Looper.loop(Looper.java:157) 
                                                                          at android.app.ActivityThread.main(ActivityThread.java:5293) 
                                                                          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:1265) 
                                                                          at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1081) 
                                                                          at dalvik.system.NativeStart.main(Native Method) 
                                                                       Caused by: android.content.res.Resources$NotFoundException: File res/drawable-v19/abc_ic_ab_back_material.xml from drawable resource ID #0x7f020016
                                                                          at android.content.res.Resources.loadDrawable(Resources.java:3008)
                                                                          at android.content.res.Resources.getDrawable(Resources.java:1586)
                                                                          at android.support.v7.widget.TintResources.superGetDrawable(TintResources.java:48)
                                                                          at android.support.v7.widget.AppCompatDrawableManager.onDrawableLoadedFromResources(AppCompatDrawableManager.java:374)
                                                                          at android.support.v7.widget.TintResources.getDrawable(TintResources.java:44)
                                                                          at android.support.v4.content.ContextCompat.getDrawable(ContextCompat.java:323)
                                                                          at android.support.v7.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:180)
                                                                          at android.support.v7.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:173)
                                                                          at android.support.v7.widget.TintTypedArray.getDrawable(TintTypedArray.java:60)
                                                                          at android.support.v7.widget.Toolbar.<init>(Toolbar.java:254)
                                                                          at android.support.v7.widget.Toolbar.<init>(Toolbar.java:196)
                                                                          at java.lang.reflect.Constructor.constructNative(Native Method) 
                                                                          at java.lang.reflect.Constructor.newInstance(Constructor.java:423) 
                                                                          at android.view.LayoutInflater.createView(LayoutInflater.java:600) 
                                                                          at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:702) 
                                                                          at android.view.LayoutInflater.rInflate(LayoutInflater.java:761) 
                                                                          at android.view.LayoutInflater.parseInclude(LayoutInflater.java:855) 
                                                                          at android.view.LayoutInflater.rInflate(LayoutInflater.java:751) 
                                                                          at android.view.LayoutInflater.rInflate(LayoutInflater.java:769) 
                                                                          at android.view.LayoutInflater.inflate(LayoutInflater.java:498) 
                                                                          at android.view.LayoutInflater.inflate(LayoutInflater.java:398) 
                                                                          at android.view.LayoutInflater.inflate(LayoutInflater.java:354) 
                                                                          at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:267) 
                                                                          at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:129) 
                                                                          at com.example.android.uamp.ui.MusicPlayerActivity.onCreate(MusicPlayerActivity.java:60) 
                                                                          at android.app.Activity.performCreate(Activity.java:5389) 
                                                                          at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1105) 
                                                                          at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2246) 
                                                                          at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2340) 
                                                                          at android.app.ActivityThread.access$800(ActivityThread.java:157) 
                                                                          at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1247) 
                                                                          at android.os.Handler.dispatchMessage(Handler.java:102) 
                                                                          at android.os.Looper.loop(Looper.java:157) 
                                                                          at android.app.ActivityThread.main(ActivityThread.java:5293) 
                                                                          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:1265) 
                                                                          at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1081) 
                                                                          at dalvik.system.NativeStart.main(Native Method) 
                                                                       Caused by: org.xmlpull.v1.XmlPullParserException: Binary XML file line #17: invalid drawable tag vector
                                                                          at android.graphics.drawable.Drawable.createFromXmlInner(Drawable.java:969)
                                                                          at android.graphics.drawable.Drawable.createFromXml(Drawable.java:913)
                                                                          at android.content.res.Resources.loadDrawable(Resources.java:3004)
                                                                          at android.content.res.Resources.getDrawable(Resources.java:1586) 
                                                                          at android.support.v7.widget.TintResources.superGetDrawable(TintResources.java:48) 
                                                                          at android.support.v7.widget.AppCompatDrawableManager.onDrawableLoadedFromResources(AppCompatDrawableManager.java:374) 
                                                                          at android.support.v7.widget.TintResources.getDrawable(TintResources.java:44) 
                                                                          at android.support.v4.content.ContextCompat.getDrawable(ContextCompat.java:323) 
                                                                          at android.support.v7.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:180) 
                                                                          at android.support.v7.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:173) 
                                                                          at android.support.v7.widget.TintTypedArray.getDrawable(TintTypedArray.java:60) 
                                                                          at android.support.v7.widget.Toolbar.<init>(Toolbar.java:254) 
                                                                          at android.support.v7.widget.Toolbar.<init>(Toolbar.java:196) 
                                                                          at java.lang.reflect.Constructor.constructNative(Native Method) 
                                                                          at java.lang.reflect.Constructor.newInstance(Constructor.java:423) 
                                                                          at android.view.LayoutInflater.createView(LayoutInflater.java:600) 
                                                                          at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:702) 
                                                                          at android.view.LayoutInflater.rInflate(LayoutInflater.java:761) 
                                                                          at android.view.LayoutInflater.parseInclude(LayoutInflater.java:855) 
                                                                          at android.view.LayoutInflater.rInflate(LayoutInflater.java:751) 
                                                                          at android.view.LayoutInflater.rInflate(LayoutInflater.java:769) 
                                                                          at android.view.LayoutInflater.inflate(LayoutInflater.java:498) 
                                                                          at android.view.LayoutInflater.inflate(LayoutInflater.java:398) 
                                                                          at android.view.LayoutInflater.inflate(LayoutInflater.java:354) 
                                                                          at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:267) 
                                                                          at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:129) 
                                                                          at com.example.android.uamp.ui.MusicPlayerActivity.onCreate(MusicPlayerActivity.java:60) 
                                                                          at android.app.Activity.performCreate(Activity.java:5389) 
                                                                          at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1105) 
                                                                          at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2246) 
                                                                          at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2340) 
                                                                          at android.app.ActivityThread.access$800(ActivityThread.java:157) 
                                                                          at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1247) 
                                                                          at android.os.Handler.dispatchMessage(Handler.java:102) 
                                                                          at android.os.Looper.loop(Looper.java:157) 
                                                                          at android.app.ActivityThread.main(ActivityThread.java:5293) 
                                                                          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:1265) 
                                                                          at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1081) 
                                                                          at dalvik.system.NativeStart.main(Native Method) 

CRASH提示:找不到res/drawable-v19/abc_ic_ab_back_material.xml文件,从而导致加载crash。

解决方案:

使用这篇博客的方案解决:

  android studio1.4新建工程运行出错

我使用的是本文推荐的这种方法:

1)gradle:  1.5.0;

2)  defaultConfig中加入:  generatedDensities = [] 

3)  aaptOptions  加入 :  additionalParameters  "--no-version-vectors"

over -- 问题解决。参考这篇文章中的stack overflow 链接,可以找到更多关于这个问题的分析。 



   

;