当前位置: 首页 > 知识库问答 >
问题:

Android中的execv(/system/bin/dex2Oat)失败

法和硕
2023-03-14

activity_main_menu.xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/activity_main_menu_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="fyp.hkust.facet.activity.MainMenuActivity"
android:background="@drawable/background_dark_circle">


<ImageButton
    android:layout_width="65dp"
    android:layout_height="65dp"
    android:background="@mipmap/ic_location_on_white_36dp"
    android:id="@+id/store_button"
    android:layout_below="@+id/photo_camera"
    android:layout_alignParentLeft="true"
    android:layout_alignParentStart="true" />

<ImageButton
    android:layout_width="65dp"
    android:layout_height="65dp"
    android:background="@mipmap/ic_favorite_white_36dp"
    android:id="@+id/fav_button"
    android:layout_below="@+id/photo_camera"
    android:layout_alignParentRight="true"
    android:layout_alignParentEnd="true" />

<TextView
    android:id="@+id/location_text"
    android:layout_width="80dp"
    android:layout_height="wrap_content"
    android:gravity="center"
    android:text="@string/store_text"
    android:textColor="#FFFFFF"
    android:textStyle="bold"
    android:layout_alignParentLeft="true"
    android:layout_alignParentStart="true"
    android:layout_alignRight="@+id/store_button"
    android:layout_alignEnd="@+id/store_button"
    android:layout_below="@+id/store_button" />

<TextView
    android:id="@+id/fav_text"
    android:layout_width="80dp"
    android:layout_height="wrap_content"
    android:gravity="center"
    android:text="@string/favourite_text"
    android:textColor="#FFFFFF"
    android:textStyle="bold"
    android:layout_below="@+id/fav_button"
    android:layout_alignLeft="@+id/fav_button"
    android:layout_alignStart="@+id/fav_button" />

<TextView
    android:id="@+id/account_text"
    android:layout_width="150dp"
    android:layout_height="wrap_content"
    android:gravity="center"
    android:text="@string/my_account_text"
    android:textColor="#FFFFFF"
    android:textStyle="bold"
    android:layout_below="@+id/account_button"
    android:layout_alignLeft="@+id/account_button"
    android:layout_alignStart="@+id/account_button" />

<TextView
    android:id="@+id/photo_camera_text"
    android:layout_width="100dp"
    android:layout_height="wrap_content"
    android:gravity="center"
    android:text="@string/facet_match_text"
    android:layout_marginLeft="5dp"
    android:textColor="#FFFFFF"
    android:textStyle="bold"
    android:layout_above="@+id/fav_text"
    android:layout_centerHorizontal="true"
    android:layout_marginBottom="58dp" />

<ImageButton
    android:layout_width="125dp"
    android:layout_height="125dp"
    android:background="@mipmap/ic_photo_camera_white_36dp"
    android:id="@+id/photo_camera"
    android:layout_centerVertical="true"
    android:layout_centerHorizontal="true"
    />

<ImageButton
    android:layout_width="65dp"
    android:layout_height="65dp"
    android:background="@mipmap/ic_account_circle_white_36dp"
    android:id="@+id/account_button"
    android:layout_alignTop="@+id/shopping_button"
    android:layout_alignParentRight="true"
    android:layout_alignParentEnd="true"
    />

<TextView
    android:id="@+id/product_text"
    android:layout_width="80dp"
    android:layout_height="wrap_content"
    android:gravity="center"
    android:text="@string/all_products_text"
    android:textColor="#FFFFFF"
    android:textStyle="bold"
    android:layout_alignParentLeft="true"
    android:layout_alignParentStart="true"
    android:layout_alignBottom="@+id/account_text"
    android:layout_below="@+id/account_button"
    android:layout_alignRight="@+id/shopping_button"
    android:layout_alignEnd="@+id/shopping_button" />

<ImageButton
    android:layout_width="65dp"
    android:layout_height="65dp"
    android:background="@mipmap/ic_shopping_basket_white_36dp"
    android:id="@+id/shopping_button"
    android:layout_marginBottom="15dp"
    android:layout_marginLeft="5dp"
    android:layout_above="@+id/photo_camera"
    android:layout_alignParentLeft="true"
    android:layout_alignParentStart="true" />

</RelativeLayout>

MainmenuActivity.java

