后记:

本文解决了VirtualBox里共享文件夹的两个问题:

1. 无法访问Host机的共享文件夹;

2. 无法在共享文件夹里创建symbol link;

但解决完上面的问题之后,最终virtualbox用共享文件夹编译还是会遇到问题。

故事:用mac系统,但芯片厂商提供的方案里没有提供mac系统编译android,只好装了虚拟机。虚拟机里parallels desktop算是比较好用,不过坑爹的是,编译时期make命令挂了,提示"segmentation fail",Google未果。只好重新启用virtualbox。

在虚拟机管理里设置了共享文件夹,之后发现权限不够:

➜~ls/media/sf_AndroidBuildls:无法打开目录/media/sf_AndroidBuild:权限不够

解决方法是用mount命令挂载进来

➜~sudomkdir-m755/mnt/AndroidBuild➜~sudomount-tvboxsf-oAndroidBuild/mnt/AndroidBuild

mount命令至少需要知道三个信息:

  1. 要加载对象的文件系统类型:vboxsf

  2. 要加载对象的设备名称:AndroidBuild,就是在虚拟机管理设置的名字

  3. 要加载到哪个目录下:/mnt/AndroidBuild

挂载之后,当前用户没有写权限,加上参数`-o`:

➜~sudomount-tvboxsf-orw,uid=1000,gid=1000AndroidBuild/mnt/AndroidBuild

其中uid和gid表示当前用户的id,可以用`id`命令查到:

➜~idcaohonguid=1000(caohong)gid=1000(caohong)groups=1000(caohong),4(adm),24(cdrom),27(sudo),30(dip),46(plugdev),109(lpadmin),124(sambashare)

结果如下:

➜~/mnt/AndroidBuild/LL95mount|grepvboxsfAndroidBuildon/media/sf_AndroidBuildtypevboxsf(gid=999,rw)AndroidBuildon/mnt/AndroidBuildtypevboxsf(uid=1000,gid=1000,rw)

这下可以了吧,你还会遇到编译时的错误:“ln: 无法创建符号链接"out/target/": 只读文件系统”

答案在这儿找到:cannot create symlinks in virtualbox shared foldersvirtualbox在某版本之后禁用了在共享文件夹里创建链接(symbol link),workaround的方法是:

➜~VBoxManagesetextradataubuntu64VBoxInternal2/SharedFoldersEnableSymlinksCreate/AndroidBuild1➜~VBoxManagegetextradataubuntu64enumerateKey:GUI/InfoDlgState,Value:400,450,normalKey:GUI/LastCloseAction,Value:PowerOffKey:GUI/LastGuestSizeHint,Value:640,480Key:GUI/LastNormalWindowPosition,Value:32,44,640,342,maxKey:GUI/LastScaleWindowPosition,Value:20,52,1245,694,maxKey:GUI/VirtualScreenToHostScreen0,Value:1Key:VBoxInternal2/SharedFoldersEnableSymlinksCreate/AndroidBuild,Value:1

`ubuntu64`是虚拟机的名字,`AndroidBuild`是共享文件夹的名字,设置成功后用`VBoxManage getextradata`可以查到,重启搞定

更多相关文章

  1. android ndk编译x264开源(用于android的ffmpeg中进行软编码)
  2. Android(安卓)bluetooth介绍(四): a2dp connect流程分析
  3. [android]编译时出现/usr/bin/ld: skipping incompatible /usr/l
  4. 编译android的linux内核
  5. Android(安卓)命令行编译、打包生成apk文件
  6. Ionic 运行报错No resource identifier found for attribute 'ap
  7. Android热更新框架Tinker无法更新?
  8. 使用sencha cmd创建android应用
  9. flutter-使用第三方库,编译和运行版本不一致问题 2

随机推荐

  1. Android(安卓)Architecture Blueprints(架
  2. Android中的.9.png图形的机制及制作和使
  3. android HOME、back(按钮、事件)截取获得,综
  4. 【凯子哥带你夯实应用层】Android的Googl
  5. Android(安卓)So加载的路径选择以及注意
  6. Android之Android(安卓)apk动态加载机制
  7. [置顶] Android(安卓)popwindow和fragmen
  8. android 源码设计模式之--代理模式(Proxy
  9. Android(安卓)UI总结 Android(安卓)和H5
  10. Android自定义控件系列案例【二】