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.
Related
I am creating an app on Android, which involves an Activity and a service. One of the components of the service is meant to send a signal to the MainActivity, which will execute some specific code. The problem is, trying to send the intent makes the app crash.
Here is the code that sends the intent. Note that it resides in the inside of a doInBackground function of an AsyncTask object, which resides inside the said service:
#Override
protected String doInBackground(Socket... client) {
Intent received = new Intent();
received.setAction("com.mycompany.Messenger.MESSAGE_RECEIVED");
sendBroadcast(received);
}
Note that if I comment out sendBroadcast(received), the app does not crash.
Here is the handler of the Intent inside MainActivity (which has the name ChatBubbleActivity in my app):
public class MessageReceiver extends BroadcastReceiver {
#Override
public void onReceive(Context context, Intent intent) {
if(intent.getAction().equals(MESSAGE_RECEIVED)) {
String current_message = "Intent works!";
TextView textView = (TextView) findViewById(R.id.myText);
textView.setText(current_message);
}
}
}
And this is the declaration of the Receiver in manifest:
<receiver android:name=".ChatBubbleActivity$MessageReceiver">
<intent-filter>
<action android:name="com.mycompany.Messenger.MESSAGE_RECEIVED"/>
</intent-filter>
</receiver>
, inside the <activity> chunk.
What is it that I might be missing?
EDIT:New version of code based on answers, still crashing.
EDIT logcat:
02-04 16:17:32.444 487-489/? D/dalvikvm﹕ GC_CONCURRENT freed 1662K, 22% free 6885K/8728K, paused 2ms+2ms, total 42ms
02-04 16:17:32.876 1275-1275/? D/AndroidRuntime﹕ >>>>>> AndroidRuntime START com.android.internal.os.RuntimeInit <<<<<<
02-04 16:17:32.912 1275-1275/? D/AndroidRuntime﹕ CheckJNI is OFF
02-04 16:17:32.960 1275-1275/? D/dalvikvm﹕ Trying to load lib libjavacore.so 0x0
02-04 16:17:32.964 1275-1275/? D/dalvikvm﹕ Added shared lib libjavacore.so 0x0
02-04 16:17:32.968 1275-1275/? D/dalvikvm﹕ Trying to load lib libnativehelper.so 0x0
02-04 16:17:32.972 1275-1275/? D/dalvikvm﹕ Added shared lib libnativehelper.so 0x0
02-04 16:17:32.972 1275-1275/? D/dalvikvm﹕ No JNI_OnLoad found in libnativehelper.so 0x0, skipping init
02-04 16:17:33.020 1275-1275/? D/dalvikvm﹕ Note: class Landroid/app/ActivityManagerNative; has 179 unimplemented (abstract) methods
02-04 16:17:33.128 1275-1275/? E/memtrack﹕ Couldn't load memtrack module (No such file or directory)
02-04 16:17:33.132 1275-1275/? E/android.os.Debug﹕ failed to load memtrack module: -2
02-04 16:17:33.264 1275-1275/? D/AndroidRuntime﹕ Calling main entry com.android.commands.am.Am
02-04 16:17:33.284 487-617/? I/ActivityManager﹕ START u0 {act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 cmp=com.mycompany.messenger/com.mycompany.Messenger.ChatBubbleActivity} from pid 1275
02-04 16:17:33.692 1275-1275/? D/AndroidRuntime﹕ Shutting down VM
02-04 16:17:33.692 1275-1279/? D/dalvikvm﹕ GC_CONCURRENT freed 95K, 15% free 576K/676K, paused 1ms+0ms, total 1ms
02-04 16:17:33.884 487-538/? I/ActivityManager﹕ Start proc com.mycompany.messenger for activity com.mycompany.messenger/com.mycompany.Messenger.ChatBubbleActivity: pid=1286 uid=10059 gids={50059, 3003}
02-04 16:17:33.932 1286-1286/? D/dalvikvm﹕ Late-enabling CheckJNI
02-04 16:17:34.228 1286-1286/? D/dalvikvm﹕ GC_FOR_ALLOC freed 60K, 4% free 2873K/2992K, paused 6ms, total 7ms
02-04 16:17:34.236 1286-1286/? I/dalvikvm-heap﹕ Grow heap (frag case) to 3.338MB for 500412-byte allocation
02-04 16:17:34.248 1286-1295/? D/dalvikvm﹕ GC_FOR_ALLOC freed <1K, 4% free 3362K/3484K, paused 11ms, total 11ms
02-04 16:17:34.252 1286-1290/? D/dalvikvm﹕ GC_CONCURRENT freed 0K, 4% free 3362K/3484K, paused 1ms+0ms, total 5ms
02-04 16:17:34.696 1286-1286/? D/libEGL﹕ loaded /system/lib/egl/libEGL_genymotion.so
02-04 16:17:34.708 1286-1286/? D/﹕ HostConnection::get() New Host Connection established 0xb7944cb0, tid 1286
02-04 16:17:34.744 1286-1286/? D/libEGL﹕ loaded /system/lib/egl/libGLESv1_CM_genymotion.so
02-04 16:17:34.744 1286-1286/? D/libEGL﹕ loaded /system/lib/egl/libGLESv2_genymotion.so
02-04 16:17:34.816 1286-1286/? W/EGL_genymotion﹕ eglSurfaceAttrib not implemented
02-04 16:17:34.820 1286-1286/? E/OpenGLRenderer﹕ Getting MAX_TEXTURE_SIZE from GradienCache
02-04 16:17:34.824 1286-1286/? E/OpenGLRenderer﹕ MAX_TEXTURE_SIZE: 8192
02-04 16:17:34.848 1286-1286/? E/OpenGLRenderer﹕ Getting MAX_TEXTURE_SIZE from Caches::initConstraints()
02-04 16:17:34.848 1286-1286/? E/OpenGLRenderer﹕ MAX_TEXTURE_SIZE: 8192
02-04 16:17:34.852 1286-1286/? D/OpenGLRenderer﹕ Enabling debug mode 0
02-04 16:17:34.932 1286-1300/? W/dalvikvm﹕ threadid=12: thread exiting with uncaught exception (group=0xa4d31b20)
02-04 16:17:34.932 1286-1300/? E/AndroidRuntime﹕ FATAL EXCEPTION: AsyncTask #2
Process: com.mycompany.messenger, PID: 1286
java.lang.RuntimeException: An error occured while executing doInBackground()
at android.os.AsyncTask$3.done(AsyncTask.java:300)
at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:355)
at java.util.concurrent.FutureTask.setException(FutureTask.java:222)
at java.util.concurrent.FutureTask.run(FutureTask.java:242)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at java.lang.Thread.run(Thread.java:841)
Caused by: android.util.AndroidRuntimeException: Calling startActivity() from outside of an Activity context requires the FLAG_ACTIVITY_NEW_TASK flag. Is this really what you want?
at android.app.ContextImpl.startActivity(ContextImpl.java:1050)
at android.app.ContextImpl.startActivity(ContextImpl.java:1037)
at android.content.ContextWrapper.startActivity(ContextWrapper.java:311)
at com.mycompany.Messenger.LocalService$DownloadWebpageTask2.doInBackground(LocalService.java:118)
at com.mycompany.Messenger.LocalService$DownloadWebpageTask2.doInBackground(LocalService.java:113)
at android.os.AsyncTask$2.call(AsyncTask.java:288)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at java.lang.Thread.run(Thread.java:841)
02-04 16:17:34.936 487-617/? W/ActivityManager﹕ Force finishing activity com.mycompany.messenger/com.mycompany.Messenger.ChatBubbleActivity
02-04 16:17:35.180 487-840/? W/InputMethodManagerService﹕ Focus gain on non-focused client com.android.internal.view.IInputMethodClient$Stub$Proxy#529ef2ac (uid=10059 pid=1286)
02-04 16:17:35.288 487-617/? I/WindowManager﹕ Screenshot max retries 4 of Token{52998cec ActivityRecord{5294f214 u0 com.mycompany.messenger/com.mycompany.Messenger.ChatBubbleActivity t4 f}} appWin=Window{52948c58 u0 Starting com.mycompany.messenger} drawState=4
02-04 16:17:35.288 487-617/? W/WindowManager﹕ Screenshot failure taking screenshot for (800x1280) to layer 21015
02-04 16:17:38.512 487-502/? I/Choreographer﹕ Skipped 188 frames! The application may be doing too much work on its main thread.
02-04 16:17:38.516 711-711/? I/Choreographer﹕ Skipped 185 frames! The application may be doing too much work on its main thread.
02-04 16:17:39.708 117-117/? D/local_opengl﹕ Select interrupted or nothing to read
02-04 16:17:40.536 711-711/? W/EGL_genymotion﹕ eglSurfaceAttrib not implemented
02-04 16:17:41.260 487-502/? I/Choreographer﹕ Skipped 35 frames! The application may be doing too much work on its main thread.
02-04 16:17:49.560 1286-1300/? I/Process﹕ Sending signal. PID: 1286 SIG: 9
02-04 16:17:49.580 487-616/? W/InputMethodManagerService﹕ Window already focused, ignoring focus gain of: com.android.internal.view.IInputMethodClient$Stub$Proxy#52963b68 attribute=null, token = android.os.BinderProxy#5290713c
02-04 16:17:49.644 487-840/? I/ActivityManager﹕ Process com.mycompany.messenger (pid 1286) has died.
02-04 16:17:49.716 117-117/? D/local_opengl﹕ Select interrupted or nothing to read
02-04 16:17:59.720 117-117/? D/local_opengl﹕ Select interrupted or nothing to read
02-04 16:18:09.728 117-117/? D/local_opengl﹕ Select interrupted or nothing to read
02-04 16:18:19.736 117-117/? D/local_opengl﹕ Select interrupted or nothing to read
02-04 16:18:29.744 117-117/? D/local_opengl﹕ Select interrupted or nothing to read
02-04 16:18:39.752 117-117/? D/local_opengl﹕ Select interrupted or nothing to read
02-04 16:18:49.756 117-117/? D/local_opengl﹕ Select interrupted or nothing to read
02-04 16:18:59.764 117-117/? D/local_opengl﹕ Select interrupted or nothing to read
02-04 16:19:09.772 117-117/? D/local_opengl﹕ Select interrupted or nothing to read
02-04 16:19:19.780 117-117/? D/local_opengl﹕ Select interrupted or nothing to read
02-04 16:19:29.788 117-117/? D/local_opengl﹕ Select interrupted or nothing to read
02-04 16:19:39.792 117-117/? D/local_opengl﹕ Select interrupted or nothing to read
02-04 16:19:49.800 117-117/? D/local_opengl﹕ Select interrupted or nothing to read
Do you want to start an activity or send a broadcast? I don't understand your code.
You are starting an activity from a background thread, that's not allowed.
In your AsyncTask, the method protected String doInBackground(Socket... client) is the only one that doesn't run in the UI thread.
When ever you want to start your Broadcast Receiver you don't call it as an acitivty
Your Method
Intent received = new Intent(ChatBubbleActivity.MESSAGE_RECEIVED);
received.putExtra("current", "Intent is working!!");
startActivity(received);
What it should be
Intent intent = new Intent();
intent.setAction("com.tutorialspoint.CUSTOM_INTENT");
sendBroadcast(intent);
Have a look at these tutorials
Vogella
TutorialsPoint
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'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)
I am new to Android Development. I install CouchDB on the server and created a user. I use following code in my app.
#ReportsCrashes (
formKey = "",
reportType = org.acra.sender.HttpSender.Type.JSON,
httpMethod = org.acra.sender.HttpSender.Method.PUT,
formUri = "localhost:5984/acra-myapp/_design/acra-storage/_update/report",
formUriBasicAuthLogin = "admin",
formUriBasicAuthPassword = "admin"
)
when i run my app from android device it give me following error:
02-04 12:46:26.606: E/ACRA(348): Failed to send crash report for 1391497913000-approved.stacktrace
02-04 12:46:26.606: E/ACRA(348): org.acra.sender.ReportSenderException: Error while sending JSON report via Http PUT
02-04 12:46:26.606: E/ACRA(348): at org.acra.sender.HttpSender.send(HttpSender.java:228)
02-04 12:46:26.606: E/ACRA(348): at org.acra.SendWorker.sendCrashReport(SendWorker.java:179)
02-04 12:46:26.606: E/ACRA(348): at org.acra.SendWorker.checkAndSendReports(SendWorker.java:141)
02-04 12:46:26.606: E/ACRA(348): at org.acra.SendWorker.run(SendWorker.java:77)
02-04 12:46:26.606: E/ACRA(348): Caused by: org.apache.http.conn.HttpHostConnectException: Connection to `*` refused
02-04 12:46:26.606: E/ACRA(348): at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:183)
02-04 12:46:26.606: E/ACRA(348): at org.apache.http.impl.conn.AbstractPoolEntry.open(AbstractPoolEntry.java:164)
02-04 12:46:26.606: E/ACRA(348): at org.apache.http.impl.conn.AbstractPooledConnAdapter.open(AbstractPooledConnAdapter.java:119)
02-04 12:46:26.606: E/ACRA(348): at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:365)
02-04 12:46:26.606: E/ACRA(348): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:555)
02-04 12:46:26.606: E/ACRA(348): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:487)
02-04 12:46:26.606: E/ACRA(348): at org.acra.util.HttpRequest.send(HttpRequest.java:152)
02-04 12:46:26.606: E/ACRA(348): at org.acra.sender.HttpSender.send(HttpSender.java:225)
02-04 12:46:26.606: E/ACRA(348): ... 3 more
02-04 12:46:26.606: E/ACRA(348): Caused by: java.net.ConnectException: failed to connect to after 3000ms: isConnected failed: ECONNREFUSED (Connection refused)
02-04 12:46:26.606: E/ACRA(348): at libcore.io.IoBridge.isConnected(IoBridge.java:250)
02-04 12:46:26.606: E/ACRA(348): at libcore.io.IoBridge.connectErrno(IoBridge.java:178)
02-04 12:46:26.606: E/ACRA(348): at libcore.io.IoBridge.connect(IoBridge.java:112)
02-04 12:46:26.606: E/ACRA(348): at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:192)
02-04 12:46:26.606: E/ACRA(348): at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:459)
02-04 12:46:26.606: E/ACRA(348): at java.net.Socket.connect(Socket.java:859)
02-04 12:46:26.606: E/ACRA(348): at org.apache.http.conn.scheme.PlainSocketFactory.connectSocket(PlainSocketFactory.java:119)
02-04 12:46:26.606: E/ACRA(348): at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:144)
02-04 12:46:26.606: E/ACRA(348): ... 10 more
02-04 12:46:26.606: E/ACRA(348): Caused by: libcore.io.ErrnoException: isConnected failed: ECONNREFUSED (Connection refused)
02-04 12:46:26.606: E/ACRA(348): at libcore.io.IoBridge.isConnected(IoBridge.java:234)
Can't seem to figure out this error.Please help me.
You access your computer's localhost as 10.0.2.2 from emulator. more details
http://developer.android.com/guide/appendix/faq/commontasks.html#localhostalias
try below code
formKey = "",
reportType = org.acra.sender.HttpSender.Type.JSON,
httpMethod = org.acra.sender.HttpSender.Method.PUT,
formUri = "10.0.2.2:5984/acra-mediwatch/_design/acra-storage/_update/report",
formUriBasicAuthLogin = "admin",
formUriBasicAuthPassword = "admin"
Add the INTERNET permission to your manifest file.
You have to add this line:
<uses-permission android:name="android.permission.INTERNET" />
outside the application tag in your AndroidManifest.xml
"Connection refused" means that the host could be reached but there wasn't anything listening in the target port. So, first make sure you have your server running on 208.109.91.98 port 5984.
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