Android E / DEBUG:AM写入失败:管道损坏

时间:2017-03-20 02:40:02

标签: java android

我需要在设置片段中选择照片作为用户的图标,并在另一个片段中显示地图。当只有一个设置片段时,照片选择器是正常且有用的。

但是,只要添加了FragmentTransaction并添加了地图片段,那么照片选择器就不正常了。问题是,有时候从厨房选择照片后,如果我想用相机拍照,活动就会中断。如果我先用照相机拍照,也会发生同样的休息。

更重要的是,如果我删除了地图片段,那么一切都还可以。

错误信息:

  

03-20 10:08:53.531 1196-3512 /? E / LocSvc_eng:I / ===&gt; int loc_eng_inject_location(loc_eng_data_s_type&amp;,double,double,float)第2119行       03-20 10:08:53.531 1196-3978 /? E / LocSvc_ApiV02:I /&lt; --- void globalRespCb(locClientHandleType,uint32_t,locClientRespIndUnionType,void *)第115行QMI_LOC_INJECT_POSITION_REQ_V02       03-20 10:08:53.551 24604-24656 / com.example.john.wemeet_11_debug A / libc:致命信号11(SIGSEGV),代码1,故障地址0x800000c4abef40 in tid 24656(GLThread 5661)       03-20 10:08:53.651 401-401 /? A / DEBUG: * < / strong> *       03-20 10:08:53.651 401-401 /? A / DEBUG:构建指纹:&#39; HONOR / ATH-AL00 / HWATH:6.0.1 / HONORATH-AL00 / C00B398:用户/释放键&#39;       03-20 10:08:53.651 401-401 /? A / DEBUG:修订版:&#39; 0&#39;       03-20 10:08:53.651 401-401 /? A / DEBUG:ABI:&#39; arm64&#39;       03-20 10:08:53.651 401-401 /? A / DEBUG:pid:24604,tid:24656,姓名:GLThread 5661&gt;&gt;&gt; com.example.john.wemeet_11_debug&lt;&lt;&lt;       03-20 10:08:53.651 401-401 /? A / DEBUG:信号11(SIGSEGV),代码1(SEGV_MAPERR),故障地址0x800000c4abef40       03-20 10:08:53.681 401-401 /? A / DEBUG:x0 ffffffffffffffc0 x1 c0800000c4abef30 x2 0000000000000000 x3 fffffffffffff40       03-20 10:08:53.681 401-401 /? A / DEBUG:x4 0000000000000000 x5 0000000000000002 x6 00000055c430a490 x7 00000055c4b42e10       03-20 10:08:53.681 401-401 /? A / DEBUG:x8 00000055c2b50000 x9 0000000000000000 x10 0000000000000038 x11 00000055c430a1d0       03-20 10:08:53.681 401-401 /? A / DEBUG:x12 00000055c4ba3fb0 x13 00000055c430a1d0 x14 0000000000000000 x15 0000000000000000       03-20 10:08:53.681 401-401 /? A / DEBUG:x16 0000000000000001 x17 00000055c430a1d0 x18 0000000000000005 x19 0000000000000000       03-20 10:08:53.681 401-401 /? A / DEBUG:x20 00000000000002c0 x21 0000007f939e2000 x22 0000007f939e2000 x23 8000000000000000       03-20 10:08:53.681 401-401 /? A / DEBUG:x24 000000000000000e x25 0000000000008000 x26 0000000000000000 x27 0000000000000281       03-20 10:08:53.681 401-401 /? A / DEBUG:x28 0000000000000000 x29 0000007f89851bb0 x30 0000000000000280       03-20 10:08:53.681 401-401 /? A / DEBUG:sp 0000007f89851bb0 pc 0000007f939793a8 pstate 0000000060000000       03-20 10:08:53.731 401-401 /? A / DEBUG:回溯:       03-20 10:08:53.731 401-401 /? A / DEBUG:#00 pc 00000000000463a8 /system/lib64/libc.so(dlmalloc + 3608)       03-20 10:08:53.731 401-401 /? A / DEBUG:#01 pc 0000000000019650 /system/lib64/libc.so(malloc + 20)       03-20 10:08:53.731 401-401 /? A / DEBUG:#02 pc 0000000000000f7c /system/lib64/libstdc++.so(_Znwm + 16)       03-20 10:08:53.731 401-401 /? A / DEBUG:#03 pc 000000000003b430 /data/app/com.example.john.wemeet_11_debug-2/lib/arm64/libgdinamapv4sdk752.so       03-20 10:08:53.731 401-401 /? A / DEBUG:#04 pc 0000000000039678 /data/app/com.example.john.wemeet_11_debug-2/lib/arm64/libgdinamapv4sdk752.so       03-20 10:08:53.731 401-401 /? A / DEBUG:#05 pc 000000000000bba0 /data/app/com.example.john.wemeet_11_debug-2/lib/arm64/libgdinamapv4sdk752.so(am_mapengine_new + 28)       03-20 10:08:53.731 401-401 /? A / DEBUG:#06 pc 000000000000c4d8 /data/app/com.example.john.wemeet_11_debug-2/lib/arm64/libgdinamapv4sdk752ex.so(Java_com_autonavi_amap_mapcore_MapCore_nativeNewInstance + 136)       03-20 10:08:53.731 401-401 /? A / DEBUG:#07 pc 0000000000cabeb0 /data/app/com.example.john.wemeet_11_debug-2/oat/arm64/base.odex(偏移量0x7e3000)(长com.autonavi.amap.mapcore.MapCore.nativeNewInstance(java。 lang.String,java.lang.String)+180)       03-20 10:08:53.731 401-401 /? A / DEBUG:#08 pc 0000000000cb0140 /data/app/com.example.john.wemeet_11_debug-2/oat/arm64/base.odex(偏移量0x7e3000)(void com.autonavi.amap.mapcore.MapCore.newMap()+ 724)       03-20 10:08:53.731 401-401 /? A / DEBUG:#09 pc 0000000001128df8 /data/app/com.example.john.wemeet_11_debug-2/oat/arm64/base.odex(offset 0x7e3000)(void com.amap.api.mapcore.util.b.af( )+108)       03-20 10:08:53.731 401-401 /? A / DEBUG:#10 pc 0000000001128810 /data/app/com.example.john.wemeet_11_debug-2/oat/arm64/base.odex(offset 0x7e3000)(void com.amap.api.mapcore.util.ba(com。 amap.api.mapcore.util.b)+68)       03-20 10:08:53.731 401-401 /? A / DEBUG:#11 pc 0000000000ab9a24 /data/app/com.example.john.wemeet_11_debug-2/oat/arm64/base.odex(offset 0x7e3000)(void com.amap.api.mapcore.util.b $ 1.run ()104)       03-20 10:08:53.731 401-401 /? A / DEBUG:#12 pc 0000000075072128 /data/dalvik-cache/arm64/system@framework@boot.oat(offset 0x26bc000)       03-20 10:08:54.131 401-401 /? A / DEBUG:Tombstone写入:/ data / tombstones / tombstone_05       03-20 10:08:54.131 401-401 /? E / DEBUG:AM写入失败:管道损坏       03-20 10:08:54.151 469-875 /? E / logserver:process_one_event,找不到此事件(data_app_native_crash@1489975734160.txt)       03-20 10:08:54.341 1196-1973 /? E / InputDispatcher:channel&#39; a86922e com.example.john.wemeet_11_debug / com.example.john.wemeet_11_debug.ActivityLogin(server)&#39; 〜频道不可挽回地被打破,将被处置!       03-20 10:08:54.341 1196-1973 /? E / InputDispatcher:channel&#39; 8015f92 com.example.john.wemeet_11_debug / com.example.john.wemeet_11_debug.ActivityMain(server)&#39; 〜频道不可挽回地被打破,将被处置!       03-20 10:08:54.351 1196-4366 /? E / HsmCoreServiceImpl:代码中的onTransact是:102       03-20 10:08:54.391 3789-3815 /? E / DeviceInfo:文件不存在:/ proc / ddr_info       03-20 10:08:54.391 3789-3815 /? E / DeviceInfo:无法获得ddr,默认值:NULL       03-20 10:08:54.571 3789-3814 /? E / PackageLogInfoManager:checkPackageLogState,cr:android.app.ContextImpl$ApplicationContentResolver@e13648a,packageNames:null       03-20 10:08:54.821 9187-9187 /? E / wpa_supplicant:RSSI = -41; LINKSPEED = 72; NOISE = 9999; FREQUENCY = 2427;       03-20 10:08:54.821 1196-1994 /? E / WifiConfigStore:updateConfiguration freq = 2427 BSSID = d4:ee:07:20:83:0c RSSI = -41&#34; plusub&#34; WPA_PSK       03-20 10:08:55.081 1196-1214 /? E / Sensors:setDelay,173:handle = 0,ns = 10000000       03-20 10:08:55.081 1196-1214 /? E / Sensors:setDelay,855:handle = 0,ns = 10000000       03-20 10:08:55.081 1196-1971 /? E /传感器:读取文件,buf = 4

