获取 PatchStore::createDisableExceptionQarthFile 方法失败

get PatchStore::createDisableExceptionQarthFile method fail

提问人:Morshed 提问时间:7/25/2022 最后编辑:Morshed 更新时间:7/25/2022 访问量:360

问:

当我在我的应用程序中向下滚动时,应用程序突然崩溃了,我发现在这次崩溃的背后,当我想在我的音乐应用程序中显示歌曲图像时,它会崩溃,任何人都请帮助我,我正在尽力而为,但我找不到任何方法

她的我的代码


2022-07-24 22:05:33.942 14071-14154/com.codewithmorshed.musikc E/AwareLog: AtomicFileUtils: readFileLines file not exist: android.util.AtomicFile@41e3df3
2022-07-24 22:05:33.945 14071-14118/com.codewithmorshed.musikc E/MemoryLeakMonitorManager: MemoryLeakMonitor.jar is not exist!
2022-07-24 22:06:00.418 14071-14071/com.codewithmorshed.musikc 
2022-07-24 22:06:01.086 14071-14071/com.codewithmorshed.musikc E/hmorshed.musik: [qarth_debug:]  get PatchStore::createDisableExceptionQarthFile method fail.
2022-07-24 22:06:01.089 14071-14071/com.codewithmorshed.musikc E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.codewithmorshed.musikc, PID: 14071
    java.lang.IllegalArgumentException
        at android.media.MediaMetadataRetriever.setDataSource(MediaMetadataRetriever.java:80)
        at com.codewithmorshed.musikc.SongAdapter.getAlbumart(SongAdapter.java:128)
        at com.codewithmorshed.musikc.SongAdapter.onBindViewHolder(SongAdapter.java:76)
        at com.codewithmorshed.musikc.SongAdapter.onBindViewHolder(SongAdapter.java:40)
        at androidx.recyclerview.widget.RecyclerView$Adapter.onBindViewHolder(RecyclerView.java:7254)
        at androidx.recyclerview.widget.RecyclerView$Adapter.bindViewHolder(RecyclerView.java:7337)
        at androidx.recyclerview.widget.RecyclerView$Recycler.tryBindViewHolderByDeadline(RecyclerView.java:6194)
        at androidx.recyclerview.widget.RecyclerView$Recycler.tryGetViewHolderForPositionByDeadline(RecyclerView.java:6460)
        at androidx.recyclerview.widget.GapWorker.prefetchPositionWithDeadline(GapWorker.java:288)
        at androidx.recyclerview.widget.GapWorker.flushTaskWithDeadline(GapWorker.java:345)
        at androidx.recyclerview.widget.GapWorker.flushTasksWithDeadline(GapWorker.java:361)
        at androidx.recyclerview.widget.GapWorker.prefetch(GapWorker.java:368)
        at androidx.recyclerview.widget.GapWorker.run(GapWorker.java:399)
        at android.os.Handler.handleCallback(Handler.java:907)
        at android.os.Handler.dispatchMessage(Handler.java:105)
        at android.os.Looper.loop(Looper.java:216)
        at android.app.ActivityThread.main(ActivityThread.java:7625)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:524)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:987)