public class MainMenuActivity extends AppCompatActivity {

private static final String TAG = MainMenuActivity.class.getSimpleName();
private static final int CAM_REQUEST = 3;
private static String[] PERMISSIONS_REQ = {
        Manifest.permission.READ_EXTERNAL_STORAGE,
        Manifest.permission.WRITE_EXTERNAL_STORAGE,
        Manifest.permission.CAMERA
};
private static final int REQUEST_CODE_PERMISSION = 2;
private View activity_main_menu_layout;
private ImageButton shoppingBtn;
private ImageButton photoCameraBtn;
private ImageButton accountBtn;
private ImageButton storeBtn;

private static final int GALLERY_REQUEST = 1;
private static int OVERLAY_PERMISSION_REQ_CODE = 3;
private ImageButton favBtn;
private int buttonNumber = 0;
private String captureImageFullPath = null;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main_menu);

    activity_main_menu_layout = (RelativeLayout) findViewById(R.id.activity_main_menu_layout);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        Window window = getWindow();
        // Translucent status bar
        window.setFlags(
                WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS,
                WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
    }
    Typeface fontType = FontManager.getTypeface(getApplicationContext(), FontManager.APP_FONT);
    FontManager.markAsIconContainer(findViewById(R.id.activity_main_menu_layout), fontType);

    photoCameraBtn = (ImageButton) findViewById(R.id.photo_camera);
    shoppingBtn = (ImageButton) findViewById(R.id.shopping_button);
    accountBtn = (ImageButton) findViewById(R.id.account_button);
    storeBtn = (ImageButton) findViewById(R.id.store_button);
    favBtn = (ImageButton) findViewById(R.id.fav_button);

    photoCameraBtn.setOnClickListener(new View.OnClickListener() {
        @Override
        html" target="_blank">public void onClick(View view) {

            showAlertDialog();
        }
    });

    shoppingBtn.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            Intent Intent = new Intent(MainMenuActivity.this, MainActivity.class);
            startActivity(Intent);
        }
    });

    accountBtn.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {

            Intent accountIntent = new Intent(MainMenuActivity.this, ProfileActivity.class);
            startActivity(accountIntent);

        }
    });

    storeBtn.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            showMakeUpDialog();
        }
    });

    favBtn.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {

            Intent storeIntent = new Intent(MainMenuActivity.this, ShopListActivity.class);
            startActivity(storeIntent);

        }
    });


    // Just use hugo to print log
    isExternalStorageWritable();
    isExternalStorageReadable();

    // For API 23+ you need to request the read/write permissions even if they are already in your manifest.
    int currentapiVersion = android.os.Build.VERSION.SDK_INT;

    if (currentapiVersion >= Build.VERSION_CODES.M) {
        verifyPermissions(this);
    }

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
        if (!Settings.canDrawOverlays(this.getApplicationContext())) {
            Intent intent = new Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION, Uri.parse("package:" + getPackageName()));
            startActivityForResult(intent, OVERLAY_PERMISSION_REQ_CODE);
        }
    }

    if (!isMyServiceRunning(MyService.class))
        startService(new Intent(this, MyService.class));

}


private void showAlertDialog() {

    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder.setTitle("Choose the way to get your selfie");

    builder.setIcon(R.mipmap.app_icon);
    builder.setCancelable(true);

    final String[] items = new String[]{"From Gallery", "Take Photo"};
    final Integer[] icons = new Integer[]{R.mipmap.app_icon, R.mipmap.app_icon};
    ListAdapter adapter = new ArrayAdapterWithIcon(getApplication(), items, icons);

    builder.setAdapter(adapter, new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int item) {
            switch (item) {
                case 0: {
                    buttonNumber = 1;
                    Intent intent = new Intent(
                            Intent.ACTION_PICK,
                            android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
                    startActivityForResult(intent, GALLERY_REQUEST);
                    break;
                }
                case 1: {
                    Intent cameraViewIntent = new Intent(MainMenuActivity.this, ShowCameraViewActivity.class);
                    startActivity(cameraViewIntent);
                    break;
                }
            }

        }
    }).show();
}