FragmentSetting:

package com.example.john.wemeet_11_debug;
import android.Manifest;
import android.content.DialogInterface;
import android.graphics.Bitmap;
import android.net.Uri;
import android.os.Bundle;
import android.os.Environment;
import android.support.annotation.Nullable;
import android.support.v7.app.AlertDialog;
import android.util.Log;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.CompoundButton;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.Switch;
import android.widget.TextView;
import android.widget.Toast;
import com.bumptech.glide.Glide;
import com.jph.takephoto.app.TakePhoto;
import com.jph.takephoto.app.TakePhotoFragment;
import com.jph.takephoto.compress.CompressConfig;
import com.jph.takephoto.model.CropOptions;
import com.jph.takephoto.model.TResult;
import com.zhy.m.permission.MPermissions;
import net.qiujuer.genius.ui.widget.EditText;
import java.io.File;
import static com.example.john.wemeet_11_debug.UtilsFinalArguments.IS_ADAPTED_ORIENTATION;
import static com.example.john.wemeet_11_debug.UtilsFinalArguments.REQUEST_CAMERO;
public class FragmentSetting extends TakePhotoFragment implements View.OnClickListener, CompoundButton.OnCheckedChangeListener {
    //fragment_setting's view
    private View view;
    private ImageView containerImageView;
    private LinearLayout layout;
    private UtilsRenderScriptGaussianBlur blur;
    //layout UIs
    private Button chooseIconBtn;
    private ImageView userIconUIImg;
    private TextView userNameTxv;  
    ...

