Android API-Demo MediaPlayer not playing videos from SD-Card - android

I installed the ApiDemos project, which can be found in <your-sdk-path>/sdk/samples (provided you installed samples with SDK manager). I tried the one for api17. I pushed a video file onto the sd card of my device (I tried a samsung tablet and a LG P990) with DDMS and set the Path of the video to:
path = Environment.getExternalStorageDirectory().getPath() + "/myvideo.mp4";
(That is the only part where I edited the ApiDemos example)
I checked that this path returns the actual path to the sdcard where I pushed to file to and it is, the video however is not played.
When I run the whole thing in a genymotion device, the video is played without a problem. Does anyone has an Idea whats wrong here?
Log
These are the lines that are logged when the video is tried to be loaded by the ApiDemo:
11-05 16:03:42.830 2305-2334/? E/Trace﹕ error opening trace file: No such file or directory (2)
11-05 16:03:42.838 2305-10023/? E/OMXCodec﹕ [LEGO] else flags = 0
11-05 16:03:42.955 2305-10023/? E/OMXCodec﹕ set buffer size variable to : 1572864
11-05 16:03:44.970 2305-10034/? E/OMXCodec﹕ [OMX.TI.DUCATI1.VIDEO.DECODER] ERROR(0x80001000, 0)
11-05 16:03:45.189 385-456/? E/WifiStateMachine﹕ set default RSSI: -200
11-05 16:03:46.986 2305-10023/? A/OMXCodec﹕ frameworks/av/media/libstagefright/OMXCodec.cpp:1821 CHECK_EQ( err,(status_t)OK) failed: -110 vs. 0
11-05 16:03:46.986 2305-10023/? A/libc﹕ Fatal signal 11 (SIGSEGV) at 0xdeadbaad (code=1), thread 10023 (TimedEventQueue)

If your Video is in the root of your sd Card then try:
videoView.setVideoPath("/sdcard/myvideo.mp4");
or try if you have a Directory named e.g "my_Videos"
path = Environment.getExternalStorageDirectory() + "//my_Videos//";
path += "myvideo.mp4";

Related

New getExternalFilesDir in Android R crashes in emulator because SD card is missing?

I'm trying to use non-deprecated methods for storing an image. However, the suggested context.getExternalFilesDir crashes in the emulator on the first line in the following.
val albumFolder = context.getExternalFilesDir(Environment.DIRECTORY_PICTURES)!!
i { "Writing file to ${albumFolder.absolutePath} "}
albumFolder.mkdirs()
check(albumFolder.exists() && albumFolder.canWrite()) { "Missing or non-writable folder: ${albumFolder.absolutePath}"}
It throws 2 errors, then dies on a NPE for the first line.
E/vold: Failed to find mounted volume for /storage/emulated/0/Android/data/MYAPP/files/Pictures/
W/ContextImpl: Failed to ensure /storage/emulated/0/Android/data/MYAPP/files/Pictures: android.os.ServiceSpecificException: (code -22)

Android - Eclipse: Trace Files

I have two issues--but first thing's first:
Dell Inspiron M5030: AMD Athlon II P360
Windows 7 Ultimate 32bit SP 1
Android ADT 21.0.1-543035
org.eclipse.platform.ide 3.8.0-I20120608-1200
EMULATOR:
4.0" WVGA (480x800:hdpi)
Android 4.2 (API 17)
armeabi-v7a
RAM:512, VM Heap:16
Internal Storage: 600MB
SDCard Size 128MB, Use Host GPU
In the onCreate of my activity i have these lines:
super.onCreate(savedInstanceState);
if (BuildConfig.DEBUG) {
Log.i(Constants.TAG_ACTSPLASH, "onCreate() Method called.");
Debug.startMethodTracing("actsplash");
}
In the onDestroy of my activity i have these lines:
super.onDestroy();
if (BuildConfig.DEBUG) {
Log.i(Constants.TAG_ACTSPLASH, "onDestroy()");
Debug.stopMethodTracing();
}
PROBLEM NUMBER ONE: In debug mode, after onCreate is called, Logcat says:
davlikvm: Unable to open trace file '/mnt/sdcard/actsplash.trace': Permission denied
NOTE: when running the apk on my Epic4G (Android 4.2) the trace file is created.
PROBLEM NUMBER TWO: The tracefile extracted from the Epic4G can't be processed.
(1) When running traceview I get the error:
The standalone version of traceview is deprecated. Please use Android Device Monitor (tools/monitor) instead. trace file './actsplash.trace' not found
(2) When running ADM ('%SDK%/tools/monitor.bat') and loading the trace file i get:
Failed to read the stack trace.
This article says something about a key file...is that what's missing? Any help would be appreciated!
The first problem can be fixed by adding the WRITE_EXTERNAL_STORAGE permission to your app, so that it can write to /sdcard. Alternatively, explicitly specify a filename for the trace file in your private app data storage area, and pull the file from there.
The second problem is "trace file not found", which is a direct result of the first. The third problem appears to be a variation of the second.
The trace file itself used to be split into "key" and "data" files, but those were combined into a single .trace file a long time ago.
The problem seems to be with the 4.2 emulator; the 4.1 emulator processed the trace file and (unlike the 4.2 emulator) allowed me to pull the file and load it in ADM (Android Debug Monitor).
For problem number 2:
Traceview can't resolve relative paths. I had to specify the full path to the tracefile (still using only the basename) starting with "C:/"
http://www.talkandroid.com/android-forums/android-games-applications/509-traceview-cant-find-trace-file.html

