В Android 3.0 я не могу использовать ndk-build для отладки ошибки собственного кода, когда нет библиотек собственного кода - PullRequest
0 голосов
/ 01 июля 2019

Я получаю следующую ошибку:

07-01 15:58:03.674: A/DEBUG(14660): *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
07-01 15:58:03.674: A/DEBUG(14660): Build fingerprint: 'Zebra/MC33/MC33:7.1.2/01-01-49-NG-00-A/7:user/release-keys'
07-01 15:58:03.674: A/DEBUG(14660): Revision: '0'
07-01 15:58:03.674: A/DEBUG(14660): ABI: 'arm64'
07-01 15:58:03.674: A/DEBUG(14660): pid: 14548, tid: 14548, name: x_pick_pack_app  >>> corp.cranegroup.corp.iplex_pick_pack_app <<<
07-01 15:58:03.675: A/DEBUG(14660): signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x40b61c00
07-01 15:58:03.675: A/DEBUG(14660):     x0   0000000000000001  x1   0000007ff08bb650  x2   0000000000000000  x3   0000000000000000
07-01 15:58:03.675: A/DEBUG(14660):     x4   0000000000000000  x5   88be1f8cfe791c83  x6   0000000000000000  x7   00000000fffffff5
07-01 15:58:03.675: A/DEBUG(14660):     x8   0000000040b61c00  x9   88be1f8cfe791c83  x10  88be1f8cfe791c83  x11  0000000000000007
07-01 15:58:03.675: A/DEBUG(14660):     x12  0000007ff08b9c70  x13  0000007f95690600  x14  0000007ff08b9d88  x15  0000000000000000
07-01 15:58:03.675: A/DEBUG(14660):     x16  0000007f9761c008  x17  0000007f97545444  x18  0000000000000000  x19  0000007f956a3000
07-01 15:58:03.675: A/DEBUG(14660):     x20  0000007f956a30a8  x21  0000000000000000  x22  0000007f86940f30  x23  0000007f86940f18
07-01 15:58:03.675: A/DEBUG(14660):     x24  000000000000003f  x25  0000000000000003  x26  0000007ff08bb7d8  x27  000000000000003f
07-01 15:58:03.675: A/DEBUG(14660):     x28  0000000000000001  x29  0000007ff08bb930  x30  0000007f96020338
07-01 15:58:03.675: A/DEBUG(14660):     sp   0000007ff08bb790  pc   0000007f96020354  pstate 0000000060000000
07-01 15:58:04.147: A/DEBUG(14660): backtrace:
07-01 15:58:04.148: A/DEBUG(14660):     #00 pc 0000000000018354  /system/lib64/libutils.so (_ZN7android6Looper9pollInnerEi+884)
07-01 15:58:04.148: A/DEBUG(14660):     #01 pc 0000000000017f30  /system/lib64/libutils.so (_ZN7android6Looper8pollOnceEiPiS1_PPv+60)
07-01 15:58:04.148: A/DEBUG(14660):     #02 pc 00000000000f2794  /system/lib64/libandroid_runtime.so (_ZN7android18NativeMessageQueue8pollOnceEP7_JNIEnvP8_jobjecti+48)
07-01 15:58:04.148: A/DEBUG(14660):     #03 pc 0000000001fc3e40  /system/framework/arm64/boot-framework.oat (offset 0x1702000) (android.os.MessageQueue.nativePollOnce+140)
07-01 15:58:04.148: A/DEBUG(14660):     #04 pc 0000000001fc5a60  /system/framework/arm64/boot-framework.oat (offset 0x1702000) (android.os.MessageQueue.next+236)
07-01 15:58:04.148: A/DEBUG(14660):     #05 pc 0000000001fbf778  /system/framework/arm64/boot-framework.oat (offset 0x1702000) (android.os.Looper.loop+340)
07-01 15:58:04.148: A/DEBUG(14660):     #06 pc 00000000017bf758  /system/framework/arm64/boot-framework.oat (offset 0x1702000) (android.app.ActivityThread.main+516)
07-01 15:58:04.148: A/DEBUG(14660):     #07 pc 00000000000d2868  /system/lib64/libart.so (art_quick_invoke_static_stub+600)
07-01 15:58:04.148: A/DEBUG(14660):     #08 pc 00000000000df2b0  /system/lib64/libart.so (_ZN3art9ArtMethod6InvokeEPNS_6ThreadEPjjPNS_6JValueEPKc+252)
07-01 15:58:04.148: A/DEBUG(14660):     #09 pc 000000000042a784  /system/lib64/libart.so (_ZN3artL18InvokeWithArgArrayERKNS_33ScopedObjectAccessAlreadyRunnableEPNS_9ArtMethodEPNS_8ArgArrayEPNS_6JValueEPKc+108)
07-01 15:58:04.148: A/DEBUG(14660):     #10 pc 000000000042c2f4  /system/lib64/libart.so (_ZN3art12InvokeMethodERKNS_33ScopedObjectAccessAlreadyRunnableEP8_jobjectS4_S4_m+1188)
07-01 15:58:04.148: A/DEBUG(14660):     #11 pc 00000000003a372c  /system/lib64/libart.so (_ZN3artL13Method_invokeEP7_JNIEnvP8_jobjectS3_S3_+56)
07-01 15:58:04.148: A/DEBUG(14660):     #12 pc 000000000061aa58  /system/framework/arm64/boot.oat (offset 0x54e000) (java.lang.reflect.Method.invoke+180)
07-01 15:58:04.148: A/DEBUG(14660):     #13 pc 0000000002696a60  /system/framework/arm64/boot-framework.oat (offset 0x1702000) (com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run+124)
07-01 15:58:04.148: A/DEBUG(14660):     #14 pc 0000000002697cbc  /system/framework/arm64/boot-framework.oat (offset 0x1702000) (com.android.internal.os.ZygoteInit.main+1432)
07-01 15:58:04.148: A/DEBUG(14660):     #15 pc 00000000000d2868  /system/lib64/libart.so (art_quick_invoke_static_stub+600)
07-01 15:58:04.148: A/DEBUG(14660):     #16 pc 00000000000df2b0  /system/lib64/libart.so (_ZN3art9ArtMethod6InvokeEPNS_6ThreadEPjjPNS_6JValueEPKc+252)
07-01 15:58:04.148: A/DEBUG(14660):     #17 pc 000000000042a784  /system/lib64/libart.so (_ZN3artL18InvokeWithArgArrayERKNS_33ScopedObjectAccessAlreadyRunnableEPNS_9ArtMethodEPNS_8ArgArrayEPNS_6JValueEPKc+108)
07-01 15:58:04.148: A/DEBUG(14660):     #18 pc 000000000042a3dc  /system/lib64/libart.so (_ZN3art17InvokeWithVarArgsERKNS_33ScopedObjectAccessAlreadyRunnableEP8_jobjectP10_jmethodIDSt9__va_list+380)
07-01 15:58:04.148: A/DEBUG(14660):     #19 pc 0000000000345048  /system/lib64/libart.so (_ZN3art3JNI21CallStaticVoidMethodVEP7_JNIEnvP7_jclassP10_jmethodIDSt9__va_list+604)
07-01 15:58:04.148: A/DEBUG(14660):     #20 pc 00000000000a0794  /system/lib64/libandroid_runtime.so
07-01 15:58:04.148: A/DEBUG(14660):     #21 pc 00000000000a2e84  /system/lib64/libandroid_runtime.so (_ZN7android14AndroidRuntime5startEPKcRKNS_6VectorINS_7String8EEEb+692)
07-01 15:58:04.148: A/DEBUG(14660):     #22 pc 0000000000002260  /system/bin/app_process64
07-01 15:58:04.148: A/DEBUG(14660):     #23 pc 000000000001a7d8  /system/lib64/libc.so (__libc_init+88)
07-01 15:58:04.148: A/DEBUG(14660):     #24 pc 0000000000001ccc  /system/bin/app_process64

