为什么我的APK只在三星手机上工作?

时间:2017-04-27 14:23:01

标签: android android-studio

在我的应用程序中,我录制音频并保存在NEW文件夹中,我还有一个ArrayList来显示音频。 我的应用程序只是在三星手机上工作,当我尝试nexus它给我一个错误。 这是我的数组列表。

             String sep = File.separator; // Use this instead of hardcoding the "/"
    String newFolder = "FolderName";
    String extStorageDirectory = Environment.getExternalStorageDirectory().toString();
    File myNewFolder = new File(extStorageDirectory + sep + newFolder);
    myNewFolder.mkdir();


    while (fs.getfetchstatus() != true) {
        mySongs = fs.findSongs(Environment.getExternalStorageDirectory());


    }
    if (mySongs != null) {
        dialog.dismiss();
    }
    mySongs = fs.getsonglist();

    items = new String[mySongs.size()];
    for (int i = 0; i < mySongs.size(); i++) {
        items[i] = mySongs.get(i).getName().toString().replace(".3gp", "");

    }
    final ArrayAdapter<String> adp = new ArrayAdapter<String>(getApplicationContext(), android.R.layout.simple_list_item_1, items);
    adp.notifyDataSetChanged();
    lv.setAdapter(adp);

    lv.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
            Intent intent = new Intent(getApplicationContext(), Player.class);
            intent.putExtra("pos", i);
            adp.notifyDataSetChanged();
            startActivity(intent);
            finish();
        }
    });

这是我的MainAct

     org.usr.usr.mmusicplayer, PID: 1586                                                                 
     java.lang.RuntimeException: Unable to start activity ComponentInfo{org.usr.usr.mmusicplayer/org.usr.usr.musicplayer.MainActivity}: java.lang.NullPointerException: Attempt to get length of null array
                                                                          at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2416)
                                                                          at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
                                                                          at android.app.ActivityThread.-wrap11(ActivityThread.java)
                                                                          at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
                                                                          at android.os.Handler.dispatchMessage(Handler.java:102)
                                                                          at android.os.Looper.loop(Looper.java:148)
                                                                          at android.app.ActivityThread.main(ActivityThread.java:5417)
                                                                          at java.lang.reflect.Method.invoke(Native Method)
                                                                          at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
                                                                          at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
                                                                       Caused by: java.lang.NullPointerException: Attempt to get length of null array
                                                                          at org.usr.usr.musicplayer.FetchSongs.findSongs(FetchSongs.java:39)
                                                                          at org.usr.usr.musicplayer.MainActivity.onCreate(MainActivity.java:119)
                                                                          at android.app.Activity.performCreate(Activity.java:6251)
                                                                          at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107)
                                                                          at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369)
                                                                          at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476) 
                                                                          at android.app.ActivityThread.-wrap11(ActivityThread.java) 
                                                                          at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344) 
                                                                          at android.os.Handler.dispatchMessage(Handler.java:102) 
                                                                          at android.os.Looper.loop(Looper.java:148) 
                                                                          at android.app.ActivityThread.main(ActivityThread.java:5417) 
                                                                          at java.lang.reflect.Method.invoke(Native Method) 
                                                                          at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) 
                                                                          at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)                                

这是我在Nexus手机中测试时的错误

def function(pos):
    new_list = []

    if condition:
        for x in range(0,len(another_list)):
            new_pos = another_list[x]
            new_list.append(new_pos)
            function(new_pos)

0 个答案:

没有答案