    //TakePhoto
    private TakePhoto takePhoto;
    private CropOptions cropOptions;
    private CompressConfig compressConfig;
    private File file;
    private Uri imageUri;
    //User Data
    private String userSex, userName;
    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        view = inflater.inflate(R.layout.fragment_setting,container,false);
        return view;
    }

    @Override
    public void onActivityCreated(Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);

        initView();
        initClickEvent();
        initData();
    }

    /**
     *
     */
    private void initView() {
        userIconUIImg = (ImageView) view.findViewById(R.id.uiImageView_userIcon);  
        chooseIconBtn = (Button) view.findViewById(R.id.btn_choose_icon);  
...
    }
    private void initClickEvent() {
        chooseIconBtn.setOnClickListener(this);
...
    }

    private void initData() {
        takePhoto = getTakePhoto();
        cropOptions = new CropOptions.Builder().setAspectX(1).setAspectY(1).setWithOwnCrop(false).create();
        compressConfig=new CompressConfig.Builder().setMaxSize(50*1024).setMaxPixel(800).create();
        takePhoto.onEnableCompress(compressConfig,true);  //设置为需要压缩
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()){
            case R.id.btn_choose_icon:
                MPermissions.requestPermissions(getActivity(), REQUEST_CAMERO, Manifest.permission.CAMERA);
                startDialog();
                break;
                 ...
            default:
                break;
        }
    }

    @Override
    public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
        if (isChecked) {
            IS_ADAPTED_ORIENTATION = 1;
        } else {
            IS_ADAPTED_ORIENTATION = 0;
        }
    }

    @Override
    public void takeSuccess(TResult result) {
        super.takeSuccess(result);
        //Toast.makeText(getActivity(), "OK", Toast.LENGTH_SHORT).show();
        String iconPath = result.getImage().getOriginalPath();
        Log.i("TAG", iconPath);
        Glide.with(this).load(iconPath).into(userIconUIImg);
        Log.i("TAG", iconPath);
    }

    //
    @Override
    public void takeFail(TResult result, String msg) {
        super.takeFail(result, msg);
    }

    //
    @Override
    public void takeCancel() {
        super.takeCancel();
    }

    /**
     * 弹出Dialog选择头像
     */
    private void startDialog() {


        dialogChooseIcon = new DialogChooseIcon(getActivity(), new DialogChooseIcon.IDialogChooseIconEventListener() {
            @Override
            public void listenDialogChooseIconEvent(int chooseFlag) {
                switch (chooseFlag) {
                    case 0:
                        file=new File(Environment.getExternalStorageDirectory(), "/temp/"+System.currentTimeMillis() + ".jpg");
                        if (!file.getParentFile().exists())file.getParentFile().mkdirs();
                        imageUri = Uri.fromFile(file);
                        takePhoto.onPickFromCaptureWithCrop(imageUri,cropOptions);
                        break;
                    case 1:
                        file=new File(Environment.getExternalStorageDirectory(), "/temp/"+System.currentTimeMillis() + ".jpg");
                        if (!file.getParentFile().exists())file.getParentFile().mkdirs();
                        imageUri = Uri.fromFile(file);
                        takePhoto.onPickFromGalleryWithCrop(imageUri, cropOptions);
                        break;
                    default:
                        break;
                }
            }
        });
        Window dialog_window = dialogChooseIcon.getWindow();  //获取到当前Activity的Window
        dialog_window.setGravity(Gravity.CENTER | Gravity.BOTTOM);  //设置对话框的位置
        WindowManager.LayoutParams dialog_window_attributes = dialog_window.getAttributes();  //获取到LayoutParams
        dialog_window_attributes.width = WindowManager.LayoutParams.MATCH_PARENT;  //设置Dialog的长宽
        dialog_window_attributes.height = WindowManager.LayoutParams.WRAP_CONTENT;
        dialog_window_attributes.windowAnimations = R.style.dialogAnim;
        dialog_window.setAttributes(dialog_window_attributes);

        dialogChooseIcon.show();
        dialogChooseIcon.setOnCancelListener(new DialogInterface.OnCancelListener() {
            @Override
            public void onCancel(DialogInterface dialog) {
                containerImageView.setVisibility(View.GONE);

                layout.setVisibility(View.VISIBLE);
            }
        });
        dialogChooseIcon.setOnDismissListener(new DialogInterface.OnDismissListener() {
            @Override
            public void onDismiss(DialogInterface dialog) {
                containerImageView.setVisibility(View.GONE);

                layout.setVisibility(View.VISIBLE);
            }
        });

    }

}