С моим приложением у меня нет встроенных библиотек кода как части приложения, которое я создал, и мой Gradle выглядит следующим образом:

    apply plugin: 'com.android.application'

android {
    compileSdkVersion 25
    defaultConfig {
        applicationId "corp.cranegroup.corp.iplex_pick_pack_app"
        minSdkVersion 19
        targetSdkVersion 22
        versionCode 1
        versionName "1.0"
    }




    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
        debug {
            debuggable true
        }
    }
    buildToolsVersion '26.0.2'




}

dependencies {

    implementation 'com.android.support.constraint:constraint-layout:1.0.2'
    compile fileTree(include: ['*.jar'], dir: 'libs')
    compile 'com.android.support:appcompat-v7:25.+'
    compile 'com.android.support:design:25.+'
}

Мне не удалось использовать другие ответы на этом сайте, чтобы перейти к начальной стадии отладки фактической ошибки, независимо от того, была ли она нулевой ссылкой или нет. Кажется, почти все остальное в нативном коде связано с отладкой вашего собственного написанного нативного кода, однако мне нужно посмотреть, что в итоге приводит к ошибочным ссылкам, чтобы я мог исправить используемый Java-код. Для справки Java ниже

 public void goNext(View view) {
        if(view != null) {
            InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
            imm.hideSoftInputFromWindow(view.getWindowToken(),0);
        }

        edtInput.setText(edtInput.getText().toString().trim());
        if (edtInput.getText().toString().isEmpty()){
            txtError.setText("Please Enter Qty Picked Number");
        } else {
            // checking the network connection before starting the Activity
            ConnectivityManager connMgr = (ConnectivityManager)
                    getSystemService(Context.CONNECTIVITY_SERVICE);
            NetworkInfo networkInfo = connMgr.getActiveNetworkInfo();

            if (networkInfo != null && networkInfo.isConnected()) {
                String qtyEntered = edtInput.getText().toString();
                try{
                    //Check if there is a /n at the end, remove if there is one
                    if (qtyEntered.length() > 0 ) {
                        char lastCharacter = qtyEntered.charAt(qtyEntered.length() - 1);
                        if (lastCharacter == '\n') {
                            String barcode = qtyEntered.subSequence(0, qtyEntered.length() - 1).toString();
                            Log.d(TAG, "Barcode=" + barcode);
                            qtyEntered = barcode.trim();
                        }
                    }
                }catch (Exception e){
                    e.printStackTrace();
                }

                Intent intent = null;

                if (Integer.parseInt(qtyEntered) < Integer.parseInt(_tasks.get(_taskIndex).getQty_to_pick())){

                    if (confirmShortPick(qtyEntered)){
                        if (getYNPickMore(qtyEntered)){
                            try{
                            intent = new Intent(getApplicationContext(), ShortPickActivity.class);
                            intent.putExtra("qtyEntered", qtyEntered);
                            intent.putExtra("taskArray", _tasks);
                            intent.putExtra("taskIndex", _taskIndex);
                            intent.putExtra("curTrip", _curTrip);
                            //startActivity(intent);
                            }
                            catch (Exception e ){
                                e.printStackTrace();
                            }
                        } else {
                            intent = new Intent(getApplicationContext(), LocToActivity.class);
                            intent.putExtra("qtyEntered", qtyEntered);
                            intent.putExtra("taskArray", _tasks);
                            intent.putExtra("taskIndex", _taskIndex);
                            intent.putExtra("curTrip", _curTrip);
                            //startActivity(intent);
                        }
                    } else {
                        intent = new Intent(getApplicationContext(), QuantityActivity.class);
                        intent.putExtra("ERROR_CODE", "Warning: You Selected to Pick the Full Qty, Please Pick Full Qty from ".concat(_fromLoc));
                        intent.putExtra("itemScanned", _curItem);
                        intent.putExtra("taskArray", _tasks);
                        intent.putExtra("taskIndex", _taskIndex);
                        intent.putExtra("curTrip", _curTrip);
                        //startActivity(intent);
                    }

                } else {

                    intent = new Intent(getApplicationContext(), LocToActivity.class);
                    intent.putExtra("qtyEntered", qtyEntered);
                    intent.putExtra("taskArray", _tasks);
                    intent.putExtra("taskIndex", _taskIndex);
                    intent.putExtra("curTrip", _curTrip);
                    //startActivity(intent);
                }
                //} else {
                //txtError.setText("Please Scan the correct Location for this trip");
                //}

                //if (Objects.equals(itemCode.trim(), _locCode.trim())) {
                //Log.d(TAG, "goNext: locCode matches");

                if (intent != null) {
                    startActivity(intent);
                }

            } else {
                txtError.setText("No network connection available.");
            }
        }
    }

    public boolean getYNPickMore(String qtyPicked){
        final Handler handler = new Handler() {
            @Override
            public void handleMessage(Message mesg) {
                throw new RuntimeException();
            }
        };
        final Boolean[] result = {false};
        AlertDialog.Builder builder = new AlertDialog.Builder(this);

        builder.setTitle("Confirm Picked Qty of".concat(qtyPicked));
        builder.setMessage("Do you want to pick this item from a different location?");



        builder.setPositiveButton("Pick from other location", new DialogInterface.OnClickListener() {

            public void onClick(DialogInterface dialog, int which) {
                // Do nothing but close the dialog
                result[0] = true;
                handler.sendMessage(handler.obtainMessage());


            }
        });

        builder.setNegativeButton("NO", new DialogInterface.OnClickListener() {

            @Override
            public void onClick(DialogInterface dialog, int which) {

                // Do nothing
                result[0] = false;
                handler.sendMessage(handler.obtainMessage());

            }
        });

        AlertDialog alert = builder.create();
        alert.show();
        try{ Looper.loop(); }
        catch(RuntimeException e){}

        return result[0];
    }



    public boolean confirmShortPick(String qtyPicked) {
        final Handler handler = new Handler() {
            @Override
            public void handleMessage(Message mesg) {
                throw new RuntimeException();
            }
        };

        final Boolean[] result = {false};
        AlertDialog.Builder builder = new AlertDialog.Builder(this);

        builder.setTitle("Confirm Picked Qty of".concat(qtyPicked));
        builder.setMessage("Are you sure you want to short pick from this location?");

        builder.setPositiveButton("Short Pick from here", new DialogInterface.OnClickListener() {

            public void onClick(DialogInterface dialog, int which) {
                // Do nothing but close the dialog
                result[0] = true;
                handler.sendMessage(handler.obtainMessage());
            }
        });

        builder.setNegativeButton("NO", new DialogInterface.OnClickListener() {

            @Override
            public void onClick(DialogInterface dialog, int which) {

                // Do nothing
                result[0] = false;
                handler.sendMessage(handler.obtainMessage());
            }
        });

        AlertDialog alert = builder.create();
        alert.show();
        try{ Looper.loop(); }
        catch(RuntimeException e){}

        return result[0];
    }

