Android模拟器sd卡权限
我正在使用 Eclipse 并尝试让 Android 模拟器让我写入 SD 卡。
当我在手机上安装该应用程序时,它会提示接受所需的权限......并且该程序可以运行。当我尝试使用模拟器测试应用程序时,我没有收到提示,并且使用该程序会导致权限被拒绝。
我尝试重新创建我的 avd...并将 SD 卡大小设置为 4Gb。 显然我在 AndroidManifest.xml 中有使用权限行... 就是这样:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="j**.B********.App"
android:versionCode="1"
android:versionName="1.0">
<uses-sdk android:minSdkVersion="10" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<application android:icon="@drawable/icon" android:label="@string/app_name" android:permission="android.permission.WRITE_EXTERNAL_STORAGE">
<activity android:name=".NotesActivity"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
那么如何让模拟器授予我写入 SD 卡的权限呢?我所做的工作在手机上有效......那么为什么不在模拟器上呢?
刚才在模拟器的开发工具终端中,我尝试导航到 SD 卡...权限被拒绝。
查看 eclipse DDMS 视角中的权限,它们是 d---------
编辑:我让它工作了。
我必须从 avd 管理器手动启动模拟器。当你点击运行时让 Eclipse 启动模拟器似乎会使某些东西短路。
I'm using eclipse and trying to get the android emulator to let me write to the sdcard.
when I install the app on my phone it prompts to accept the permission required... and the program works. When I try using the emulator to test the app I don't get prompted and using the program results in permission denied.
I've tried recreating my avd... and have the sdcard size set to 4Gb.
Obviously I have the uses permission line in the AndroidManifest.xml...
and here it is:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="j**.B********.App"
android:versionCode="1"
android:versionName="1.0">
<uses-sdk android:minSdkVersion="10" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<application android:icon="@drawable/icon" android:label="@string/app_name" android:permission="android.permission.WRITE_EXTERNAL_STORAGE">
<activity android:name=".NotesActivity"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
So how do I get the emulator to give me the permission to write to the sdcard? What I've done works on the phone... so why not in the emulator?
Just now in the dev tools terminal in the emulator I tried to navigate to the sdcard... permission denied.
Looking at permissions in eclipse DDMS perspective and they are d---------
Edit: I got it to work.
I had to manually start the emulator from the avd manager. Letting eclipse start the emulator when you hit run seems to short circuit something.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
打开 AVD 管理器,选择适当的模拟器,然后从右侧面板中选择编辑。
然后在硬件选项上,你会看到很多属性,现在,点击新建按钮,选择SD卡支持,点击确定。
现在您可以在模拟器中使用您的 SD 卡。
Open the AVD manager, select the appropriate emulator, and choose Edit from right panel.
Then on the hardware option, you will see many properties, now, click the New button, and choose SD card support, click Ok.
Now you can use your SD-Card within the emulator.
在Android 6和模拟器中,我们需要通过以下方式授予权限手册
设置>应用程序
选择您想要授予权限的应用程序,然后授予权限,如下所示:
分享给遇到此问题的人(我使用 android studio)
In Android 6, and Emulator, We need to grand permission manual by
Setting > Apps
Chose App that you want to grant permission then grant permission like this:
Share for someone face this issue (I use android studio)
我在使用 Gingerbread 模拟器时经常遇到这个问题...由于某种原因,即使清单权限已到位,模拟器也根本不允许访问。
解决方案:
访问android shell(即adb shell)并输入:
mount -o remount,rw /sdcard
I'm getting this problem A LOT with the Gingerbread emulator... for some reason the emulator simply doesn't permit access eventhough the manifest permission is in place.
Solution:
access android shell (i.e. adb shell) and type in:
mount -o remount,rw /sdcard
只是猜测 - 但也许您已经为模拟器配置了 0 个外部存储?
Just a guess-- but perhaps you've configured the emulator with 0 external storage?