I'm working on an app which reads a .txt file that is stored in the SD card (inside /data/local). The problem I have is that it seems that it can access to the file path, but it can't access the file itself (although it has read and write permissions), it throws a FileNotFoundException.
Here I leave you the code and the log:
String ruta="/data/local/textojson.txt";
System.out.println(ruta);
String cadena="", Jsontx="";
File sd = Environment.getExternalStorageDirectory();
File f = new File(sd.getAbsolutePath(), ruta);
System.out.println(f);
BufferedReader entrada;
try
{
entrada = new BufferedReader(new FileReader(f));
System.out.println(entrada);
try
{
while((cadena=entrada.readLine())!=null)
{
Jsontx=cadena;
}
} catch (IOException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
} catch (FileNotFoundException e1)
{
// TODO Auto-generated catch block
e1.printStackTrace();
}
I've added the READ_EXTERNAL_STORAGE permissions to the manifest, and the file really exists in that directory.
02-04 19:26:40.535: E/Trace(20167): error opening trace file: No such file or directory (2)
02-04 19:26:41.055: I/System.out(20167): /data/local/textojson.txt
02-04 19:26:41.066: I/System.out(20167): /mnt/sdcard/data/local/textojson.txt
02-04 19:26:41.066: W/System.err(20167): java.io.FileNotFoundException: /mnt/sdcard/data/local/textojson.txt: open failed: ENOENT (No such file or directory)
02-04 19:26:41.066: W/System.err(20167): at libcore.io.IoBridge.open(IoBridge.java:416)
02-04 19:26:41.075: W/System.err(20167): at java.io.FileInputStream.<init>(FileInputStream.java:78)
02-04 19:26:41.075: W/System.err(20167): at java.io.FileReader.<init>(FileReader.java:42)
02-04 19:26:41.075: W/System.err(20167): at es.example.jsonarchivo.Adapter.<init>(Adapter.java:47)
02-04 19:26:41.075: W/System.err(20167): at es.example.jsonarchivo.MainActivity.onCreate(MainActivity.java:27)
02-04 19:26:41.075: W/System.err(20167): at android.app.Activity.performCreate(Activity.java:5008)
02-04 19:26:41.085: W/System.err(20167): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079)
02-04 19:26:41.085: W/System.err(20167): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2023)
02-04 19:26:41.085: W/System.err(20167): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
02-04 19:26:41.085: W/System.err(20167): at android.app.ActivityThread.access$600(ActivityThread.java:130)
02-04 19:26:41.085: W/System.err(20167): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
02-04 19:26:41.085: W/System.err(20167): at android.os.Handler.dispatchMessage(Handler.java:99)
02-04 19:26:41.085: W/System.err(20167): at android.os.Looper.loop(Looper.java:137)
02-04 19:26:41.085: W/System.err(20167): at android.app.ActivityThread.main(ActivityThread.java:4745)
02-04 19:26:41.095: W/System.err(20167): at java.lang.reflect.Method.invokeNative(Native Method)
02-04 19:26:41.105: W/System.err(20167): at java.lang.reflect.Method.invoke(Method.java:511)
02-04 19:26:41.105: W/System.err(20167): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
02-04 19:26:41.105: W/System.err(20167): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
02-04 19:26:41.105: W/System.err(20167): at dalvik.system.NativeStart.main(Native Method)
02-04 19:26:41.105: W/System.err(20167): Caused by: libcore.io.ErrnoException: open failed: ENOENT (No such file or directory)
02-04 19:26:41.116: W/System.err(20167): at libcore.io.Posix.open(Native Method)
02-04 19:26:41.116: W/System.err(20167): at libcore.io.BlockGuardOs.open(BlockGuardOs.java:110)
02-04 19:26:41.116: W/System.err(20167): at libcore.io.IoBridge.open(IoBridge.java:400)
02-04 19:26:41.125: W/System.err(20167): ... 18 more
02-04 19:26:41.125: D/AndroidRuntime(20167): Shutting down VM
02-04 19:26:41.125: W/dalvikvm(20167): threadid=1: thread exiting with uncaught exception (group=0x40a13300)
02-04 19:26:41.145: E/AndroidRuntime(20167): FATAL EXCEPTION: main
02-04 19:26:41.145: E/AndroidRuntime(20167): java.lang.RuntimeException: Unable to start activity ComponentInfo{es.example.jsonarchivo/es.example.jsonarchivo.MainActivity}: java.lang.NullPointerException
02-04 19:26:41.145: E/AndroidRuntime(20167): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2059)
02-04 19:26:41.145: E/AndroidRuntime(20167): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
02-04 19:26:41.145: E/AndroidRuntime(20167): at android.app.ActivityThread.access$600(ActivityThread.java:130)
02-04 19:26:41.145: E/AndroidRuntime(20167): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
02-04 19:26:41.145: E/AndroidRuntime(20167): at android.os.Handler.dispatchMessage(Handler.java:99)
02-04 19:26:41.145: E/AndroidRuntime(20167): at android.os.Looper.loop(Looper.java:137)
02-04 19:26:41.145: E/AndroidRuntime(20167): at android.app.ActivityThread.main(ActivityThread.java:4745)
02-04 19:26:41.145: E/AndroidRuntime(20167): at java.lang.reflect.Method.invokeNative(Native Method)
02-04 19:26:41.145: E/AndroidRuntime(20167): at java.lang.reflect.Method.invoke(Method.java:511)
02-04 19:26:41.145: E/AndroidRuntime(20167): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
02-04 19:26:41.145: E/AndroidRuntime(20167): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
02-04 19:26:41.145: E/AndroidRuntime(20167): at dalvik.system.NativeStart.main(Native Method)
02-04 19:26:41.145: E/AndroidRuntime(20167): Caused by: java.lang.NullPointerException
02-04 19:26:41.145: E/AndroidRuntime(20167): at com.android.internal.os.LoggingPrintStream.println(LoggingPrintStream.java:298)
02-04 19:26:41.145: E/AndroidRuntime(20167): at es.example.jsonarchivo.Adapter.<init>(Adapter.java:70)
02-04 19:26:41.145: E/AndroidRuntime(20167): at es.example.jsonarchivo.MainActivity.onCreate(MainActivity.java:27)
02-04 19:26:41.145: E/AndroidRuntime(20167): at android.app.Activity.performCreate(Activity.java:5008)
02-04 19:26:41.145: E/AndroidRuntime(20167): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079)
02-04 19:26:41.145: E/AndroidRuntime(20167): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2023)
02-04 19:26:41.145: E/AndroidRuntime(20167): ... 11 more
02-04 19:31:41.224: I/Process(20167): Sending signal. PID: 20167 SIG: 9
I hope I have explained it well, my mother tongue isn't english.
To recap in an answer,
java.io.FileNotFoundException: /mnt/sdcard/data/local/textojson.txt: open failed: ENOENT (No such file or directory)
means that the file does not exist. This can be verified with f.exists()
If the problem was permissions you should get open failed: EACCES (Permission denied)
Related
I have the following ImageView:
imageView.setBackgroundResource(R.drawable.create_user);
My create_user drawable looks like this:
<animation-list xmlns:android="http://schemas.android.com/apk/res/android" android:oneshot="false">
<item android:drawable="#drawable/create_user_0" android:duration="500" />
<item android:drawable="#drawable/create_user_1" android:duration="500" />
</animation-list>
But when the .xml is being set in imageView.setBacgroundResource(R.drawable.create_user), it launches the following exception:
02-04 10:49:07.994: E/AndroidRuntime(1379): FATAL EXCEPTION: main
02-04 10:49:07.994: E/AndroidRuntime(1379): java.lang.OutOfMemoryError
02-04 10:49:07.994: E/AndroidRuntime(1379): at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
02-04 10:49:07.994: E/AndroidRuntime(1379): at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:596)
02-04 10:49:07.994: E/AndroidRuntime(1379): at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:444)
02-04 10:49:07.994: E/AndroidRuntime(1379): at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:832)
02-04 10:49:07.994: E/AndroidRuntime(1379): at android.content.res.Resources.loadDrawable(Resources.java:2988)
02-04 10:49:07.994: E/AndroidRuntime(1379): at android.content.res.Resources.getDrawable(Resources.java:1558)
02-04 10:49:07.994: E/AndroidRuntime(1379): at android.graphics.drawable.AnimationDrawable.inflate(AnimationDrawable.java:282)
02-04 10:49:07.994: E/AndroidRuntime(1379): at android.graphics.drawable.Drawable.createFromXmlInner(Drawable.java:937)
02-04 10:49:07.994: E/AndroidRuntime(1379): at android.graphics.drawable.Drawable.createFromXml(Drawable.java:873)
02-04 10:49:07.994: E/AndroidRuntime(1379): at android.content.res.Resources.loadDrawable(Resources.java:2970)
02-04 10:49:07.994: E/AndroidRuntime(1379): at android.content.res.Resources.getDrawable(Resources.java:1558)
02-04 10:49:07.994: E/AndroidRuntime(1379): at android.view.View.setBackgroundResource(View.java:15697)
02-04 10:49:07.994: E/AndroidRuntime(1379): at com.facephi.sdk.ui.FragmentCreatingStructure.onCreateView(FragmentCreatingStructu re.java:29)
02-04 10:49:07.994: E/AndroidRuntime(1379): at android.app.Fragment.performCreateView(Fragment.java:1699)
02-04 10:49:07.994: E/AndroidRuntime(1379): at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:903)
02-04 10:49:07.994: E/AndroidRuntime(1379): at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1075)
02-04 10:49:07.994: E/AndroidRuntime(1379): at android.app.BackStackRecord.run(BackStackRecord.java:682)
02-04 10:49:07.994: E/AndroidRuntime(1379): at android.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1455)
02-04 10:49:07.994: E/AndroidRuntime(1379): at android.app.FragmentManagerImpl$1.run(FragmentManager.java:441)
02-04 10:49:07.994: E/AndroidRuntime(1379): at android.os.Handler.handleCallback(Handler.java:730)
02-04 10:49:07.994: E/AndroidRuntime(1379): at android.os.Handler.dispatchMessage(Handler.java:92)
02-04 10:49:07.994: E/AndroidRuntime(1379): at android.os.Looper.loop(Looper.java:176)
02-04 10:49:07.994: E/AndroidRuntime(1379): at android.app.ActivityThread.main(ActivityThread.java:5419)
02-04 10:49:07.994: E/AndroidRuntime(1379): at java.lang.reflect.Method.invokeNative(Native Method)
02-04 10:49:07.994: E/AndroidRuntime(1379): at java.lang.reflect.Method.invoke(Method.java:525)
02-04 10:49:07.994: E/AndroidRuntime(1379): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1046)
02-04 10:49:07.994: E/AndroidRuntime(1379): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:862)
02-04 10:49:07.994: E/AndroidRuntime(1379): at dalvik.system.NativeStart.main(Native Method)
I have to say that I've been using this animation for a looong time. And yesterday was the first time it started crashing.
I can't imagine what's going on at this point... Can anyone help me find what I'm doing wrong?
NOTE: It says Out of memory on a 638416-byte allocation before the mistake is launched.
NOTE2: It also says this several times before the application crashes.
02-04 11:23:56.179: I/dalvikvm(7266): "Binder_1" prio=5 tid=9 RUNNABLE
02-04 11:23:56.179: I/dalvikvm(7266): | group="main" sCount=0 dsCount=0 obj=0x427f2200 self=0x4192fcd0
02-04 11:23:56.179: I/dalvikvm(7266): | sysTid=7277 nice=0 sched=0/0 cgrp=apps handle=1100151432
02-04 11:23:56.179: I/dalvikvm(7266): | state=R schedstat=( 504400204 75428596 671 ) utm=34 stm=15 core=2
02-04 11:23:56.179: I/dalvikvm(7266): at dalvik.system.NativeStart.run(Native Method)
02-04 11:23:56.179: E/Camera-JNI(7266): Couldn't allocate byte array for JPEG data
02-04 11:23:56.239: I/dalvikvm-heap(7266): Clamp target GC heap from 71.012MB to 64.000MB
02-04 11:23:56.239: D/dalvikvm(7266): threadid=1: still suspended after undo (sc=1 dc=1)
02-04 11:23:56.239: D/dalvikvm(7266): GC_FOR_ALLOC freed 21K, 3% free 63352K/65192K, paused 17ms, total 17ms
02-04 11:23:56.239: I/dalvikvm-heap(7266): Forcing collection of SoftReferences for 460816-byte allocation
02-04 11:23:56.259: I/dalvikvm-heap(7266): Clamp target GC heap from 71.012MB to 64.000MB
02-04 11:23:56.259: D/dalvikvm(7266): threadid=1: still suspended after undo (sc=1 dc=1)
02-04 11:23:56.259: D/dalvikvm(7266): GC_BEFORE_OOM freed 0K, 3% free 63352K/65192K, paused 20ms, total 20ms
02-04 11:23:56.259: E/dalvikvm-heap(7266): Out of memory on a 460816-byte allocation.
Try adding android:largeHeap="true", in the manifest to see if this solves it.
Or Use api inSampleSize of bitmapfactory to sample the images.
I also faced this kind of error once but when I re sized my images it got resolved.
Try to re-size your images.
You can try to resize your images to adapt them to the exact size of the view, as explained here. You can even try using libraries like universal image loader which make this task easier.
I am new to android coding. I am trying a simple code like clicking a button, and if clicked it opens Google. If I run my code, and if I click the button, the browser opens, and after sometime, it displays UNFORTUNATELY BROWSER STOPPED. please help me. thanks in advance.
package com.example.single_button_google;
import android.net.Uri;
import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.Menu;
import android.view.View;
import android.widget.Button;
public class MainActivity extends Activity {
Button b1;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
b1= (Button) findViewById(R.id.button1);
b1.setOnClickListener(click);
}
View.OnClickListener click = new View.OnClickListener() {
#Override
public void onClick(View v) {
// TODO Auto-generated method stub
Intent intent = new Intent(Intent.ACTION_VIEW,Uri.parse("https://www.google.co.in/"));
startActivity(intent);
}
};
#Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
}
My logcat:
02-04 04:50:19.910: D/AndroidRuntime(1174): >>>>>> AndroidRuntime START com.android.internal.os.RuntimeInit <<<<<<
02-04 04:50:19.920: D/AndroidRuntime(1174): CheckJNI is ON
02-04 04:50:20.000: D/dalvikvm(1174): Trying to load lib libjavacore.so 0x0
02-04 04:50:20.010: D/dalvikvm(1174): Added shared lib libjavacore.so 0x0
02-04 04:50:20.040: D/dalvikvm(1174): Trying to load lib libnativehelper.so 0x0
02-04 04:50:20.040: D/dalvikvm(1174): Added shared lib libnativehelper.so 0x0
02-04 04:50:20.050: D/dalvikvm(1174): No JNI_OnLoad found in libnativehelper.so 0x0, skipping init
02-04 04:50:20.270: D/dalvikvm(1174): Note: class Landroid/app/ActivityManagerNative; has 179 unimplemented (abstract) methods
02-04 04:50:20.840: E/memtrack(1174): Couldn't load memtrack module (No such file or directory)
02-04 04:50:20.840: E/android.os.Debug(1174): failed to load memtrack module: -2
02-04 04:50:21.200: D/AndroidRuntime(1174): Calling main entry com.android.commands.pm.Pm
02-04 04:50:21.240: D/AndroidRuntime(1174): Shutting down VM
02-04 04:50:21.240: D/dalvikvm(1174): Debugger has detached; object registry had 1 entries
02-04 04:50:22.040: D/AndroidRuntime(1185): >>>>>> AndroidRuntime START com.android.internal.os.RuntimeInit <<<<<<
02-04 04:50:22.050: D/AndroidRuntime(1185): CheckJNI is ON
02-04 04:50:22.120: D/dalvikvm(1185): Trying to load lib libjavacore.so 0x0
02-04 04:50:22.130: D/dalvikvm(1185): Added shared lib libjavacore.so 0x0
02-04 04:50:22.160: D/dalvikvm(1185): Trying to load lib libnativehelper.so 0x0
02-04 04:50:22.160: D/dalvikvm(1185): Added shared lib libnativehelper.so 0x0
02-04 04:50:22.160: D/dalvikvm(1185): No JNI_OnLoad found in libnativehelper.so 0x0, skipping init
02-04 04:50:22.380: D/dalvikvm(1185): Note: class Landroid/app/ActivityManagerNative; has 179 unimplemented (abstract) methods
02-04 04:50:22.960: E/memtrack(1185): Couldn't load memtrack module (No such file or directory)
02-04 04:50:22.960: E/android.os.Debug(1185): failed to load memtrack module: -2
02-04 04:50:23.290: D/AndroidRuntime(1185): Calling main entry com.android.commands.am.Am
02-04 04:50:23.380: I/ActivityManager(363): START u0 {act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 cmp=com.example.single_button_google/.MainActivity} from pid 1185
02-04 04:50:23.410: D/AndroidRuntime(1185): Shutting down VM
02-04 04:50:23.420: D/jdwp(1185): Got wake-up signal, bailing out of select
02-04 04:50:23.420: D/dalvikvm(1185): Debugger has detached; object registry had 1 entries
02-04 04:50:23.930: W/ActivityManager(363): Activity pause timeout for ActivityRecord{b4f82e48 u0 com.android.browser/.BrowserActivity t8}
02-04 04:50:24.000: W/InputMethodManagerService(363): Window already focused, ignoring focus gain of: com.android.internal.view.IInputMethodClient$Stub$Proxy#b505f218 attribute=null, token = android.os.BinderProxy#b51975c8
02-04 04:50:24.100: I/Choreographer(363): Skipped 51 frames! The application may be doing too much work on its main thread.
02-04 04:50:24.190: I/Choreographer(363): Skipped 58 frames! The application may be doing too much work on its main thread.
02-04 04:50:24.390: I/Choreographer(363): Skipped 48 frames! The application may be doing too much work on its main thread.
02-04 04:50:24.440: I/Choreographer(899): Skipped 288 frames! The application may be doing too much work on its main thread.
02-04 04:50:24.640: I/Choreographer(363): Skipped 50 frames! The application may be doing too much work on its main thread.
02-04 04:50:24.970: I/Choreographer(363): Skipped 52 frames! The application may be doing too much work on its main thread.
02-04 04:50:25.370: I/Choreographer(363): Skipped 51 frames! The application may be doing too much work on its main thread.
02-04 04:50:25.480: I/Choreographer(363): Skipped 58 frames! The application may be doing too much work on its main thread.
02-04 04:50:25.570: I/Choreographer(363): Skipped 54 frames! The application may be doing too much work on its main thread.
02-04 04:50:25.680: I/Choreographer(363): Skipped 69 frames! The application may be doing too much work on its main thread.
02-04 04:50:25.810: I/Choreographer(363): Skipped 72 frames! The application may be doing too much work on its main thread.
02-04 04:50:34.460: E/NativeDaemonConnector.ResponseQueue(363): Timeout waiting for response
02-04 04:50:34.460: E/VoldConnector(363): timed-out waiting for response to 12 volume mkdirs /storage/sdcard/Android/data/com.android.browser/files/
02-04 04:50:34.460: D/AndroidRuntime(1157): Shutting down VM
02-04 04:50:34.460: W/dalvikvm(1157): threadid=1: thread exiting with uncaught exception (group=0xb4adab90)
02-04 04:50:34.490: E/AndroidRuntime(1157): FATAL EXCEPTION: main
02-04 04:50:34.490: E/AndroidRuntime(1157): Process: com.android.browser, PID: 1157
02-04 04:50:34.490: E/AndroidRuntime(1157): java.lang.RuntimeException: Unable to get provider com.android.browser.provider.SnapshotProvider: java.lang.NullPointerException
02-04 04:50:34.490: E/AndroidRuntime(1157): at android.app.ActivityThread.installProvider(ActivityThread.java:4774)
02-04 04:50:34.490: E/AndroidRuntime(1157): at android.app.ActivityThread.installContentProviders(ActivityThread.java:4366)
02-04 04:50:34.490: E/AndroidRuntime(1157): at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4306)
02-04 04:50:34.490: E/AndroidRuntime(1157): at android.app.ActivityThread.access$1400(ActivityThread.java:135)
02-04 04:50:34.490: E/AndroidRuntime(1157): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1457)
02-04 04:50:34.490: E/AndroidRuntime(1157): at android.os.Handler.dispatchMessage(Handler.java:102)
02-04 04:50:34.490: E/AndroidRuntime(1157): at android.os.Looper.loop(Looper.java:137)
02-04 04:50:34.490: E/AndroidRuntime(1157): at android.app.ActivityThread.main(ActivityThread.java:4998)
02-04 04:50:34.490: E/AndroidRuntime(1157): at java.lang.reflect.Method.invokeNative(Native Method)
02-04 04:50:34.490: E/AndroidRuntime(1157): at java.lang.reflect.Method.invoke(Method.java:515)
02-04 04:50:34.490: E/AndroidRuntime(1157): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:777)
02-04 04:50:34.490: E/AndroidRuntime(1157): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:593)
02-04 04:50:34.490: E/AndroidRuntime(1157): at dalvik.system.NativeStart.main(Native Method)
02-04 04:50:34.490: E/AndroidRuntime(1157): Caused by: java.lang.NullPointerException
02-04 04:50:34.490: E/AndroidRuntime(1157): at android.os.Parcel.readException(Parcel.java:1467)
02-04 04:50:34.490: E/AndroidRuntime(1157): at android.os.Parcel.readException(Parcel.java:1415)
02-04 04:50:34.490: E/AndroidRuntime(1157): at android.os.storage.IMountService$Stub$Proxy.mkdirs(IMountService.java:750)
02-04 04:50:34.490: E/AndroidRuntime(1157): at android.app.ContextImpl.ensureDirsExistOrFilter(ContextImpl.java:2160)
02-04 04:50:34.490: E/AndroidRuntime(1157): at android.app.ContextImpl.getExternalFilesDirs(ContextImpl.java:856)
02-04 04:50:34.490: E/AndroidRuntime(1157): at android.app.ContextImpl.getExternalFilesDir(ContextImpl.java:839)
02-04 04:50:34.490: E/AndroidRuntime(1157): at android.content.ContextWrapper.getExternalFilesDir(ContextWrapper.java:210)
02-04 04:50:34.490: E/AndroidRuntime(1157): at com.android.browser.provider.SnapshotProvider.getOldDatabasePath(SnapshotProvider.java:116)
02-04 04:50:34.490: E/AndroidRuntime(1157): at com.android.browser.provider.SnapshotProvider.migrateToDataFolder(SnapshotProvider.java:123)
02-04 04:50:34.490: E/AndroidRuntime(1157): at com.android.browser.provider.SnapshotProvider.onCreate(SnapshotProvider.java:137)
02-04 04:50:34.490: E/AndroidRuntime(1157): at android.content.ContentProvider.attachInfo(ContentProvider.java:1589)
02-04 04:50:34.490: E/AndroidRuntime(1157): at android.content.ContentProvider.attachInfo(ContentProvider.java:1560)
02-04 04:50:34.490: E/AndroidRuntime(1157): at android.app.ActivityThread.installProvider(ActivityThread.java:4771)
02-04 04:50:34.490: E/AndroidRuntime(1157): ... 12 more
02-04 04:50:34.660: I/Choreographer(363): Skipped 45 frames! The application may be doing too much work on its main thread.
02-04 04:50:34.910: I/Choreographer(363): Skipped 64 frames! The application may be doing too much work on its main thread.
02-04 04:50:35.020: I/Choreographer(363): Skipped 65 frames! The application may be doing too much work on its main thread.
02-04 04:50:35.130: I/Choreographer(363): Skipped 64 frames! The application may be doing too much work on its main thread.
02-04 04:50:36.050: W/ActivityManager(363): Activity stop timeout for ActivityRecord{b4f82e48 u0 com.android.browser/.BrowserActivity t8}
Seems to be a problem related to the emulator and the SD card. Try to change some configuration on your emulator or try the app on a real device.
I have a Error inflating class error that seemed to be caused by Bitmap (more details here: Android: Memory error because of an ImageView?) but when I comment the bitmap I still have the error while when I comment the Imageview5, no error. All the posts on stackoverflow about this error did not help solving my problem
02-04 10:03:04.353: E/AndroidRuntime(17427): FATAL EXCEPTION: main
02-04 10:03:04.353: E/AndroidRuntime(17427): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.kersplatt/com.example.kersplatt.ShareActivity}: android.view.InflateException: Binary XML file line #23: Error inflating class <unknown>
02-04 10:03:04.353: E/AndroidRuntime(17427): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1647)
02-04 10:03:04.353: E/AndroidRuntime(17427): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
02-04 10:03:04.353: E/AndroidRuntime(17427): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
02-04 10:03:04.353: E/AndroidRuntime(17427): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
02-04 10:03:04.353: E/AndroidRuntime(17427): at android.os.Handler.dispatchMessage(Handler.java:99)
02-04 10:03:04.353: E/AndroidRuntime(17427): at android.os.Looper.loop(Looper.java:130)
02-04 10:03:04.353: E/AndroidRuntime(17427): at android.app.ActivityThread.main(ActivityThread.java:3683)
02-04 10:03:04.353: E/AndroidRuntime(17427): at java.lang.reflect.Method.invokeNative(Native Method)
02-04 10:03:04.353: E/AndroidRuntime(17427): at java.lang.reflect.Method.invoke(Method.java:507)
02-04 10:03:04.353: E/AndroidRuntime(17427): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:875)
02-04 10:03:04.353: E/AndroidRuntime(17427): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:633)
02-04 10:03:04.353: E/AndroidRuntime(17427): at dalvik.system.NativeStart.main(Native Method)
02-04 10:03:04.353: E/AndroidRuntime(17427): Caused by: android.view.InflateException: Binary XML file line #23: Error inflating class <unknown>
02-04 10:03:04.353: E/AndroidRuntime(17427): at android.view.LayoutInflater.createView(LayoutInflater.java:518)
02-04 10:03:04.353: E/AndroidRuntime(17427): at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
02-04 10:03:04.353: E/AndroidRuntime(17427): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:568)
02-04 10:03:04.353: E/AndroidRuntime(17427): at android.view.LayoutInflater.rInflate(LayoutInflater.java:623)
02-04 10:03:04.353: E/AndroidRuntime(17427): at android.view.LayoutInflater.rInflate(LayoutInflater.java:626)
02-04 10:03:04.353: E/AndroidRuntime(17427): at android.view.LayoutInflater.inflate(LayoutInflater.java:408)
02-04 10:03:04.353: E/AndroidRuntime(17427): at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
02-04 10:03:04.353: E/AndroidRuntime(17427): at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
02-04 10:03:04.353: E/AndroidRuntime(17427): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:209)
02-04 10:03:04.353: E/AndroidRuntime(17427): at android.app.Activity.setContentView(Activity.java:1657)
02-04 10:03:04.353: E/AndroidRuntime(17427): at com.example.kersplatt.ShareActivity.onCreate(ShareActivity.java:64)
02-04 10:03:04.353: E/AndroidRuntime(17427): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
02-04 10:03:04.353: E/AndroidRuntime(17427): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
02-04 10:03:04.353: E/AndroidRuntime(17427): ... 11 more
02-04 10:03:04.353: E/AndroidRuntime(17427): Caused by: java.lang.reflect.InvocationTargetException
02-04 10:03:04.353: E/AndroidRuntime(17427): at java.lang.reflect.Constructor.constructNative(Native Method)
02-04 10:03:04.353: E/AndroidRuntime(17427): at java.lang.reflect.Constructor.newInstance(Constructor.java:415)
02-04 10:03:04.353: E/AndroidRuntime(17427): at android.view.LayoutInflater.createView(LayoutInflater.java:505)
02-04 10:03:04.353: E/AndroidRuntime(17427): ... 23 more
02-04 10:03:04.353: E/AndroidRuntime(17427): Caused by: java.lang.OutOfMemoryError: bitmap size exceeds VM budget
02-04 10:03:04.353: E/AndroidRuntime(17427): at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
02-04 10:03:04.353: E/AndroidRuntime(17427): at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:460)
02-04 10:03:04.353: E/AndroidRuntime(17427): at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:336)
02-04 10:03:04.353: E/AndroidRuntime(17427): at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:697)
02-04 10:03:04.353: E/AndroidRuntime(17427): at android.content.res.Resources.loadDrawable(Resources.java:1709)
02-04 10:03:04.353: E/AndroidRuntime(17427): at android.content.res.TypedArray.getDrawable(TypedArray.java:601)
02-04 10:03:04.353: E/AndroidRuntime(17427): at android.widget.ImageView.<init>(ImageView.java:118)
02-04 10:03:04.353: E/AndroidRuntime(17427): at android.widget.ImageView.<init>(ImageView.java:108)
02-04 10:03:04.353: E/AndroidRuntime(17427): ... 26 more
and my line 23 is imageview5
<ImageView
android:id="#+id/imageView5"
android:layout_width="85dp"
android:layout_height="100dp"
android:layout_marginLeft="8dp"
android:layout_marginTop="20dp"
android:adjustViewBounds="true"
android:src="#drawable/diviseur" />
It's a pretty misleading error, but it's caused by a nested exception, because the VM has run out of memory for the drawable diviseur. See the end of the stack trace:
02-04 10:03:04.353: E/AndroidRuntime(17427): Caused by: java.lang.OutOfMemoryError: bitmap size exceeds VM budget
02-04 10:03:04.353: E/AndroidRuntime(17427): at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
02-04 10:03:04.353: E/AndroidRuntime(17427): at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:460)
02-04 10:03:04.353: E/AndroidRuntime(17427): at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:336)
02-04 10:03:04.353: E/AndroidRuntime(17427): at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:697)
02-04 10:03:04.353: E/AndroidRuntime(17427): at android.content.res.Resources.loadDrawable(Resources.java:1709)
02-04 10:03:04.353: E/AndroidRuntime(17427): at android.content.res.TypedArray.getDrawable(TypedArray.java:601)
02-04 10:03:04.353: E/AndroidRuntime(17427): at android.widget.ImageView.<init>(ImageView.java:118)
02-04 10:03:04.353: E/AndroidRuntime(17427): at android.widget.ImageView.<init>(ImageView.java:108)
02-04 10:03:04.353: E/AndroidRuntime(17427): ... 26 more
Sometimes this may happen, the best practice is to create a scaled bitmap using the bitmap factory,
Bitmap result = Bitmap.createScaledBitmap(bitmapPicture,
imageWidth, imageHeight, false);
Try this and see if it helps
Also use,
BitmapFactory.Options opts = new BitmapFactory.Options();
opts.inPurgeable = true; // Tell to garbage collector that whether it needs free memory, the Bitmap can be cleared
opts.inTempStorage = new byte[32 * 1024];
and always recycle your bitmap when you leave that activity as it helps in freeing memory.
Hope this helps
I got the same error. My problem was that every phone loaded a 2k image as background of the activity. I solved the problem by scaling down this background image to 800x480 and 1280x720. Then I put this images into the ldpi, mdpi, ... folders.Now it works
I declare my activity in manifest file but it shows exception for me
<activity android:name="BuyClick"></activity>
I did not get what is happening to my manifest file
Exception are as follow
02-04 12:33:52.161: E/AndroidRuntime(1260): FATAL EXCEPTION: main
02-04 12:33:52.161: E/AndroidRuntime(1260): android.content.ActivityNotFoundException: Unable to find explicit activity class {com.kt.pos/com.kt.pos.BuyClick}; have you declared this activity in your AndroidManifest.xml?
02-04 12:33:52.161: E/AndroidRuntime(1260): at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1541)
02-04 12:33:52.161: E/AndroidRuntime(1260): at android.app.Instrumentation.execStartActivity(Instrumentation.java:1416)
02-04 12:33:52.161: E/AndroidRuntime(1260): at android.app.Activity.startActivityForResult(Activity.java:3351)
02-04 12:33:52.161: E/AndroidRuntime(1260): at android.app.Activity.startActivityForResult(Activity.java:3312)
02-04 12:33:52.161: E/AndroidRuntime(1260): at android.app.Activity.startActivity(Activity.java:3522)
02-04 12:33:52.161: E/AndroidRuntime(1260): at android.app.Activity.startActivity(Activity.java:3490)
02-04 12:33:52.161: E/AndroidRuntime(1260): at com.kt.pos.POSMainActivity$1.onFinish(POSMainActivity.java:21)
02-04 12:33:52.161: E/AndroidRuntime(1260): at android.os.CountDownTimer$1.handleMessage(CountDownTimer.java:118)
02-04 12:33:52.161: E/AndroidRuntime(1260): at android.os.Handler.dispatchMessage(Handler.java:99)
02-04 12:33:52.161: E/AndroidRuntime(1260): at android.os.Looper.loop(Looper.java:137)
02-04 12:33:52.161: E/AndroidRuntime(1260): at android.app.ActivityThread.main(ActivityThread.java:4745)
02-04 12:33:52.161: E/AndroidRuntime(1260): at java.lang.reflect.Method.invokeNative(Native Method)
02-04 12:33:52.161: E/AndroidRuntime(1260): at java.lang.reflect.Method.invoke(Method.java:511)
02-04 12:33:52.161: E/AndroidRuntime(1260): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
02-04 12:33:52.161: E/AndroidRuntime(1260): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
02-04 12:33:52.161: E/AndroidRuntime(1260): at dalvik.system.NativeStart.main(Native Method)
02-04 12:38:52.231: I/Process(1260): Sending signal. PID: 1260 SIG: 9
It should be either
<activity android:name=".BuyClick"></activity>
or
<activity android:name="com.kt.pos.BuyClick"></activity>
It needs to be fully qualified with the package name or preceded with a "." if it's in the main package.
try this :
<activity android:name="com.kt.pos.BuyClick"></activity>
Always use your package name with activity before defining them in menifest.
i want to play mp3 file which is streamed mp3 file. i tried below link example
http://blog.pocketjourney.com/2008/04/04/tutorial-custom-media-streaming-for-androids-mediaplayer/
but the bellow error is coming
02-04 20:22:48.960: ERROR/PlayerDriver(31): Command PLAYER_PREPARE completed with an error or info PVMFErrResource
02-04 20:22:48.970: ERROR/MediaPlayer(425): error (1, -17)
02-04 20:22:48.989: WARN/PlayerDriver(31): PVMFInfoErrorHandlingComplete
02-04 20:22:49.089: DEBUG/dalvikvm(425): GC freed 4622 objects / 982864 bytes in 120ms
02-04 20:22:49.350: ERROR/com.Boodang.StreamingMediaPlayer(425): Error updating to newly loaded content.
02-04 20:22:49.350: ERROR/com.Boodang.StreamingMediaPlayer(425): java.io.IOException: Prepare failed.: status=0x1
02-04 20:22:49.350: ERROR/com.Boodang.StreamingMediaPlayer(425): at android.media.MediaPlayer.prepare(Native Method)
02-04 20:22:49.350: ERROR/com.Boodang.StreamingMediaPlayer(425): at com.Boodang.StreamingMediaPlayer.createMediaPlayer(StreamingMediaPlayer.java:210)
02-04 20:22:49.350: ERROR/com.Boodang.StreamingMediaPlayer(425): at com.Boodang.StreamingMediaPlayer.transferBufferToMediaPlayer(StreamingMediaPlayer.java:239)
02-04 20:22:49.350: ERROR/com.Boodang.StreamingMediaPlayer(425): at com.Boodang.StreamingMediaPlayer.access$3(StreamingMediaPlayer.java:219)
02-04 20:22:49.350: ERROR/com.Boodang.StreamingMediaPlayer(425): at com.Boodang.StreamingMediaPlayer$2.run(StreamingMediaPlayer.java:160)
02-04 20:22:49.350: ERROR/com.Boodang.StreamingMediaPlayer(425): at android.os.Handler.handleCallback(Handler.java:587)
02-04 20:22:49.350: ERROR/com.Boodang.StreamingMediaPlayer(425): at android.os.Handler.dispatchMessage(Handler.java:92)
02-04 20:22:49.350: ERROR/com.Boodang.StreamingMediaPlayer(425): at android.os.Looper.loop(Looper.java:123)
02-04 20:22:49.350: ERROR/com.Boodang.StreamingMediaPlayer(425): at android.app.ActivityThread.main(ActivityThread.java:4363)
02-04 20:22:49.350: ERROR/com.Boodang.StreamingMediaPlayer(425): at java.lang.reflect.Method.invokeNative(Native Method)
02-04 20:22:49.350: ERROR/com.Boodang.StreamingMediaPlayer(425): at java.lang.reflect.Method.invoke(Method.java:521)
02-04 20:22:49.350: ERROR/com.Boodang.StreamingMediaPlayer(425): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
02-04 20:22:49.350: ERROR/com.Boodang.StreamingMediaPlayer(425): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
02-04 20:22:49.350: ERROR/com.Boodang.StreamingMediaPlayer(425): at dalvik.system.NativeStart.main(Native Method)
so please tell me what i will do and i hope there is better way to do this one . so please tell me how to stream the mp3 file and play the mp3 file.
Thank you.
Best Regards.
First, that blog post is nearly three years old. Never use Android blog posts from that long ago.
Second, at least through Android 2.2, streaming MP3 files was not supported over RTSP. I think it works over HTTP.
Beyond that, make sure the URL you are using actually is reachable from your device or emulator. For example, you need the INTERNET permission in your app, your emulator needs to have Internet access, etc.
In the future, you might consider supplying source code, as a stack trace alone is usually insufficient to get assistance from anyone.