公共类 SongAdapter 扩展 RecyclerView.Adapter<SongAdapter.MydViewHolder> {

private Context mcontex;
private ArrayList<Song> msong;
RequestOptions option;
View view;
MediaPlayer mediaPlayer;


SongAdapter(Context mcontex, ArrayList<Song> msong) {
    this.mcontex = mcontex;
    this.msong = msong;

}

@NonNull
@Override
public MydViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {

    View view = LayoutInflater.from(mcontex).inflate(R.layout.musik_item, parent, false);
    return new MydViewHolder(view);

}




@Override
public void onBindViewHolder(SongAdapter.MydViewHolder holder,int position) {

    Song song = msong.get(position);

    holder.fillname.setText(msong.get(position).getTitel());
    holder.artistnames.setText(msong.get(position).getArtist());


    byte[] image =getAlbumart(msong.get(position).getPath());
    if (image != null) {

        Glide.with(mcontex).asBitmap().load(image).into(holder.albumpic);
    } else {
          Glide.with(mcontex).asBitmap().load(R.drawable.lastlogo).into(holder.albumpic);
       }





 holder.itemView.setOnClickListener(new View.OnClickListener() {
     @Override
     public void onClick(View v) {

             Intent intent = new Intent(mcontex, PlayerActivity.class);
             intent.putExtra("position", holder.getAdapterPosition());
             mcontex.startActivity(intent);

     }
 });

    // gan delete korar jonno bebhito aitar sate connected holo aikane delted file() then Song.java tha then mainActiviy.java the
    holder.songmore.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            PopupMenu popupMenu = new PopupMenu(mcontex,v);
            popupMenu.getMenuInflater().inflate(R.menu.song_more_layout, popupMenu.getMenu());
            popupMenu.show();
            popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
                @Override
                public boolean onMenuItemClick(MenuItem item) {
                    switch (item.getItemId()){
                        case R.id.Delete:
                            Toast.makeText(mcontex, "Delete", Toast.LENGTH_SHORT).show();
                            DeletedFile(holder.getAdapterPosition(),v);
                            break;
                    }
                    return true;
                }
            });


        }
    });

  }

  


private void DeletedFile(int position, View v){
    Uri contentUri = ContentUris.withAppendedId(MediaStore.Audio.Media.EXTERNAL_CONTENT_URI,Long.parseLong(msong.get(position).getId()));
    File file = new File(msong.get(position).getPath());
    boolean deleted = file.delete();

    if (deleted) {
        mcontex.getContentResolver().delete(contentUri,null,null);
        msong.remove(position);
        notifyItemRemoved(position);
        notifyItemRangeChanged(position, msong.size());
        Snackbar.make(v, "File Delete :", Snackbar.LENGTH_LONG).show();
    }
    else {
        Snackbar.make(v, "Undo Delete :", Snackbar.LENGTH_LONG).show();
    }

}




@Override
    public int getItemCount () {
    return msong.size();
}

public static class MydViewHolder extends RecyclerView.ViewHolder{
    private TextView fillname,artistnames;
     private ImageView albumpic,songmore;

    public MydViewHolder(@NonNull View itemView) {
        super(itemView);
        fillname = itemView.findViewById(R.id.fillname);
        albumpic = itemView.findViewById(R.id.albumpic);
        songmore = itemView.findViewById(R.id.songmore);
        artistnames = itemView.findViewById(R.id.artistnames);
    }
    }
private byte[] getAlbumart(String uri) {
    MediaMetadataRetriever retriever = new MediaMetadataRetriever();
    retriever.setDataSource(uri);
    byte[] art = retriever.getEmbeddedPicture();
    retriever.release();
    return  art;



}

}

Java Android-Studio Kotlin 方法

评论

0赞 Morshed 7/25/2022
这里的任何人都请帮帮我
0赞 Paul Benn 7/25/2022
也许可以尝试在调试模式下运行代码,在调用时放置一个断点,并检查值:)的运行时值setDataSourceuri
0赞 Morshed 7/25/2022
你能给我代码吗?

答:

1赞 Paul Benn 7/25/2022 #1

MediaMetadataSource#setDataSource(String) 的文档表明您的变量(函数的参数 #0)不是有效路径:urigetAlbumart

如果路径无效,则抛出:。IllegalArgumentException

评论

0赞 Morshed 7/25/2022
兄弟,你能告诉我如何解决这个问题吗,你给我代码,因为我是新手,所以我可以理解文档
0赞 Paul Benn 7/25/2022
嗨,@Morshed,我已经评论了您上面的问题,关于我的建议,即在调试模式下运行您当前的代码,在调用中放置一个断点并检查 .我不认为新的/编辑的代码在这里会有所帮助,因为您的问题是 I/O 问题 - 该值指向不存在的东西。干杯setDataSourceuriuri
0赞 Morshed 7/25/2022
很抱歉,我无法理解你,因为我是新来的,请您给我一个示例代码 如何使用断点?