I wrote an Android app which runs without problems on every phone I tried except Samsung S3. What happens is that, while my app is running, other background processes (other apps, that is) will start dying. For example, after some time of using my app, Live Wallpaper will die, and user will get a black background on his phone after exiting my app. And finally, after some time of using it, my app is also killed by OS. What's frustrating is that I cannot see any error message in log which would give me a hint as to what exactly is the problem.
This happens only on Samsung S3 (and not on S2, for example).
I thought it was memory related, since my app is very memory intensive (it is loading a lot of images from the web), but I can't see any "no memory" errors in log.
I also suspected that the HTTP framework I am using could be buggy, so I switched from Apache HttpComponents to java.net.HttpURLConnection, but it didn't help.
Any idea about why this is happening or a hint on how to debug it would be appreciated.
Here is an excerpt from the log which shows some background processes dying (for example, Live Wallpaper):
01-07 01:57:37.245: I/InputDispatcher(2296): Delivering touch to current input target: action: 0x1
01-07 01:57:37.505: D/dalvikvm(29490): GC_FOR_ALLOC freed 1535K, 17% free 28032K/33735K, paused 71ms, total 71ms
01-07 01:57:37.580: D/dalvikvm(6718): WAIT_FOR_CONCURRENT_GC blocked 0ms
01-07 01:57:37.620: D/dalvikvm(6718): GC_EXPLICIT freed 91K, 9% free 17663K/19399K, paused 3ms+5ms, total 40ms
01-07 01:57:38.190: I/InputReader(2296): Touch event's action is 0x0 (deviceType=0) [pCnt=1, s=0.428 ]
01-07 01:57:38.190: I/InputDispatcher(2296): Delivering touch to current input target: action: 0x0
01-07 01:57:38.190: I/InputDispatcher(2296): Delivering touch to current input target: action: 0x0
01-07 01:57:38.190: I/InputDispatcher(2296): Delivering touch to current input target: action: 0x0
01-07 01:57:38.190: I/InputDispatcher(2296): Delivering touch to current input target: action: 0x0
01-07 01:57:38.190: I/InputDispatcher(2296): Delivering touch to current input target: action: 0x0
01-07 01:57:38.335: I/InputReader(2296): Touch event's action is 0x1 (deviceType=0) [pCnt=1, s=]
01-07 01:57:38.335: I/InputDispatcher(2296): Delivering touch to current input target: action: 0x1
01-07 01:57:38.335: I/InputDispatcher(2296): Delivering touch to current input target: action: 0x1
01-07 01:57:38.335: I/InputDispatcher(2296): Delivering touch to current input target: action: 0x1
01-07 01:57:38.750: D/dalvikvm(29490): GC_FOR_ALLOC freed 1688K, 18% free 27981K/33735K, paused 114ms, total 114ms
01-07 01:57:39.695: W/PowerManagerService(2296): Timer 0x3->0x3|0x0
01-07 01:57:39.700: D/PowerManagerService(2296): setTimeoutLocked::SmartSleep : after19500
01-07 01:57:39.930: I/InputReader(2296): Touch event's action is 0x0 (deviceType=0) [pCnt=1, s=0.429 ]
01-07 01:57:39.930: I/InputDispatcher(2296): Delivering touch to current input target: action: 0x0
01-07 01:57:39.930: I/InputDispatcher(2296): Delivering touch to current input target: action: 0x0
01-07 01:57:39.930: I/InputDispatcher(2296): Delivering touch to current input target: action: 0x0
01-07 01:57:39.930: I/InputDispatcher(2296): Delivering touch to current input target: action: 0x0
01-07 01:57:39.930: I/InputDispatcher(2296): Delivering touch to current input target: action: 0x0
01-07 01:57:40.020: D/DeviceInfo(2296): SysScope Service has unexpectedly disconnected!
01-07 01:57:40.065: I/InputReader(2296): Touch event's action is 0x1 (deviceType=0) [pCnt=1, s=]
01-07 01:57:40.065: I/InputDispatcher(2296): Delivering touch to current input target: action: 0x1
01-07 01:57:40.065: I/InputDispatcher(2296): Delivering touch to current input target: action: 0x1
01-07 01:57:40.065: I/InputDispatcher(2296): Delivering touch to current input target: action: 0x1
**01-07 01:57:40.080: I/ActivityManager(2296): Process com.android.smspush (pid 28031) (adj 1) has died.**
01-07 01:57:40.090: W/WallpaperService(2296): Wallpaper service gone: ComponentInfo{com.sec.ccl.csp.app.secretwallpaper.themetwo/com.sec.ccl.csp.app.secretwallpaper.themetwo.SecretWallpaperService}
01-07 01:57:40.125: D/KeyguardViewMediator(2296): setHidden false
**01-07 01:57:40.135: I/ActivityManager(2296): Process com.android.server.device.enterprise:remote (pid 28016) (adj 1) has died.**
**01-07 01:57:40.145: I/ActivityManager(2296): Process com.sec.ccl.csp.app.secretwallpaper.themetwo (pid 29715) (adj 1) has died.**
01-07 01:57:40.285: D/dalvikvm(29490): GC_CONCURRENT freed 1616K, 17% free 28289K/33735K, paused 27ms+21ms, total 178ms
01-07 01:57:40.285: D/dalvikvm(29490): WAIT_FOR_CONCURRENT_GC blocked 112ms
01-07 01:57:40.445: D/dalvikvm(2296): GC_CONCURRENT freed 1869K, 59% free 24186K/57991K, paused 26ms+12ms, total 197ms
01-07 01:57:40.660: D/dalvikvm(29490): GC_CONCURRENT freed 1587K, 16% free 28622K/33735K, paused 3ms+7ms, total 51ms
01-07 01:57:40.685: D/KeyguardViewMediator(2296): setHidden false
There are 3 main reasons why a background process may be stoped, and I'll start from the less to the most probable:
You asked inadvertedly asked it to stop
Check your code for a bug that in awkward situations could request the service to stop. This could be within the service or in other activity from your application.
Uncaught exception
The service hit an uncaught exception. In this situation you should be able to see the information in the log, however the log don't last for long and you may be missing it.
To address this possibility you can set a DefaultUncaughtExceptionHandler like this:
UncaughtExceptionHandler currentHandler = Thread.getDefaultUncaughtExceptionHandler();
if (!(currentHandler instanceof DefaultExceptionHandler)) {
// Register default exceptions handler
Thread.setDefaultUncaughtExceptionHandler(
new DefaultExceptionHandler(currentHandler));
}
and define your DefaultExceptionHandler class to write to a temp file like this:
public class DefaultExceptionHandler implements UncaughtExceptionHandler {
private UncaughtExceptionHandler defaultExceptionHandler;
public DefaultExceptionHandler(UncaughtExceptionHandler pDefaultExceptionHandler)
{
defaultExceptionHandler = pDefaultExceptionHandler;
}
public void uncaughtException(Thread t, Throwable e) {
final Writer result = new StringWriter();
final PrintWriter printWriter = new PrintWriter(result);
e.printStackTrace(printWriter);
try {
String filename = "your_temp_filename";
BufferedWriter bw = new BufferedWriter(new FileWriter(filename));
bw.write(result.toString());
bw.flush();
bw.close();
} catch (Exception e2) {
e2.printStackTrace();
}
defaultExceptionHandler.uncaughtException(t, e);
}
}
Android OS asked the service to stop
Based on your description this is the most probable cause, and the one that you have less control over it.
There is no way to prevent the Android from killing your application when it needs aditional resources or when it believes your service is running for too long. The time allowed for the service to run before being killed may change from device to device, as it depends on resources allocated (i.e. images memory requirement change with screen size) and resources available.
In this case, the only reasonable thing you can do is starting you service as foreground service using:
startForeground(int id, Notification notification);
which informs the OS that your service has user visibility and will be put in the less probable to kill service's list. My experience using it with a few devices is that the service is kept running without interruption, even if you use several other applications in the mean time.
Regards.
I have tracked down the issue. It was actually a memory leak caused by Typeface.createFromAsset() method as described here. The memory that was leaking is native memory (not on Java heap), so that's why there were no OutOfMemory exceptions.
What is odd is that this issue should be fixed since Honeycomb (3.0), but in my case, it is happening on S3 which is running JellyBean (4.1). (I tried on several S3s, and they all have this issue). It would be interesting if someone with access to a different phone that runs JellyBean would test, so we could see if it reproduces there (the link I posted shows a simple way to reproduce it).
Related
Note: I am using Android Studio, compiling the C code with the NDK outside of Android Studio.
The following C code:
jintArray Java_com_xxx_yyy_MainActivity_processFrame(
JNIEnv* env, jobject thiz, jbyteArray inArray)
{
int i;
jsize inLength = (*env)->GetArrayLength(env, inArray);
int outLength = inLength/3*2; // YYYYUV
jbyte in[outLength];
(*env)->GetByteArrayRegion(env, inArray, 0, outLength, in);
jint out[outLength];
jintArray outArray = (*env)->NewIntArray(env, outLength);
int alpha = 255 << 24;
for (i=0;i<outLength;i++) {
// just use the Y to set the B for now
out[i]=alpha | in[i];
}
// No release needed since using GetXXXRegion
//(*env)->ReleaseByteArrayElements(env, inArray, in, JNI_ABORT);
(*env)->SetIntArrayRegion(env, outArray, 0, outLength, out);
return outArray;
}
is called from Java as follows:
System.out.println("Calling processFrame");
int[] rgb = processFrame(imageData);
System.out.println("Call completed");
Yet, I do see "Calling processFrame" on my console but do not get "Call completed." Instead, I get
07-14 15:41:20.219 25810-25945/com.xxx.yyy A/libc﹕ Fatal signal 11 (SIGSEGV) at 0x5ef78000 (code=2), thread 25945 (CAMERA_THREAD)
07-14 15:41:20.219 25810-25814/com.xxx.yyy D/dalvikvm﹕ GC_CONCURRENT freed 1K, 6% free 8579K/9048K, paused 2ms+1ms, total 13ms
07-14 15:41:20.299 128-415/? W/CameraService﹕ Disconnecting camera client 0x427b09a8 since the binder for it died (this pid 128)
07-14 15:41:20.299 493-784/? I/WindowState﹕ WIN DEATH: Window{413fb7d0 u0 com.xxx.yyy/com.xxx.yyy.MainActivity}
07-14 15:41:20.299 493-493/? I/ActivityManager﹕ Process com.xxx.yyy (pid 25810) has died.
07-14 15:41:20.299 493-784/? W/WindowManager﹕ Force-removing child win Window{41685140 u0 SurfaceView} from container Window{413fb7d0 u0 com.xxx.yyy/com.xxx.yyy.MainActivity}
07-14 15:41:20.299 493-493/? W/ActivityManager﹕ Force removing ActivityRecord{41397308 u0 com.xxx.yyy/.MainActivity}: app died, no saved state
07-14 15:41:20.309 493-493/? D/WindowManager﹕ adjustConfigurationLw, config:{1.0 ?mcc?mnc ?locale ?layoutDir sw800dp w1280dp h752dp 240dpi xlrg land ?uimode ?night finger -keyb/v/h -nav/v} mLidState:-1 mHasDockFeature:true mHasKeyboardFeature:true mHasHallSensorFeature:true config.hardKeyboardHidden:2
07-14 15:41:20.309 493-493/? W/NvCpuClient﹕ Failed to bind to service
Is there something inherently wrong with the way my C code is written and called from Java that could explain this error?
How do I debug errors occurring in the C code from Android Studio?
Note: Replacing the C function body with just:
return (*env)->NewIntArray(env, 1000);
allows the call to be made to C and to return, so the binding itself works, suggesting that the error "Failed to bind to service" is simply there because the process died and cannot be invoked again from Java a second time around (I am calling this processFrame in a loop).
UPDATE: Occasionally but not always, I do also get
Consumer closed input channel or an error occurred. events=0x9
as part of the error message. I really do not see why but that does seem related to my problem somehow. I shouldn't have to release outArray from the C code. Should I?
UPDATE 2: I isolated the issue: the error is caused by a memory allocation. The code executes properly for outLength=320*480 (or anything smaller than that), but when I got to SD (640*480), I get the error I described. Is any of my memory allocation incorrect in the C code I provided? Is there a more appropriate way of allocating a larger chunk of memory from the C code? Should malloc be used instead for out? Do I need to increase heap memory and if so, how?
The error is caused by
jint out[outLength];
This does not work for too large an array. Using malloc solved my problem. If there are other issues in my code, please let me know. Otherwise I will accept the answer and move on.
I have a strange behaviour. My App starts very fast when first started.
When starting the second time (closed the app before and checked with taskmanager that it is no longer running ) it runs very slow. 3rd time fast, 4th time slow. every second start runs slow. Its because my Garbage Collector starts working the second time, but I don't know why. Should a start of an App behaves always the same ?
My Step which is very slow is my decodeStream - Statement. I have about 100 small pictures (5 kbytes - 15kbytes) I want to load.
Log.v("DEBUG DRAWEVENT 71","load " + e.sEventTitle);
bm = BitmapFactory.decodeStream(new FileInputStream(fImage), null, o2);
Log.v("DEBUG DRAWEVENT 72","end load " + e.sEventTitle);
LogCat that shows Garbage-Collection activities ( Only every 2. start )
01-04 16:16:03.500: V/DEBUG DRAWEVENT 71(20427): load Title
01-04 16:16:03.641: D/dalvikvm(20427): GC_FOR_ALLOC freed 17K, 33% free 28448K/41924K, paused 138ms, total 138ms
01-04 16:16:03.641: I/dalvikvm-heap(20427): Grow heap (frag case) to 27.842MB for 34612-byte allocation
01-04 16:16:03.771: D/dalvikvm(20427): GC_FOR_ALLOC freed 0K, 33% free 28481K/41960K, paused 138ms, total 138ms
01-04 16:16:03.781: V/DEBUG DRAWEVENT 72(20427): end load Title
I am on API Level 12.
Any hints ?
New analysing facts : After first start the App runns still under cached processes (35MB). Cached Processes can be shown under settings->apps->Running->Show Cached Processes.
When stopping this process my second start runns fast too.
So the next question. How to prevent an app to be cached ?
Following the "Five minute quick start" documentation for uploading a file from an Android device to Google Drive, I've written a test application that successfully uploads a file but my attempt at copying the relevant code to a larger application doesn't upload a file because its Google Account Picker is always getting canceled:
the onActivityResult() result code is 0 (i.e.,
RESULT_CANCELED),
the onActivityResult() intent argument is null, and
the logcat (shown below) reveals that "Activity is launching as a new task, so
cancelling activity result."
04-22 02:04:25.098: D/alsa_ucm(162): snd_use_case_set(): uc_mgr 0x40e59388 identifier _verb value HiFi Lowlatency
04-22 02:04:25.098: D/alsa_ucm(162): Set mixer controls for Speaker enable 1
04-22 02:04:25.098: D/ACDB-LOADER(162): ACDB -> send_afe_cal
04-22 02:04:25.098: I/ActivityManager(526): START u0 {act=com.google.android.gms.common.account.CHOOSE_ACCOUNT cmp=com.google.android.gms/.common.account.AccountPickerActivity (has extras)} from pid 3484
04-22 02:04:25.098: W/ActivityManager(526): Activity is launching as a new task, so cancelling activity result.
04-22 02:04:25.108: D/alsa_ucm(162): Set mixer controls for HiFi Lowlatency enable 1
04-22 02:04:25.108: D/ALSAModule(162): Device value returned is hw:0,14
04-22 02:04:25.118: D/ALSAModule(162): setHardwareParams: reqBuffSize 1024 channels 2 sampleRate 48000
04-22 02:04:25.118: D/ALSAModule(162): setHardwareParams: buffer_size 2048, period_size 1024, period_cnt 2
04-22 02:04:25.188: D/dalvikvm(526): GC_FOR_ALLOC freed 565K, 15% free 18562K/21684K, paused 71ms, total 71ms
04-22 02:04:25.248: D/overlay(159): Unset pipe=VG0 dpy=0; Unset pipe=VG1 dpy=0; Unset pipe=RGB1 dpy=0
04-22 02:04:25.248: W/InputMethodManagerService(526): Window already focused, ignoring focus gain of: com.android.internal.view.IInputMethodClient$Stub$Proxy#41ebd7e0 attribute=null, token = android.os.BinderProxy#42018140
04-22 02:04:27.991: D/dalvikvm(526): GC_FOR_ALLOC freed 422K, 15% free 18564K/21684K, paused 65ms, total 66ms
04-22 02:04:28.011: I/ActivityManager(526): No longer want com.google.android.marvin.talkback (pid 5301): empty #17
04-22 02:04:28.241: D/overlay(159): Set pipe=RGB1 dpy=0; Set pipe=VG0 dpy=0; Set pipe=VG1 dpy=0;
04-22 02:04:28.672: D/overlay(159): Unset pipe=VG0 dpy=0; Unset pipe=VG1 dpy=0; Unset pipe=RGB1 dpy=0;
The code that launches the Google Account Picker is exactly the same in both applications but the picker gets canceled only in the larger application.
// Handle item selection
case R.id.action_select_account:
mCredential = GoogleAccountCredential.usingOAuth2(this, DriveScopes.DRIVE);
Intent intent2 = mCredential.newChooseAccountIntent();
showToast("intent extra: " + intent2.getStringExtra(AccountManager.KEY_ACCOUNT_NAME)); // TODO: remove after test
startActivityForResult(intent2, REQUEST_ACCOUNT_PICKER);
return true;
default:
return false;
The test application and the larger application are both debug versions, including the same jars (shown below), and running on the same device (Nexus 4, OS 4.2.2) but, as suggested in the five minute quickstart, each application has its own client ID generated by Google APIs Console.
The result of this cancellation is that the onActivityResult() runs as soon as the Google Account Picker gets drawn, well before an account is selected.
UPDATE:
After an approximately equal amount of trial and error, it turns out that removing the following from AndroidManifest.xml fixed the problem.
android:launchMode="singleInstance"
My initial question of why now shifts to why does the Google Account Picker in Android need to create multiple instances?
Thanks,
Greg
If you use singleInstance you permit no other activities to be part of its task. Use singleTask instead.
As stated on http://developer.android.com/guide/topics/manifest/activity-element.html#lmode
a few paragraphs down.
The "singleTask" and "singleInstance" modes also differ from each other in only one respect: A "singleTask" activity allows other activities to be part of its task. It's always at the root of its task, but other activities (necessarily "standard" and "singleTop" activities) can be launched into that task. A "singleInstance" activity, on the other hand, permits no other activities to be part of its task. It's the only activity in the task. If it starts another activity, that activity is assigned to a different task — as if FLAG_ACTIVITY_NEW_TASK was in the intent.
As described in the question's update, the account picker started working when I removed singleInstance launchMode from AndroidManifest.xml. I don't know if this single instance launch mode behavior is a bug or a lack of documentation, but I submitted it to the Android Issue Tracker: issue 54656
For some reason, the intent returned by account manager has singleTop set, which always causes your onActivityResult to fail immediately and return a 0 resultCode (Activity.RESULT_CANCELLED) or whatever. I had to zero-out the intent flags to prevent this
// prevent running AccountPicker as SingleTop which fails and calls onActivityResult immediately otherwise
intent.setFlags(0);
startActivityForResult(intent, AccountManagerUtils.GOOGLE_AUTH_REQUEST_CODE);
In my app I am sending an intent to update an appWidget. The problem is, from the logcat I can see that the intent is taking on average ten seconds to be received.
05-16 18:12:54.070: DEBUG/PHCA_Variable(7580): Broadcast sent
05-16 18:12:54.080: INFO/ActivityManager(274): Starting: Intent { flg=0x10000000 cmp=com.skipmorrow.phca/.WidgetDialogResponseActivity (has extras) } from pid 7580
05-16 18:12:54.100: WARN/ActivityManager(274): Trying to launch com.skipmorrow.phca/.WidgetDialogResponseActivity
05-16 18:12:54.170: DEBUG/InputTransport(274): Input channel constructed: name='40832a98 com.skipmorrow.phca/com.skipmorrow.phca.WidgetDialogResponseActivity (server)', ashmemFd=299, receivePipeFd=311, sendPipeFd=310
05-16 18:12:54.170: DEBUG/InputTransport(274): Input channel constructed: name='40832a98 com.skipmorrow.phca/com.skipmorrow.phca.WidgetDialogResponseActivity (client)', ashmemFd=304, receivePipeFd=309, sendPipeFd=313
05-16 18:12:54.170: DEBUG/InputTransport(274): Input channel destroyed: name='40832a98 com.skipmorrow.phca/com.skipmorrow.phca.WidgetDialogResponseActivity (client)', ashmemFd=304, receivePipeFd=309, sendPipeFd=313
05-16 18:12:54.180: DEBUG/InputTransport(7580): Input channel constructed: name='40832a98 com.skipmorrow.phca/com.skipmorrow.phca.WidgetDialogResponseActivity (client)', ashmemFd=66, receivePipeFd=67, sendPipeFd=68
05-16 18:12:54.460: INFO/ActivityManager(274): Displayed com.skipmorrow.phca/.WidgetDialogResponseActivity: +362ms
05-16 18:12:56.140: INFO/InputDispatcher(274): Delivering key to current input target: action: 0, channel '40832a98 com.skipmorrow.phca/com.skipmorrow.phca.WidgetDialogResponseActivity (server)'
05-16 18:12:56.260: INFO/InputDispatcher(274): Delivering key to current input target: action: 1, channel '40832a98 com.skipmorrow.phca/com.skipmorrow.phca.WidgetDialogResponseActivity (server)'
05-16 18:12:56.390: DEBUG/InputTransport(7580): Input channel destroyed: name='40832a98 com.skipmorrow.phca/com.skipmorrow.phca.WidgetDialogResponseActivity (client)', ashmemFd=66, receivePipeFd=67, sendPipeFd=68
05-16 18:13:03.350: DEBUG/PHCA_PhcaAppWidgetProvider(7580): onReceive(); action = android.appwidget.action.APPWIDGET_UPDATE
The only thing I see that looks a little fishy is a warning that an activity is starting. Why would that be a warning? Other than that, everything seems ok.
The code to send the intent is nothing special:
Log.d(MY_DEBUG_TAG, "UpdateAppWidgets()");
Intent i = new Intent();
i.setAction(AppWidgetManager.ACTION_APPWIDGET_UPDATE);
ComponentName phcaWidget = new ComponentName(ctx, PhcaAppWidgetProvider.class);
i.putExtra("appWidgetIds", AppWidgetManager.getInstance(ctx).getAppWidgetIds(phcaWidget));
ctx.sendBroadcast(i);
Log.d(MY_DEBUG_TAG, "Broadcast sent");
And the onReceive in the appWidgetProvider is nothing special either. The Log statement is the first command.
What could cause an intent to take upwards of ten seconds to be received?
Skip
If the Activity you are sending the intent to does not yet exist, it has to be started. 10 seconds seems like a long time for starting an app, but not insane.
I have apps which run 5 times or more slower when in debug mode. If you are in debug mode, it could be that it will run much faster if not in debug mode. Generally, you can see logcat messages when not in debug mode, for a device connected to PC running eclipse IDE. If you can get that working, you should try running that way and see if it is faster. Also try running with phone unplugged from Eclipse entirely, it will be harder to tell if its faster but it might be.
In my application,showing video from sdcard folder or new taken video from Video intent in a VideoView in different Activity by passing file path of the video selected.
Now the problem is,
I have tested this app in my 2 devices LG Optimus Black and LG Optimus Me and it works like charm not problem no force close.
Now when i test this app in Samsung Fascinate 2.1 the video view shows the message "Can't Play Video" no matter i select existing video or take new one.
Remember the app is working fine with the above 2 devices.
In the ShowVideo activity i have button to upload the video, when i got the message "Can't Play Video" i been able to take video from the same path and upload it and can check that video at server side but video view didn't played that video.
So, the Video Path of the SDCard is not the problem thats for sure.
also the Video are of .3gp or .mp4 format only so the format is also supported by android
.
My Questions Are :
1)When the message "Can't Play Video" occurs?
2)What are the Solution for that?
and 3) What could be possible mistakes in my application?
here is the logcat output while i got that message but don't see any error/exception in that.
I/ActivityManager( 2227): Starting activity: Intent { cmp=com.zoodigapp.zoodig/com.zoodigapp.media.ShowVideo (has extras) }
V/SettingsProvider( 2227): system <- value=1.0 name=font_scale
V/SettingsProvider( 2227): property: sys.settings_system_version=26
V/SettingsProvider( 2227): notifying: content://settings/system/font_scale
D/HardwareService( 2227): Brightness NATIVE setBacklightBrightness running. light: 2bightness ==> 30 mode: 1
D/NetworkLocationProvider( 2227): onDataConnectionStateChanged 6
D/MobileDataStateTracker( 2227): default Received state= CONNECTING, old= CONNECTING, reason= (unspecified), apnTypeList= *
D/AGPSManagerService( 2227): state: CONNECTING apnName: Verizon reason: null
D/dalvikvm( 3326): GC freed 2472 objects / 140504 bytes in 73ms
I/File ( 3326): /sdcard/DCIM/Camera/video-2011-10-17-10-40-54.mp4
V/MediaStore( 3326): We probably run out of space, so create the thumbnail in memory.
I/MediaPlayerService( 2182): Use PV_PLAYER for url:/sdcard/DCIM/Camera/video-2011-10-17-10-40-54.mp4
E/MetadataDriver( 2182): MetadataDriver::setDataSource url file type is isAudiofile(0)
D/ ( 2182): SISO TEST registering PVMFRecognizerPluginFactory
D/ ( 2182): SISO TEST registering PVMFRecognizerPluginFactory success
E/MetadataDriver( 2182): isCommandSuccessful: Command id(0 and expected 0) and status (-17 and expected 1), data corruption (false) at state (4).
E/MetadataDriver( 2182): isCommandSuccessful: Command id(1 and expected 1) and status (-14 and expected 1), data corruption (false) at state (5).
E/MetadataDriver( 2182): captureFrame : time = 0
E/MetadataDriver( 2182): captureFrame : inputWidth = 0, inputHeight =0, bAspectratio=0, bResize=0
D/MediaUploader( 2492): UploadsQueue.getAllPending: elapsed msec=449
I/MediaUploader( 2492): UploadManager.uploadPendingItems: Found 1 items in queue.
I/Selected( 3326): =============Second
D/MediaUploader( 2492): isGphotosSynced: FALSE -- starting gphotos update refresh for -5709461173740324808
W/IInputConnectionWrapper( 3505): showStatusIcon on inactive InputConnection
I/copybit ( 2227): [createPP] fimc version : 50
I/MediaPlayerService( 2182): Use PV_PLAYER for url:/DCIM/Camera/video-2011-10-17-10-40-54.mp4
D/ ( 2182): SISO TEST registering PVMFRecognizerPluginFactory
D/ ( 2182): SISO TEST registering PVMFRecognizerPluginFactory success
D/ ( 2182): SISO TEST PVOMA1FFRecognizerFactory::CreateRecognizerPlugin()
D/ ( 2182): SISO TEST PVOMA1FFRecognizerFactory::CreateRecognizerPlugin() plugin found
D/ ( 2182): SISO TEST PVOMA1FFRecognizerFactory::DestroyRecognizerPlugin()
E/OsclDirectFileIO( 2182): [LargeFileSupport] OsclDirectFileIO::OpenFileOrSharedFd Error = -1
W/MediaPlayer( 3326): info/warning (1, 26)
E/PlayerDriver( 2182): Command PLAYER_SET_DATA_SOURCE completed with an error or info -4
E/MediaPlayer( 3326): SISO TEST MEDIA_ERROR
E/MediaPlayer( 3326): error (-4, -4)
W/PlayerDriver( 2182): PVMFInfoErrorHandlingComplete
V/MediaProvider( 2349): stopThumbWorkerSuspendTimer
V/MediaProvider( 2349): Resuming ThumbWorker
W/MediaProvider( 2349): Have message but no request?
I/System.out( 2647): interface name: null
I/MediaPlayer( 3326): Info (1,26)
E/MediaPlayer( 3326): Error (-4,-4)
D/VideoView( 3326): Error: -4,-4
D/MediaUploader( 2492): UploadManager.uploadPendingItems: Waiting for GPhotos sync
D/MediaUploader( 2492): UploadsQueue.getAllPending: elapsed msec=5
I/MediaUploader( 2492): UploadManager.uploadPendingItems: Found 1 items in queue.
I/POWER_OFF_TEST( 2227): mBatteryLevel = 38 mBatteryDecimalPoint = 1
D/MediaUploader( 2492): UploadsAsyncQueryHandler.notifiyDatabaseChangeListeners
D/MediaUploader( 2492): isGphotosSynced: FALSE -- update is in progress for -5709461173740324808
D/MediaUploader( 2492): UploadManager.uploadPendingItems: Waiting for GPhotos sync
D/MediaUploader( 2492): updateQueueState: RUNNING
I/GooglePlusOne( 2492): Starting new CAMERA_SYNC_CREATED request 1
I/ActivityManager( 2227): Displayed activity com.zoodigapp.zoodig/com.zoodigapp.media.ShowVideo: 1251 ms (total 1251 ms)
V/InputDevice( 2227): ID[0]=0 Dn (0=>1)
V/WindowManager( 2227): Dsptch >Window{47a67278 com.zoodigapp.zoodig/com.zoodigapp.media.ShowVideo paused=false}
D/dalvikvm( 2227): GC freed 4009 objects / 210024 bytes in 155ms
V/InputDevice( 2227): ID[0]=0 Up (1=>0)
V/WindowManager( 2227): Dsptch >Window{47a67278 com.zoodigapp.zoodig/com.zoodigapp.media.ShowVideo paused=false}
W/InputManagerService( 2227): Window already focused, ignoring focus gain of: com.android.internal.view.IInputMethodClient$Stub$Proxy#47d89250
D/dalvikvm( 2492): GC freed 11952 objects / 682568 bytes in 171ms
D/dalvikvm( 2647): GC freed 7435 objects / 656456 bytes in 26ms
D/dalvikvm( 2647): GC freed 3079 objects / 498304 bytes in 60ms
I/System.out( 2647): interface name: null
I/GooglePlusOne( 2492): CAMERA_SYNC_CREATED request 1 completed with code=200
D/MediaUploader( 2492): onGphotosChange: sawError=false; errs=0; retry=Wed Dec 31 17:00:00 America/Boise 1969; expiry=Mon Oct 17 10:56:20 America/Boise 2011
D/MediaUploader( 2492): UploadsQueue.getAllPending: elapsed msec=17
I/MediaUploader( 2492): UploadManager.uploadPendingItems: Found 1 items in queue.
D/MediaUploader( 2492): isGphotosSynced: TRUE for -5709461173740324808
D/MediaUploader( 2492): existsInGphotos: false info=name=video-2011-10-17-10-40-54.mp4 fileUri=content://media/external/video/media/37 fileSize=2477915;
D/MediaUploader( 2492): UploadManager.uploadPendingItems: starting upload...
D/MediaUploader( 2492): UploadManager.upload: info=name=video-2011-10-17-10-40-54.mp4 fileUri=content://media/external/video/media/37 fileSize=2477915
I/NetworkStat( 2678): Network type: MOBILE
I/NetworkStat( 2678): -------- mobile data network is NOT available as of now
D/NotificationService( 2227): enqueueNotification :: notification.defaults = 0, Notification.DEFAULT_SOUND = 1, notification.sound = null
D/dalvikvm( 2492): GC freed 4032 objects / 238248 bytes in 49ms
I/dalvikvm-heap( 2492): Grow heap (frag case) to 6.708MB for 524304-byte allocation
D/dalvikvm( 2492): GC freed 291 objects / 13392 bytes in 58ms
D/MediaUploader( 2492): UploadsAsyncQueryHandler.notifiyDatabaseChangeListeners
D/MediaUploader( 2492): GlsAuthorizer.getAuthToken: authTokenType=lh2; account=dprichards#gmail.com;
D/MediaUploader( 2492): executeWithAuthRetry: starting httpClient.execute #1
D/dalvikvm( 2870): GC freed 555 objects / 24144 bytes in 269ms
I/System.out( 2492): interface name: null
V/InputDevice( 2227): ID[0]=0 Dn (0=>1)
V/WindowManager( 2227): Dsptch >Window{47cf6308 com.zoodigapp.zoodig/com.zoodigapp.media.ShowVideo paused=false}
V/InputDevice( 2227): ID[0]=0 Up (1=>0)
V/WindowManager( 2227): Dsptch >Window{47cf6308 com.zoodigapp.zoodig/com.zoodigapp.media.ShowVideo paused=false}
D/dalvikvm( 2647): GC freed 7301 objects / 659064 bytes in 78ms
I/System.out( 2647): interface name: null
I/System.out( 2647): interface name: null
I/System.out( 2647): interface name: null
D/dalvikvm( 2647): GC freed 2654 objects / 324016 bytes in 149ms
I/System.out( 2647): interface name: null
D/MediaUploader( 2492): getStatusCode: status=HTTP/1.1 200 OK
D/MediaUploader( 2492): getStatusCode: status=HTTP/1.1 200 OK
D/MediaUploader( 2492): UPLOAD_START: uploadUrl=https://picasaweb.google.com/data/upload/resumable/media/create-session/feed/api/user/default/albumid/camera-sync?xmlerrors=1&upload_id=AEnB2Uqe2bdvyx5p31Ta-sS4ytggj07_6-uiKG_hCOc6sT1u8eqhvr-8oZdUT1uPHxuAxXphUiJXyq-i_8YaJlT2YLholp__Sw
D/MediaUploader( 2492): UploadManager.onProgress
V/MediaUploader( 2492): UploadManager.progressUpdate: guid=1351689615505998240; bytes=0
D/dalvikvm( 2647): GC freed 920 objects / 202544 bytes in 53ms
D/dalvikvm( 2492): GC freed 7362 objects / 498448 bytes in 73ms
D/MediaUploader( 2492): UploadsAsyncQueryHandler.notifiyDatabaseChangeListeners
D/dalvikvm( 2492): GC freed 658 objects / 129232 bytes in 42ms
I/dalvikvm-heap( 2492): Grow heap (frag case) to 7.250MB for 262160-byte allocation
D/dalvikvm( 2492): GC freed 0 objects / 0 bytes in 41ms
D/dalvikvm( 2492): GC freed 92 objects / 135128 bytes in 30ms
I/dalvikvm-heap( 2492): Grow heap (frag case) to 7.621MB for 524304-byte allocation
D/dalvikvm( 2492): GC freed 0 objects / 0 bytes in 44ms
D/MediaUploader( 2492): executeWithAuthRetry: starting httpClient.execute #1
D/dalvikvm( 2647): GC freed 576 objects / 53240 bytes in 182ms
V/InputDevice( 2227): ID[0]=0 Dn (0=>1)
V/WindowManager( 2227): Dsptch >Window{47cf6308 com.zoodigapp.zoodig/com.zoodigapp.media.ShowVideo paused=false}
V/InputDevice( 2227): ID[0]=0 Up (1=>0)
V/WindowManager( 2227): Dsptch >Window{47cf6308 com.zoodigapp.zoodig/com.zoodigapp.media.ShowVideo paused=false}
I/ActivityManager( 2227): Starting activity: Intent { cmp=com.zoodigapp.zoodig/.WriteMessage (has extras) }
If you find anything not described well please comment below.
Additional details (moved from comments):
They are merely of 1 minutes and the last one I tested and failed on Samsung that was of only 20 seconds. and sizes are mostly in MB not more than 20 MB right now.
The video is taken from the same device and immediately after taking that video I try to show in my activity same way other already stored video are also fine...actually after uploading that video I can see that video and can download also
1)When the message "Can't Play Video" occurs?
Android usually gives out this message, when it is not able to play the media content. The reasons for this to happen can be anything like
Unsupported file format
Unsupported codecs
Erroneous content
to mention a few.
2)What are the Solution for that?
Unless you have your own Media Framework in your app, there is no solution from the application level
3) What could be possible mistakes in my application?
Very unlikely the mistake is in your application. If you read the logs, you will see that the error seems to originate from the DataSource of opencore (Which version of android are you running anyway? It is still using Opencore instead of StageFright). It is recognizing it as a large file (> 2GB) and hence giving out the error "E/OsclDirectFileIO( 2182): [LargeFileSupport] OsclDirectFileIO::OpenFileOrSharedFd Error = -1"
The other thing to note is certain phones have better multimedia capability than the other phones, since OEM's can themselves improve the multimedia capability. So there is no written guarantee that all files can be played on all devices, even though it conforms to the supported formats, codecs mentioned by Android.
Its all about format problem, Some phone record the video in mp4 format and some in 3gp format, but in almost all phones the default mediaplayer support 3gp format. So the solution is you need to convert it into 3gp at the time of playing. This thing is difficult to handle in android, So at server end you can do it easily and hence whatever the format of the video is being uploaded you can download it in one format .3gp and it will work fine.
Make sure that your video is in MP4 format , but if still does not play or shows same error then fault is not with the code. Fault is in the video resolution. just check height and width of you video and match it with you video view component. There are lot of free video compressors Online available. So just compress your video and test it.
It will work.
Cheers!!!
I kept getting the same "Can't Play Video" message while trying to play video from the phone itself. First I didn't input good path to a file but there was anther interesting issue.
I've type path from the root, example /videoFileName.mp4 and I should have type it with sdcard in between like /sdcard/videoFileName.mp4
My Sony Ercisson Xperia Arc was connected as a usb mass device storage at the same time I was running my app through adb, so internal sd card was unmounted and file could not be found. I've discovered this when I tryed same code on Samsung Galaxy S which behaves differently when connected.
If you have mp4 file having H.264 baseline encoding and still you are unable to play video in your android device then it might be problem in .htAccess file on server side. It might be zipping .mp4 file. few devices are able to play video by unzipping it and stream it but not in all device cases. You need to change .htAccess file on server side. Change in output filter and include file format .mp4 to exclude it from being zip at streaming time.
SetEnvIfNoCase Request_URI \.(?:gif|jpe?g|png|swf|mp4)$ \ no-gzip dont-vary
Google recently open-sourced Exoplayer after Google IO 2014.
My experience with video playing with it was good so far.
https://github.com/google/ExoPlayer
I could stream videos from Dropbox/AWS
Stream videos from youtube.
Things still depend upon codecs supported by the device.
I had this same issue while using VideoView, while i tried to check all things regarding the video the issue was in the AndroidManifest.xml File, It was regarding the permission to use EXTERNAL STORAGE give it a shot it might solve the issue.
I came across the same problem and what worked for is adding the Internet permission to the manifest file since I am getting video from url.
<uses-permission android:name="android.permission.INTERNET"/>
This is how I am populating listview of videos.
//assign video
mVideosListView = (ListView) findViewById(R.id.videoListView);
//create videos
Video riverVideo = new Video("https://s3.amazonaws.com/androidvideostutorial/862009639.mp4");
Video carsVideo = new Video("https://s3.amazonaws.com/androidvideostutorial/862013714.mp4");
Video townVideo = new Video("https://s3.amazonaws.com/androidvideostutorial/862014159.mp4");
Video whiteCarVideo = new Video("https://s3.amazonaws.com/androidvideostutorial/862014159.mp4");
Video parkVideo = new Video("https://s3.amazonaws.com/androidvideostutorial/862014834.mp4");
Video busyCityVideo = new Video("https://s3.amazonaws.com/androidvideostutorial/862017385.mp4");
mVideosList.add(riverVideo);
mVideosList.add(carsVideo);
mVideosList.add(townVideo);
mVideosList.add(whiteCarVideo);
mVideosList.add(parkVideo);
mVideosList.add(busyCityVideo);
/***populate video list to adapter**/
mVideoAdapter = new VideoAdapter(this, mVideosList);
mVideosListView.setAdapter(mVideoAdapter);
I faced the same issue once. In My case only issue was fie format. i Just changed the video format to .mp4 and it works like charm on all the devices and emulator i used.
my suggestion is to check your video format first and then try other solutions.
For me was a problem with the codec used by video.
I installed the Any Video Converter and converted the video using the settings for Google Android (x264).
Now I can play on every device.
My problem was I had saved it in .avi format instead of .m4v format, and it worked liked a charm on my Samsung...thanks for everyone's help!