```

ActivityMain.java

package com.example.john.wemeet_11_debug;

import android.Manifest;
import android.content.Context;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.Color;
import android.os.Build;
import android.os.Bundle;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.NavigationView;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.support.v4.view.GravityCompat;
import android.support.v4.widget.DrawerLayout;
import android.support.v7.app.ActionBarDrawerToggle;
import android.support.v7.widget.Toolbar;
import android.view.KeyEvent;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.view.WindowManager;
import android.widget.TextView;
import android.widget.Toast;

import com.zhy.m.permission.MPermissions;
import com.zhy.m.permission.PermissionDenied;
import com.zhy.m.permission.PermissionGrant;
import static com.example.john.wemeet_11_debug.UtilsFinalArguments.REQUEST_ACCESS_COARSE_LOCATION;
import static com.example.john.wemeet_11_debug.UtilsFinalArguments.REQUEST_ACCESS_FINE_LOCATION;
import static com.example.john.wemeet_11_debug.UtilsFinalArguments.REQUEST_USUAL;

public class ActivityMain extends BaseActivity
        implements NavigationView.OnNavigationItemSelectedListener {
    //基本的UI部件
    private Toolbar toolbar;
    private FloatingActionButton fab;
    private DrawerLayout drawer;
    private ActionBarDrawerToggle toggle;
    private NavigationView navigationView;
    private TextView toolbarTitle;

    //碎片管理FragmentManager
    private FragmentManager mFragmentManager = null;
    /**
     * 1
     */
    private FragmentMainMap fragmentMainMap = null;
    private FragmentSetting fragmentSetting = null;
    private FragmentTransaction mFragmentTransaction = null;


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

        initBaseView();

        initMapFirst();
    }

    @SuppressWarnings("StatementWithEmptyBody")
    @Override
    public boolean onNavigationItemSelected(MenuItem item) {
        // Handle navigation view item clicks here.
        int id = item.getItemId();
        mFragmentTransaction = mFragmentManager.beginTransaction();

        switch (id){
            case R.id.seek_mode_menu_item:
                hideAllFragment(mFragmentTransaction);
                /**
                 * 2
                 */
                if(fragmentMainMap == null){
                    fragmentMainMap = new FragmentMainMap();
                    mFragmentTransaction.add(R.id.main_fragment_layout,fragmentMainMap);
                }else{
                    mFragmentTransaction.show(fragmentMainMap);
                }
                toolbarTitle = (TextView) findViewById(R.id.toolbar_title);
                toolbarTitle.setText("WeMeet");
                break;
            case R.id.setting_menu_list:
                hideAllFragment(mFragmentTransaction);
                if (fragmentSetting == null){
                    fragmentSetting = new FragmentSetting();
                    mFragmentTransaction.add(R.id.main_fragment_layout,fragmentSetting);
                }else {
                    mFragmentTransaction.show(fragmentSetting);
                }
                //修改标题栏标题
                toolbarTitle = (TextView) findViewById(R.id.toolbar_title);
                toolbarTitle.setText(R.string.action_settings);
                break;
            default:
                break;
        }
        mFragmentTransaction.commit();
        //点击某一项菜单项取消选中状态并关闭drawer
        //item.setCheckable(false);
        drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
        drawer.closeDrawer(GravityCompat.START);
        return true;
    }

    private void initBaseView() {
        //Toolbar
        toolbar = (Toolbar) findViewById(R.id.toolbar);
        if (toolbar != null) {
            toolbar.setTitle("");
            toolbar.setBackgroundResource(R.drawable.background_toolbar);
        } else {
            Toast.makeText(this, "toolbar == null!", Toast.LENGTH_SHORT).show();
        }
        toolbarTitle = (TextView) findViewById(R.id.toolbar_title);
        setSupportActionBar(toolbar);
        //DrawerLayout
        drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
        toggle = new ActionBarDrawerToggle(
                this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
        drawer.setDrawerListener(toggle);
        toggle.syncState();
        //NavigationView
        navigationView = (NavigationView) findViewById(R.id.nav_view);
        if (navigationView != null) {
            navigationView.setNavigationItemSelectedListener(this);
        } else {
            Toast.makeText(this, "navigationView == null!", Toast.LENGTH_SHORT).show();
        }
        mFragmentManager = getSupportFragmentManager();

        //nav_header
        View headerLayout = navigationView.getHeaderView(0);   //没有这一行时,drawerUserNameTxv的findviewById的结果是null
        drawerUserNameTxv = (TextView) headerLayout.findViewById(R.id.txt_name);
        drawerUserIcon = (UtilsCircleImageView) headerLayout.findViewById(R.id.imageView);

        MPermissions.requestPermissions(ActivityMain.this, REQUEST_ACCESS_FINE_LOCATION, Manifest.permission.ACCESS_FINE_LOCATION);
        MPermissions.requestPermissions(ActivityMain.this, REQUEST_ACCESS_COARSE_LOCATION, Manifest.permission.ACCESS_COARSE_LOCATION);
    }

    /**
     * 初始化显示地图
     */
    private void initMapFirst() {
        /**
         *3
         */
        FragmentTransaction mFragmentTransaction = mFragmentManager.beginTransaction();
        if(fragmentMainMap == null){
            fragmentMainMap = new FragmentMainMap();
            mFragmentTransaction.replace(R.id.main_fragment_layout,fragmentMainMap);
        }else{
            mFragmentTransaction.show(fragmentMainMap);
        }
        mFragmentTransaction.commit();
    }

    /**
     * 隐藏所有Fragment
     * @param fragmentTransaction
     */
    private void hideAllFragment(FragmentTransaction fragmentTransaction){
        /**
         * 4
         */
        if (fragmentMainMap != null){
            fragmentTransaction.hide(fragmentMainMap);
        }
        if (fragmentSetting != null){
            fragmentTransaction.hide(fragmentSetting);
        }
    }
}

的build.gradle

apply plugin: 'com.android.application'
//申请权限
apply plugin: 'com.neenbedankt.android-apt'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.3"

    sourceSets {
        main {
            jniLibs.srcDirs = ['libs']
        }
    }

    defaultConfig {
        applicationId "com.example.john.wemeet_11_debug"
        minSdkVersion 15
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"

        //高斯模糊处理
        renderscriptTargetApi 19
        renderscriptSupportModeEnabled true
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    compile 'com.android.support:appcompat-v7:23.4.0'
    compile 'com.android.support:design:23.4.0'
    //申请权限
    apt 'com.zhy:mpermission-compiler:1.0.0'
    compile 'com.zhy:mpermission-api:1.0.0'
    //Material Design
    compile 'net.qiujuer.genius:ui:2.0.0-beta4'
    //TakePhoto
    compile 'com.jph.takephoto:takephoto_library:4.0.3'

    testCompile 'junit:junit:4.12'
}

0 个答案:

没有答案