private void showMakeUpDialog() {

    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder.setTitle("Choose the way to get your selfie");

    builder.setIcon(R.mipmap.app_icon);
    builder.setCancelable(true);

    final String[] items = new String[]{"From Gallery", "Take Photo"};
    final Integer[] icons = new Integer[]{R.mipmap.app_icon, R.mipmap.app_icon};
    ListAdapter adapter = new ArrayAdapterWithIcon(getApplication(), items, icons);

    builder.setAdapter(adapter, new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int item) {
            switch (item) {
                case 0: {
                    buttonNumber = 2;
                    Intent intent = new Intent(
                            Intent.ACTION_PICK,
                            android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
                    startActivityForResult(intent, GALLERY_REQUEST);
                    break;
                }
                case 1: {
                    Intent cameraViewIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
                    File file = getFile();
                    cameraViewIntent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(file));
                    startActivityForResult(cameraViewIntent, CAM_REQUEST);
                    break;
                }
            }

        }
    }).show();
}

private boolean isMyServiceRunning(Class<?> serviceClass) {
    ActivityManager manager = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE);
    for (ActivityManager.RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) {
        if (serviceClass.getName().equals(service.service.getClassName())) {
            return true;
        }
    }
    return false;
}

private File getFile() {

    File folder = new File("sdcard/FaceT");

    if (!folder.exists()) {
        folder.mkdir();
    }

    String currentDateTimeString = DateFormat.getDateTimeInstance().format(new Date());
    captureImageFullPath = folder + "/makeup_" + currentDateTimeString;
    File imageFile = new File(captureImageFullPath);
    return imageFile;
}

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);

    if (requestCode == OVERLAY_PERMISSION_REQ_CODE) {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
            if (!Settings.canDrawOverlays(this.getApplicationContext())) {
                Snackbar snackbar = Snackbar
                        .make(activity_main_menu_layout, "CameraActivity\", \"SYSTEM_ALERT_WINDOW, permission not granted...", Snackbar.LENGTH_SHORT);
                snackbar.show();
            } else {
                Intent intent = getIntent();
                finish();
                startActivity(intent);
            }
        }
    }

    if (requestCode == GALLERY_REQUEST && resultCode == RESULT_OK && data != null && data.getData() != null) {
        Uri pickedImage = data.getData();
        Log.d(TAG, "selected!!!" + " : " + pickedImage.getPath());
        // Let's read picked image path using content resolver
        String[] filePathColumn = {MediaStore.Images.Media.DATA};

        Cursor cursor = getContentResolver().query(pickedImage,
                filePathColumn, null, null, null);
        cursor.moveToFirst();

        int columnIndex = cursor.getColumnIndex(filePathColumn[0]);
        String picturePath = cursor.getString(columnIndex);
        cursor.close();

        Log.d(TAG + "Path:", picturePath);
        Intent intent = new Intent();
        if (buttonNumber == 1)
            intent.setClass(MainMenuActivity.this, CaptureActivity.class);
        else if (buttonNumber == 2)
            intent.setClass(MainMenuActivity.this, ColorizeFaceActivity.class);
        intent.putExtra("path", picturePath);
        //intent.putExtra("color" , "" + mBlobColorHsv);
        startActivity(intent);
    } else if (requestCode == CAM_REQUEST) {
        Intent intent = new Intent();
        intent.setClass(MainMenuActivity.this, ColorizeFaceActivity.class);
        intent.putExtra("path", captureImageFullPath);
        startActivity(intent);
    }

}

/**
 * Checks if the app has permission to write to device storage or open camera
 * If the app does not has permission then the user will be prompted to grant permissions
 *
 * @param activity
 */
private static boolean verifyPermissions(Activity activity) {
    // Check if we have write permission
    int write_permission = ActivityCompat.checkSelfPermission(activity, Manifest.permission.WRITE_EXTERNAL_STORAGE);
    int read_persmission = ActivityCompat.checkSelfPermission(activity, Manifest.permission.WRITE_EXTERNAL_STORAGE);
    int camera_permission = ActivityCompat.checkSelfPermission(activity, Manifest.permission.CAMERA);

    if (write_permission != PackageManager.PERMISSION_GRANTED ||
            read_persmission != PackageManager.PERMISSION_GRANTED ||
            camera_permission != PackageManager.PERMISSION_GRANTED) {
        // We don't have permission so prompt the user
        ActivityCompat.requestPermissions(
                activity,
                PERMISSIONS_REQ,
                REQUEST_CODE_PERMISSION
        );
        return false;
    } else {
        return true;
    }
}

/* Checks if external storage is available for read and write */
private boolean isExternalStorageWritable() {
    String state = Environment.getExternalStorageState();
    if (Environment.MEDIA_MOUNTED.equals(state)) {
        return true;
    }
    return false;
}