1 Ответ

0 голосов
/ 02 июля 2019

Хорошо, так что после еще большего тестирования я нашел ответ мою проблему. Кажется, что существует произвольное ограничение на объем работы, который основной цикл будет обрабатывать в любой момент времени, и это было причина ошибки Sigsegv.

Таким образом, чтобы решить мою конкретную проблему с помощью диалогового окна предупреждения о блокировке / неблокировании, я сделал следующее в своей функции goNext '' 'Java

@Override
    public void goNext(View view) {
        if(view != null) {
            InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
            imm.hideSoftInputFromWindow(view.getWindowToken(),0);
        }

        final Handler mHandlerThread = new Handler(){
            @Override
            public void handleMessage(Message msg) {
                super.handleMessage(msg);
                if (msg.what == 400){
                    txtError.setText(msg.getData().getString("Error"));
                } else if (msg.what == 100){
                    startActivity((Intent) msg.getData().getParcelable("Intent"));
                }
            }
        };

        Thread blockingThread = new Thread(new Runnable() {


            @Override
            public void run() {
                Looper.prepare();
                Message message = new Message();
                Bundle bundle = new Bundle();

                edtInput.setText(edtInput.getText().toString().trim());
                if (edtInput.getText().toString().isEmpty()){
                    message.what = 400;
                    bundle.putString("Error","Please Enter Qty Picked Number");
                    message.setData(bundle);
                } else {
                    // checking the network connection before starting the Activity
                    ConnectivityManager connMgr = (ConnectivityManager)
                            getSystemService(Context.CONNECTIVITY_SERVICE);
                    NetworkInfo networkInfo = connMgr.getActiveNetworkInfo();

                    if (networkInfo != null && networkInfo.isConnected()) {
                        String qtyEntered = edtInput.getText().toString();
                        try{
                            //Check if there is a /n at the end, remove if there is one
                            if (qtyEntered.length() > 0 ) {
                                char lastCharacter = qtyEntered.charAt(qtyEntered.length() - 1);
                                if (lastCharacter == '\n') {
                                    String barcode = qtyEntered.subSequence(0, qtyEntered.length() - 1).toString();
                                    Log.d(TAG, "Barcode=" + barcode);
                                    qtyEntered = barcode.trim();
                                }
                            }
                        }catch (Exception e){
                            e.printStackTrace();
                        }

                        Intent intent = null;

                        if (Integer.parseInt(qtyEntered) < Integer.parseInt(_tasks.get(_taskIndex).getQty_to_pick())){

                            if (confirmShortPick(qtyEntered)){
                                if (getYNPickMore(qtyEntered)){
                                    try{
                                        intent = new Intent(getApplicationContext(), ShortPickActivity.class);
                                        intent.putExtra("qtyEntered", qtyEntered);
                                        intent.putExtra("taskArray", _tasks);
                                        intent.putExtra("taskIndex", _taskIndex);
                                        intent.putExtra("curTrip", _curTrip);
                                        //startActivity(intent);
                                    }
                                    catch (Exception e ){
                                        e.printStackTrace();
                                    }
                                } else {
                                    intent = new Intent(getApplicationContext(), LocToActivity.class);
                                    intent.putExtra("qtyEntered", qtyEntered);
                                    intent.putExtra("taskArray", _tasks);
                                    intent.putExtra("taskIndex", _taskIndex);
                                    intent.putExtra("curTrip", _curTrip);
                                    //startActivity(intent);
                                }
                            } else {
                                intent = new Intent(getApplicationContext(), QuantityActivity.class);
                                intent.putExtra("ERROR_CODE", "Warning: You Selected to Pick the Full Qty, Please Pick Full Qty from ".concat(_fromLoc));
                                intent.putExtra("itemScanned", _curItem);
                                intent.putExtra("taskArray", _tasks);
                                intent.putExtra("taskIndex", _taskIndex);
                                intent.putExtra("curTrip", _curTrip);
                                //startActivity(intent);
                            }

                        } else {

                            intent = new Intent(getApplicationContext(), LocToActivity.class);
                            intent.putExtra("qtyEntered", qtyEntered);
                            intent.putExtra("taskArray", _tasks);
                            intent.putExtra("taskIndex", _taskIndex);
                            intent.putExtra("curTrip", _curTrip);
                            //startActivity(intent);
                        }
                        //} else {
                        //txtError.setText("Please Scan the correct Location for this trip");
                        //}

                        //if (Objects.equals(itemCode.trim(), _locCode.trim())) {
                        //Log.d(TAG, "goNext: locCode matches");

                        if (intent != null) {
                            message.what = 100; //success
                            bundle.putParcelable("Intent",intent);
                            message.setData(bundle);
                        }

                    } else {
                        message.what = 400; //error
                        bundle.putString("Error","No network connection available.");
                        message.setData(bundle);
                    }
                }
                mHandlerThread.sendMessage(message);
            }
        });

        blockingThread.start();


        //new QuantityActivity.goNextAsynch().execute(view);

    }

Потянув вышеупомянутое в его собственный Поток, я смог получить это, чтобы заблокировать переход к следующему действию, в то время как приложение ожидало ввода данных от AlertDialog.

...