所以我正在制作一个音乐播放器。应用程序在三星galaxy s5上工作正常但不是s4。最小值是为android 4.0设置的。我的设备是4.4.4,但它无法正常工作。 log cat说明了二进制xml文件。
这是Log Cat
03-17 17:06:36.987 11870-11870/? I/SELinux﹕ Function: selinux_android_load_priority , priority [3] , priority version is VE=SEPF_SGH-M919_4.4.4_0048
03-17 17:06:36.987 11870-11870/? E/dalvikvm﹕ >>>>> Normal User
03-17 17:06:36.987 11870-11870/? E/dalvikvm﹕ >>>>> com.example.joe.projectmanhattan [ userId:0 | appId:10239 ]
03-17 17:06:36.987 11870-11870/? D/dalvikvm﹕ Late-enabling CheckJNI
03-17 17:06:37.127 11870-11870/com.example.joe.projectmanhattan W/dalvikvm﹕ VFY: unable to find class referenced in signature (Landroid/view/SearchEvent;)
03-17 17:06:37.127 11870-11870/com.example.joe.projectmanhattan I/dalvikvm﹕ Could not find method android.view.Window$Callback.onSearchRequested, referenced from method android.support.v7.view.WindowCallbackWrapper.onSearchRequested
03-17 17:06:37.127 11870-11870/com.example.joe.projectmanhattan W/dalvikvm﹕ VFY: unable to resolve interface method 15026: Landroid/view/Window$Callback;.onSearchRequested (Landroid/view/SearchEvent;)Z
03-17 17:06:37.127 11870-11870/com.example.joe.projectmanhattan D/dalvikvm﹕ VFY: replacing opcode 0x72 at 0x0002
03-17 17:06:37.127 11870-11870/com.example.joe.projectmanhattan I/dalvikvm﹕ Could not find method android.view.Window$Callback.onWindowStartingActionMode, referenced from method android.support.v7.view.WindowCallbackWrapper.onWindowStartingActionMode
03-17 17:06:37.127 11870-11870/com.example.joe.projectmanhattan W/dalvikvm﹕ VFY: unable to resolve interface method 15030: Landroid/view/Window$Callback;.onWindowStartingActionMode (Landroid/view/ActionMode$Callback;I)Landroid/view/ActionMode;
03-17 17:06:37.127 11870-11870/com.example.joe.projectmanhattan D/dalvikvm﹕ VFY: replacing opcode 0x72 at 0x0002
03-17 17:06:37.177 11870-11870/com.example.joe.projectmanhattan I/dalvikvm﹕ Could not find method android.content.res.TypedArray.getChangingConfigurations, referenced from method android.support.v7.widget.TintTypedArray.getChangingConfigurations
03-17 17:06:37.177 11870-11870/com.example.joe.projectmanhattan W/dalvikvm﹕ VFY: unable to resolve virtual method 396: Landroid/content/res/TypedArray;.getChangingConfigurations ()I
03-17 17:06:37.177 11870-11870/com.example.joe.projectmanhattan D/dalvikvm﹕ VFY: replacing opcode 0x6e at 0x0002
03-17 17:06:37.177 11870-11870/com.example.joe.projectmanhattan I/dalvikvm﹕ Could not find method android.content.res.TypedArray.getType, referenced from method android.support.v7.widget.TintTypedArray.getType
03-17 17:06:37.177 11870-11870/com.example.joe.projectmanhattan W/dalvikvm﹕ VFY: unable to resolve virtual method 418: Landroid/content/res/TypedArray;.getType (I)I
03-17 17:06:37.177 11870-11870/com.example.joe.projectmanhattan D/dalvikvm﹕ VFY: replacing opcode 0x6e at 0x0002
03-17 17:06:37.187 11870-11870/com.example.joe.projectmanhattan 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.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.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.createSubDecor(AppCompatDelegateImplV7.java:379)
at android.support.v7.app.AppCompatDelegateImplV7.ensureSubDecor(AppCompatDelegateImplV7.java:300)
at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:264)
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:129)
at com.example.joe.projectmanhattan.ArtistList.onCreate(ArtistList.java:23)
at android.app.Activity.performCreate(Activity.java:5585)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1093)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2400)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2495)
at android.app.ActivityThread.access$900(ActivityThread.java:170)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1304)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:146)
at android.app.ActivityThread.main(ActivityThread.java:5635)
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:1291)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1107)
at dalvik.system.NativeStart.main(Native Method)
03-17 17:06:37.187 11870-11870/com.example.joe.projectmanhattan D/AndroidRuntime﹕ Shutting down VM
03-17 17:06:37.187 11870-11870/com.example.joe.projectmanhattan W/dalvikvm﹕ threadid=1: thread exiting with uncaught exception (group=0x41845da0)
03-17 17:06:37.187 11870-11870/com.example.joe.projectmanhattan E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: com.example.joe.projectmanhattan, PID: 11870
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.joe.projectmanhattan/com.example.joe.projectmanhattan.ArtistList}: android.view.InflateException: Binary XML file line #36: Error inflating class android.support.v7.widget.Toolbar
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2436)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2495)
at android.app.ActivityThread.access$900(ActivityThread.java:170)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1304)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:146)
at android.app.ActivityThread.main(ActivityThread.java:5635)
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:1291)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1107)
at dalvik.system.NativeStart.main(Native Method)
Caused by: android.view.InflateException: Binary XML file line #36: 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.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.createSubDecor(AppCompatDelegateImplV7.java:379)
at android.support.v7.app.AppCompatDelegateImplV7.ensureSubDecor(AppCompatDelegateImplV7.java:300)
at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:264)
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:129)
at com.example.joe.projectmanhattan.ArtistList.onCreate(ArtistList.java:23)
at android.app.Activity.performCreate(Activity.java:5585)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1093)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2400)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2495)
at android.app.ActivityThread.access$900(ActivityThread.java:170)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1304)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:146)
at android.app.ActivityThread.main(ActivityThread.java:5635)
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:1291)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1107)
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.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.createSubDecor(AppCompatDelegateImplV7.java:379)
at android.support.v7.app.AppCompatDelegateImplV7.ensureSubDecor(AppCompatDelegateImplV7.java:300)
at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:264)
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:129)
at com.example.joe.projectmanhattan.ArtistList.onCreate(ArtistList.java:23)
at android.app.Activity.performCreate(Activity.java:5585)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1093)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2400)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2495)
at android.app.ActivityThread.access$900(ActivityThread.java:170)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1304)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:146)
at android.app.ActivityThread.main(ActivityThread.java:5635)
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:1291)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1107)
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:3439)
at android.content.res.Resources.getDrawable(Resources.java:1893)
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.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.createSubDecor(AppCompatDelegateImplV7.java:379)
at android.support.v7.app.AppCompatDelegateImplV7.ensureSubDecor(AppCompatDelegateImplV7.java:300)
at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:264)
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:129)
at com.example.joe.projectmanhattan.ArtistList.onCreate(ArtistList.java:23)
at android.app.Activity.performCreate(Activity.java:5585)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1093)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2400)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2495)
at android.app.ActivityThread.access$900(ActivityThread.java:170)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1304)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:146)
at android.app.ActivityThread.main(ActivityThread.java:5635)
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:1291)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1107)
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:986)
at android.graphics.drawable.Drawable.createFromXml(Drawable.java:930)
at android.content.res.Resources.loadDrawable(Resources.java:3435)
.
03-17 17:06:39.920 11870-11870/com.example.joe.projectmanhattan I/Process﹕ Sending signal. PID: 11870 SIG: 9
这是我的艺术家和歌曲列表
package com.example.joe.projectmanhattan;
import android.database.Cursor;
import android.net.Uri;
import android.provider.MediaStore;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.widget.ListView;
import java.util.ArrayList;
public class ArtistList extends AppCompatActivity {
ListView mp3List;
String title, artist, path, displayName, songDuration,album;
ArrayList<Mp3Model> Artist;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_artist_list);
mp3List = (ListView) findViewById(R.id.artist_list);
Artist = new ArrayList<>();
scanSdcard();
SongAdapter adapter = new SongAdapter(this, Artist);
mp3List.setAdapter(adapter);
}
private void scanSdcard() {
String selection = MediaStore.Audio.Media.IS_MUSIC + " != 0";
String[] projection = {
MediaStore.Audio.Media.TITLE,
MediaStore.Audio.Media.ARTIST,
MediaStore.Audio.Media.DATA,
MediaStore.Audio.Media.DISPLAY_NAME,
MediaStore.Audio.Media.DURATION,
MediaStore.Audio.Media.ALBUM,
};
final String sortOrder = MediaStore.Audio.AudioColumns.ARTIST + " COLLATE LOCALIZED ASC";
Cursor cursor = null;
try {
Uri uri = android.provider.MediaStore.Audio.Media.EXTERNAL_CONTENT_URI;
cursor = this.getContentResolver().query(uri, projection, selection, null, sortOrder);
if (cursor != null) {
cursor.moveToFirst();
while (!cursor.isAfterLast()) {
Mp3Model mp3Model = new Mp3Model();
title = cursor.getString(0);
artist = cursor.getString(1);
path = cursor.getString(2);
displayName = cursor.getString(3);
songDuration = cursor.getString(4);
album=cursor.getString(5);
mp3Model.setTitle(title);
mp3Model.setArtist(artist);
mp3Model.setPath(path);
mp3Model.setDisplayName(displayName);
mp3Model.setSongDuration(songDuration);
//needs album in mp3model
Artist.add(mp3Model);
cursor.moveToNext();
}
}
} catch (Exception e) {
Log.e("Tag", e.toString());
} finally {
if (cursor != null) {
cursor.close();
}
}
}
}
here is the my Adapter:
package com.example.joe.projectmanhattan;
/**
* Created by joe on 3/17/2016.
*/
import android.graphics.Color;
import android.graphics.Typeface;
import android.util.TypedValue;
import android.widget.BaseAdapter;
import java.util.ArrayList;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.LinearLayout;
import android.widget.TextView;
import static android.graphics.Color.*;
/**
* Created by joe on 3/3/2016.
*/
public class SongAdapter extends BaseAdapter {
Context context;
ArrayList<Mp3Model> mp3Models;
LayoutInflater inflater;
//Typeface captureFont;
public SongAdapter(Context context, ArrayList<Mp3Model> mp3Models) {
this.context = context;
this.mp3Models = mp3Models;
inflater = (LayoutInflater) this.context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
//captureFont = Typeface.createFromAsset(this.context.getAssets(), "fonts/verdana.ttf");
}
@Override
public int getCount() {
return mp3Models.size();
}
@Override
public Object getItem(int position) {
return position;
}
@Override
public long getItemId(int position) {
return position;
}
public class ViewHolder {
TextView songName;
TextView artistName;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
ViewHolder vh;
if (convertView == null) {
vh = new ViewHolder();
convertView = inflater.inflate(R.layout.audio_list_style, parent, false);
vh.songName = (TextView) convertView.findViewById(R.id.song_title);
vh.artistName= (TextView)convertView.findViewById(R.id.song_artist);
convertView.setTag(vh);
} else {
vh = (ViewHolder) convertView.getTag();
}
vh.songName.setText(mp3Models.get(position).getTitle());
//vh.songName.setTypeface(captureFont);
vh.songName.setPadding(10, 10, 10, 10);
vh.songName.setTextColor(BLACK);
//vh.songName.setBackgroundColor(parseColor("#333333"));
vh.songName.setTextSize(TypedValue.COMPLEX_UNIT_SP, 18);
//artist name
vh.artistName.setText(mp3Models.get(position).getArtist());
vh.artistName.setTextColor(GRAY);
vh.artistName.setTextSize(TypedValue.COMPLEX_UNIT_SP,10);
return convertView;
}
}
答案 0 :(得分:0)
您似乎正在使用矢量xml drawable。直到v21才支持这些。这个设备是v19。您需要为此版本提供非矢量绘图