/* Checks if external storage is available to at least read */
private boolean isExternalStorageReadable() {
    String state = Environment.getExternalStorageState();
    if (Environment.MEDIA_MOUNTED.equals(state) ||
            Environment.MEDIA_MOUNTED_READ_ONLY.equals(state)) {
        return true;
    }
    return false;
}

}

04-06 16:47:18.851 934-934/fyp.hkust.facet w/art:execv失败(/system/bin/dex2Oat--runtime-arg-classpath--runtime-arg-debuggable--instruction-set-features=smp,div,atomic_ldrd_strd--runtime-arg-xrelocate--boot-image=/system/framework/boot.art--runtime-arg-xms64m--runtime-arg-xmx512m--runtime-arg-xmx512m

04-06 16:47:18.919 934-934/fyp.hkust.facet w/art:execv失败(/system/bin/dex2Oat--runtime-arg-classpath--runtime-arg-debuggable--instruction-set-features=smp,div,atomic_ldrd_strd--runtime-arg-xrelocate--boot-image=/system/framework/boot.art--runtime-arg-xms64m--runtime-arg-xmx512m--instruction-set-features=default

04-06 16:47:18.995 934-934/fyp.hkust.facet w/art:execv失败(/system/bin/dex2Oat--runtime-arg-classpath--runtime-arg-debuggable--instruction-set-features=smp,div,atomic_ldrd_strd--runtime-arg-xrelocate--boot-image=/system/framework/boot.art--runtime-arg-xms64m--runtime-arg-xmx512m--instruction-set-features=default

...。

04-06 16:47:19.590 934-934/fyp.hkust.facet w/art:execv失败(/system/bin/dex2Oat--runtime-arg-classpath--runtime-arg-debuggable--instruction-set-features=smp,div,atomic_ldrd_strd--runtime-arg-xrelocate--boot-image=/system/framework/boot.art--runtime-arg-xms64m--runtime-arg-xmx512m--instruction-set-features=default

当我进入这个活动,我的手机需要加载这么多的东西(在我的logcat中),以至于我不知道它们是什么。我不知道他们是什么意思。有人能解决这个问题吗?非常感谢。

共有1个答案

施锋
2023-03-14

这基本上说明您有太多的代码/资源作为编译输出。

有两个与此相关的主题,如果我看到您的build.gradle(特别是依赖项),就更容易回答了,但下面是:

>

  • 通常情况下,您的应用程序会引入大量依赖项,但实际上并没有使用这些依赖项中的每一段代码,因此可以安全地删除未使用的内容。这里的答案是用Proguard收缩。

    话虽如此,但要不惜一切代价避免使用Multidex:它会减慢构建过程,并为应用程序引入更多复杂性。它是为那些你没有其他选择的罕见情况而设计的。

  •  类似资料:
    • 我尝试过:在administrator中运行Android Studio,在环境变量上添加path,删除构建文件夹和重建项目,但我总是出现这个错误。 我想这就是为什么它没有开始我的活动。 $adb推送C:\users\me\androidStudioProjects\model\app\build\outputs\apk\app-debug.apk/data/local/tmp/my.model

    • execv(执行文件) 相关函数 fork,execl,execle,execlp,execve,execvp 表头文件 #include<unistd.h> 定义函数 int execv (const char * path, char * const argv[ ]); 函数说明 execv()用来执行参数path字符串所代表的文件路径,与execl()不同的地方在于execve()只需两个参

    • execv 执行文件 相关函数 fork,execl,execle,execlp,execve,execvp 表头文件 #include<unistd.h> 定义函数 int execv(const char *path, char *const argv[]); 函数说明 execv()用来执行参数path字符串所代表的文件路径,与execl()不同的地方在于execve()只需两个参数,第

    • 问题内容: 我目前正在学习,并且对组合的效率存在疑问。 向我显示了以下标准代码: 我知道这会克隆整个过程(复制整个堆等),并用新程序替换当前地址空间。考虑到这一点,使用该组合是否会导致效率低下?我们正在复制进程的整个地址空间,然后立即覆盖它。 所以我的问题是: 即使我们浪费了,使用此组合(而不是其他解决方案)有什么好处呢? 问题答案: 使用此组合(而不是其他解决方案)有什么好处,即使我们有浪费,该

    • 这是更新IDE后出现的错误 Android资源链接失败i:\Android\AndriodStudioProjects\MedicalApp\App\Build\Intermediates\Incremental\MergedebugResources\Merged.dir\values-v28\values-v28.xml:7:错误:找不到资源Android:attr/DialogCornerR