Failed to unmount /mnt/secure/staging

android Unable to access files in SD card ####Android无法访问SD卡中的文件
I am working on application where it create text files in the SD card.
I have a receiver which will execute logic to create files in SD card from that point I will keep on store some data into that .
So far it is working properly , but suddenly I stopped working.
I checked logcat output , I found some logs related to SD card mounting.
But do not have an idea to how to resolve this issue.
below are the log statements:
1.464 W/Vold ( 2357): Failed to unmount /mnt/secure/staging (Device or resource busy, retries 3, action 0)
08-23 07:26:31.783 E/ProcessKiller( 2357): Process logcat (3344) has open file /mnt/secure/staging/abc1.txt
08-23 07:26:31.783 E/ProcessKiller( 2357): Process logcat (3345) has open file /mnt/secure/staging/abc2.txt
08-23 07:26:32.845 W/Vold ( 2357): Failed to unmount /mnt/secure/staging (Device or resource busy, retries 2, action 1)
08-23 07:26:33.173 E/ProcessKiller( 2357): Process logcat (3344) has open file /mnt/secure/staging/abc1.txt
I have added permission android.permission.WRITE_EXTERNAL_STORAGE
I think it's just because you're use multiple thread to access file. So, try to use synchronized in your open file function.
synchronized void openFile(String filePath) {
// Code to open file
}
before writing the text file into SD-card you must always check the media state
if(Environment.getExternalStorageState().equalsIgnoreCase(Environment.MEDIA_MOUNTED))
{
// read or write file logic here //
}

Can we place folder(images) containing 40mb in assets folder in android?

I need to display images in my project from local sqlite database and so I kept them in assets folder. The size of the images folder is 40mb. Since my project contains lot many images I have chosen assets folder instead of drawable folder. But when I kept the 40mb size folder in assets my emulator is showing error and my app is not running.
In Console:
Installation error: INSTALL_FAILED_INSUFFICIENT_STORAGE
[2011-12-09 11:47:16 - Mccee] Please check logcat output for more details.
[2011-12-09 11:47:16 - Mccee] Launch canceled!
In Logcat
12-09 11:44:03.210: WARN/NetworkManagementSocketTagger(89): setKernelCountSet(10041, 0) failed with errno -2
12-09 11:44:03.220: WARN/InputManagerService(89): Starting input on non-focused client com.android.internal.view.IInputMethodClient$Stub$Proxy#414013c0 (uid=10041 pid=1049)
12-09 11:44:03.340: WARN/ActivityManager(89): Activity idle timeout for ActivityRecord{413ba658 com.android.myproject/.Select}
12-09 11:44:05.840: WARN/ThrottleService(89): unable to find stats for iface rmnet0
What could be the reason. I have searched in google and tried many links...like keeping -partition-size 1024 in default emulator options but didnt worked. Also I have created new emulator with 1GB size but even then it didnt worked. Could you please help me regarding this.
Thanks in Advance....
Yes, You can place a folder of size 40MB in your asset folder, The error of emulator is for not sufficient internal size of emulator, try your application on device. Also If your application is large sized advice you to if possible save your application on SDcard.

error while starting self-compiled android in vm

i am getting following errors on starting the android vm (compiled from froyo branch) in virtual-box 4.0.4
D/ALSAModule(1985)open called for devices 00000002 in mode 0...
E/ALSALib (1985)external/alsa-lib/src/pcm/pcm.c:2203:(snd_pcm_open_noupdate) Unknown PCM AndroidPlayback_Speaker_normal
E/ALSALib (1985)external/alsa-lib/src/pcm/pcm.c:2203:(snd_pcm_open_noupdate) Unknown PCM AndroidPlayback_Speaker
E/ALSALib (1985)external/alsa-lib/src/pcm/pcm.c:2203:(snd_pcm_open_noupdate) Unknown PCM AndroidPlayback
D/ (1985)[external/alsa-lib/src/pcm/pcm_hw.c]:snd_pcm_hw_prepare
I/ALSAModule(1985)Initialized ALSA PLAYBACK device default
it seems the problem is with sound device (or ALSA) but I am not sure. Any help is appreciated.
I think that you are missing alsa config in your system image. Check if /system/etc/asound.conf is present or not. Try creating a new config file with default configuration. Check THIS for more details

Categories

Resources