I just want to run with XXHDPI emulator. I created an emulator of XXHDPI(screen size=5.0, resolution 1080/1920, RAM = 1080 MIB). At first, It run my application well but just 3 or 4 minutes later, the emulator was stopped and show this errors. How can I solve this issue? What should I do? I just want to run with XXHDPI emulator peacefully.
05-09 00:28:09.623: E/EGL_emulation(1475): rcCreateWindowSurface returned 0
05-09 00:28:09.623: E/EGL_emulation(1475): tid 1475: eglCreateWindowSurface(631): error 0x3003 (EGL_BAD_ALLOC)
05-09 00:28:09.633: D/AndroidRuntime(1475): Shutting down VM
05-09 00:28:09.633: W/dalvikvm(1475): threadid=1: thread exiting with uncaught exception (group=0xb1a51ba8)
05-09 00:28:09.673: E/AndroidRuntime(1475): FATAL EXCEPTION: main
05-09 00:28:09.673: E/AndroidRuntime(1475): Process: com.speedlink, PID: 1475
05-09 00:28:09.673: E/AndroidRuntime(1475): java.lang.RuntimeException: createWindowSurface failed EGL_BAD_ALLOC
05-09 00:28:09.673: E/AndroidRuntime(1475): at android.view.HardwareRenderer$GlRenderer.createSurface(HardwareRenderer.java:1349)
05-09 00:28:09.673: E/AndroidRuntime(1475): at android.view.HardwareRenderer$GlRenderer.createEglSurface(HardwareRenderer.java:1241)
05-09 00:28:09.673: E/AndroidRuntime(1475): at android.view.HardwareRenderer$GlRenderer.initialize(HardwareRenderer.java:1058)
05-09 00:28:09.673: E/AndroidRuntime(1475): at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1550)
05-09 00:28:09.673: E/AndroidRuntime(1475): at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1000)
05-09 00:28:09.673: E/AndroidRuntime(1475): at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:5670)
05-09 00:28:09.673: E/AndroidRuntime(1475): at android.view.Choreographer$CallbackRecord.run(Choreographer.java:761)
05-09 00:28:09.673: E/AndroidRuntime(1475): at android.view.Choreographer.doCallbacks(Choreographer.java:574)
05-09 00:28:09.673: E/AndroidRuntime(1475): at android.view.Choreographer.doFrame(Choreographer.java:544)
05-09 00:28:09.673: E/AndroidRuntime(1475): at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:747)
05-09 00:28:09.673: E/AndroidRuntime(1475): at android.os.Handler.handleCallback(Handler.java:733)
05-09 00:28:09.673: E/AndroidRuntime(1475): at android.os.Handler.dispatchMessage(Handler.java:95)
05-09 00:28:09.673: E/AndroidRuntime(1475): at android.os.Looper.loop(Looper.java:136)
05-09 00:28:09.673: E/AndroidRuntime(1475): at android.app.ActivityThread.main(ActivityThread.java:5017)
05-09 00:28:09.673: E/AndroidRuntime(1475): at java.lang.reflect.Method.invokeNative(Native Method)
05-09 00:28:09.673: E/AndroidRuntime(1475): at java.lang.reflect.Method.invoke(Method.java:515)
05-09 00:28:09.673: E/AndroidRuntime(1475): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
05-09 00:28:09.673: E/AndroidRuntime(1475): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
05-09 00:28:09.673: E/AndroidRuntime(1475): at dalvik.system.NativeStart.main(Native Method)
Try genymotion emulators. They are a lot faster.
Related
I am trying to view a file word as well as .txt file using android as follows:
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.setDataAndType(Uri.parse("file:///android_asset/usage.txt"), "plain/text");
getApplicationContext().startActivity(intent);
and
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.setDataAndType(Uri.parse("file:///android_asset/USAGE_INSTRUCTIONS_FOR_SMART_RESPONDER.doc"), "plain/text");
getApplicationContext().startActivity(intent);
inside a method of an activity. Now, i have ES File Manager installed on my device. But i keep on getting the error:
05-09 01:24:53.516: W/System.err(28918): android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.VIEW dat=file:///android_asset/USAGE_INSTRUCTIONS_FOR_SMART_RESPONDER.doc typ=plain/text flg=0x10000000 }
05-09 01:24:53.516: W/System.err(28918): at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1622)
05-09 01:24:53.516: W/System.err(28918): at android.app.Instrumentation.execStartActivity(Instrumentation.java:1417)
05-09 01:24:53.516: W/System.err(28918): at android.app.ContextImpl.startActivity(ContextImpl.java:949)
05-09 01:24:53.524: W/System.err(28918): at android.app.ContextImpl.startActivity(ContextImpl.java:931)
05-09 01:24:53.524: W/System.err(28918): at android.content.ContextWrapper.startActivity(ContextWrapper.java:284)
05-09 01:24:53.524: W/System.err(28918): at com.pack.android.activity.ResponderActivity.onHelpMenuSelected(ResponderActivity.java:1733)
05-09 01:24:53.524: W/System.err(28918): at com.pack.android.activity.ResponderActivity.onOptionsItemSelected(ResponderActivity.java:1711)
05-09 01:24:53.532: W/System.err(28918): at android.app.Activity.onMenuItemSelected(Activity.java:2548)
05-09 01:24:53.532: W/System.err(28918): at com.android.internal.policy.impl.PhoneWindow.onMenuItemSelected(PhoneWindow.java:980)
05-09 01:24:53.532: W/System.err(28918): at com.android.internal.view.menu.MenuBuilder.dispatchMenuItemSelected(MenuBuilder.java:735)
05-09 01:24:53.532: W/System.err(28918): at com.android.internal.view.menu.MenuItemImpl.invoke(MenuItemImpl.java:149)
05-09 01:24:53.539: W/System.err(28918): at com.android.internal.view.menu.MenuBuilder.performItemAction(MenuBuilder.java:874)
05-09 01:24:53.539: W/System.err(28918): at com.android.internal.view.menu.MenuPopupHelper.onItemClick(MenuPopupHelper.java:156)
05-09 01:24:53.539: W/System.err(28918): at android.widget.AdapterView.performItemClick(AdapterView.java:298)
05-09 01:24:53.539: W/System.err(28918): at android.widget.AbsListView.performItemClick(AbsListView.java:1100)
05-09 01:24:53.547: W/System.err(28918): at android.widget.AbsListView$PerformClick.run(AbsListView.java:2749)
05-09 01:24:53.547: W/System.err(28918): at android.widget.AbsListView$1.run(AbsListView.java:3423)
05-09 01:24:53.547: W/System.err(28918): at android.os.Handler.handleCallback(Handler.java:725)
05-09 01:24:53.547: W/System.err(28918): at android.os.Handler.dispatchMessage(Handler.java:92)
05-09 01:24:53.547: W/System.err(28918): at android.os.Looper.loop(Looper.java:137)
05-09 01:24:53.555: W/System.err(28918): at android.app.ActivityThread.main(ActivityThread.java:5041)
05-09 01:24:53.555: W/System.err(28918): at java.lang.reflect.Method.invokeNative(Native Method)
05-09 01:24:53.555: W/System.err(28918): at java.lang.reflect.Method.invoke(Method.java:511)
05-09 01:24:53.555: W/System.err(28918): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
05-09 01:24:53.555: W/System.err(28918): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
05-09 01:24:53.563: W/System.err(28918): at dalvik.system.NativeStart.main(Native Method)
and
05-09 01:29:43.071: W/System.err(28918): android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.VIEW dat=file:///android_asset/usage.txt typ=plain/text flg=0x10000000 }
05-09 01:29:43.071: W/System.err(28918): at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1622)
05-09 01:29:43.078: W/System.err(28918): at android.app.Instrumentation.execStartActivity(Instrumentation.java:1417)
05-09 01:29:43.078: W/System.err(28918): at android.app.ContextImpl.startActivity(ContextImpl.java:949)
05-09 01:29:43.086: W/System.err(28918): at android.app.ContextImpl.startActivity(ContextImpl.java:931)
05-09 01:29:43.086: W/System.err(28918): at android.content.ContextWrapper.startActivity(ContextWrapper.java:284)
05-09 01:29:43.086: W/System.err(28918): at com.pack.android.activity.ResponderActivity.onHelpMenuSelected(ResponderActivity.java:1748)
05-09 01:29:43.086: W/System.err(28918): at com.pack.android.activity.ResponderActivity.onOptionsItemSelected(ResponderActivity.java:1711)
05-09 01:29:43.094: W/System.err(28918): at android.app.Activity.onMenuItemSelected(Activity.java:2548)
05-09 01:29:43.094: W/System.err(28918): at com.android.internal.policy.impl.PhoneWindow.onMenuItemSelected(PhoneWindow.java:980)
05-09 01:29:43.094: W/System.err(28918): at com.android.internal.view.menu.MenuBuilder.dispatchMenuItemSelected(MenuBuilder.java:735)
05-09 01:29:43.094: W/System.err(28918): at com.android.internal.view.menu.MenuItemImpl.invoke(MenuItemImpl.java:149)
05-09 01:29:43.094: W/System.err(28918): at com.android.internal.view.menu.MenuBuilder.performItemAction(MenuBuilder.java:874)
05-09 01:29:43.102: W/System.err(28918): at com.android.internal.view.menu.MenuPopupHelper.onItemClick(MenuPopupHelper.java:156)
05-09 01:29:43.102: W/System.err(28918): at android.widget.AdapterView.performItemClick(AdapterView.java:298)
05-09 01:29:43.102: W/System.err(28918): at android.widget.AbsListView.performItemClick(AbsListView.java:1100)
05-09 01:29:43.102: W/System.err(28918): at android.widget.AbsListView$PerformClick.run(AbsListView.java:2749)
05-09 01:29:43.110: W/System.err(28918): at android.widget.AbsListView$1.run(AbsListView.java:3423)
05-09 01:29:43.110: W/System.err(28918): at android.os.Handler.handleCallback(Handler.java:725)
05-09 01:29:43.110: W/System.err(28918): at android.os.Handler.dispatchMessage(Handler.java:92)
05-09 01:29:43.118: W/System.err(28918): at android.os.Looper.loop(Looper.java:137)
05-09 01:29:43.118: W/System.err(28918): at android.app.ActivityThread.main(ActivityThread.java:5041)
05-09 01:29:43.118: W/System.err(28918): at java.lang.reflect.Method.invokeNative(Native Method)
05-09 01:29:43.118: W/System.err(28918): at java.lang.reflect.Method.invoke(Method.java:511)
05-09 01:29:43.125: W/System.err(28918): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
05-09 01:29:43.125: W/System.err(28918): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
05-09 01:29:43.125: W/System.err(28918): at dalvik.system.NativeStart.main(Native Method)
I have got these 2 files in my assets folder but still can't open it!
Any help would be great !
EDIT
using proper MIME_TYPE does resolve the error but now i am getting another error :
05-09 01:42:27.647: W/System.err(29614): java.lang.RuntimeException: java.io.FileNotFoundException: /android_asset/USAGE_INSTRUCTIONS_FOR_SMART_RESPONDER.doc: open failed: ENOENT (No such file or directory)
05-09 01:42:27.647: W/System.err(29614): at com.tf.fastole2.CompoundBinaryUtil.openRandomAccessFile(CompoundBinaryUtil.java:15)
05-09 01:42:27.647: W/System.err(29614): at com.tf.fastole2.TFOleFileSystem.openFileSystem(TFOleFileSystem.java:81)
05-09 01:42:27.647: W/System.err(29614): at com.tf.fastole2.TFOleFsFactory.openFileSystem(TFOleFsFactory.java:32)
05-09 01:42:27.647: W/System.err(29614): at com.tf.write.filter.CheckFileType.isHwp50(CheckFileType.java:240)
05-09 01:42:27.655: W/System.err(29614): at com.tf.write.filter.CheckFileType.getType(CheckFileType.java:35)
05-09 01:42:27.655: W/System.err(29614): at com.tf.thinkdroid.write.viewer.action.Open$2.run(Unknown Source)
05-09 01:42:27.655: W/System.err(29614): at java.lang.Thread.run(Thread.java:856)
05-09 01:42:27.655: W/System.err(29614): Caused by: java.io.FileNotFoundException: /android_asset/USAGE_INSTRUCTIONS_FOR_SMART_RESPONDER.doc: open failed: ENOENT (No such file or directory)
05-09 01:42:27.655: W/System.err(29614): at libcore.io.IoBridge.open(IoBridge.java:416)
05-09 01:42:27.655: W/System.err(29614): at java.io.RandomAccessFile.<init>(RandomAccessFile.java:118)
05-09 01:42:27.655: W/System.err(29614): at com.tf.fastole2.CompoundBinaryUtil.openRandomAccessFile(CompoundBinaryUtil.java:11)
05-09 01:42:27.655: W/System.err(29614): ... 6 more
05-09 01:42:27.655: W/System.err(29614): Caused by: libcore.io.ErrnoException: open failed: ENOENT (No such file or directory)
05-09 01:42:27.655: W/System.err(29614): at libcore.io.Posix.open(Native Method)
05-09 01:42:27.655: W/System.err(29614): at libcore.io.BlockGuardOs.open(BlockGuardOs.java:110)
05-09 01:42:27.655: W/System.err(29614): at libcore.io.IoBridge.open(IoBridge.java:400)
05-09 01:42:27.655: W/System.err(29614): ... 8 more
05-09 01:42:27.655: W/System.err(29614): java.io.FileNotFoundException: /android_asset/USAGE_INSTRUCTIONS_FOR_SMART_RESPONDER.doc: open failed: ENOENT (No such file or directory)
05-09 01:42:27.655: W/System.err(29614): at libcore.io.IoBridge.open(IoBridge.java:416)
05-09 01:42:27.655: W/System.err(29614): at java.io.RandomAccessFile.<init>(RandomAccessFile.java:118)
05-09 01:42:27.655: W/System.err(29614): at java.io.RandomAccessFile.<init>(RandomAccessFile.java:150)
05-09 01:42:27.655: W/System.err(29614): at java.util.zip.ZipFile.<init>(ZipFile.java:130)
05-09 01:42:27.655: W/System.err(29614): at java.util.zip.ZipFile.<init>(ZipFile.java:103)
05-09 01:42:27.655: W/System.err(29614): at com.tf.io.CachedZipFile$RealZipFileImpl.<init>(CachedZipFile.java:274)
05-09 01:42:27.655: W/System.err(29614): at com.tf.io.CachedZipFile$RealZipFileImpl.<init>(CachedZipFile.java:269)
05-09 01:42:27.655: W/System.err(29614): at com.tf.io.CachedZipFile.create(CachedZipFile.java:61)
05-09 01:42:27.655: W/System.err(29614): at com.tf.io.CachedZipFile.create(CachedZipFile.java:37)
05-09 01:42:27.655: W/System.err(29614): at com.tf.write.filter.CheckFileType.isDocx(CheckFileType.java:322)
05-09 01:42:27.655: W/System.err(29614): at com.tf.write.filter.CheckFileType.getType(CheckFileType.java:47)
05-09 01:42:27.655: W/System.err(29614): at com.tf.thinkdroid.write.viewer.action.Open$2.run(Unknown Source)
05-09 01:42:27.655: W/System.err(29614): at java.lang.Thread.run(Thread.java:856)
05-09 01:42:27.655: W/System.err(29614): Caused by: libcore.io.ErrnoException: open failed: ENOENT (No such file or directory)
05-09 01:42:27.663: W/System.err(29614): at libcore.io.Posix.open(Native Method)
05-09 01:42:27.663: W/System.err(29614): at libcore.io.BlockGuardOs.open(BlockGuardOs.java:110)
05-09 01:42:27.663: W/System.err(29614): at libcore.io.IoBridge.open(IoBridge.java:400)
05-09 01:42:27.663: W/System.err(29614): ... 12 more
The issue is that you are trying to give access via intents to 3rd party applications that doesn't have permission to access your files.
Android's Security Model doesn't allow any other app to access your private data (assets/resources ....) root here is an exception.
So to make your file available to such apps consider copying your files to a public directory CacheDir maybe the most suitable option.
by doing so you can use intents to view your data the way you are using them right now.
for more about copying files to external dir look here:
Android: how to copy files in assets to sdcard
Also while at it take a look at Android's Security Model
P.S don't forget about WRITE_EXTERNAL_STORAGE permession..
Good luck
You should use text/plain instead of plain/text.
As is mentioned in the exception log,
java.io.FileNotFoundException: /android_asset/USAGE_INSTRUCTIONS_FOR_SMART_RESPONDER.doc: open failed: ENOENT (No such file or directory)
its not able to find the file. Verify if the file is indeed there in that location. Also, as Brigham mentioned, use text/plain.
Exception says that File not exist. Watch that you are pointing to /android_asset/ folder in internal memory.
Are you sure that you not put this file on SDCard?
I'm trying to follow the advice from this post:
But when I run this code, my program crashes. Here is my code:
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
/* Change the font for the password hint to match that of the
* user name field */
EditText pw = (EditText) findViewById(R.id.password);
pw.setTypeface(Typeface.DEFAULT); //<---Crashes on this line
pw.setTransformationMethod(new PasswordTransformationMethod());
setContentView(R.layout.activity_main);
}
Here is the XML for this object:
<EditText
android:id="#+id/password"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/userName"
android:layout_alignRight="#+id/appName"
android:layout_below="#+id/userName"
android:layout_marginTop="14dp"
android:ems="10"
android:hint="#string/password"
android:inputType="textPassword" />
And finally, here is the LogCat output where I can see the error:
05-09 00:30:21.408: E/Trace(16987): error opening trace file: No such
file or directory (2) 05-09 00:30:21.918: D/AndroidRuntime(16987):
Shutting down VM 05-09 00:30:21.918: W/dalvikvm(16987): threadid=1:
thread exiting with uncaught exception (group=0x40a71930) 05-09
00:30:21.978: E/AndroidRuntime(16987): FATAL EXCEPTION: main 05-09
00:30:21.978: E/AndroidRuntime(16987): java.lang.RuntimeException:
Unable to start activity
ComponentInfo{com.mobilenicity.gen_co_event_marketing_app/com.mobilenicity.gen_co_event_marketing_app.MainActivity}:
java.lang.NullPointerException 05-09 00:30:21.978:
E/AndroidRuntime(16987): at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2180)
05-09 00:30:21.978: E/AndroidRuntime(16987): at
android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
05-09 00:30:21.978: E/AndroidRuntime(16987): at
android.app.ActivityThread.access$600(ActivityThread.java:141) 05-09
00:30:21.978: E/AndroidRuntime(16987): at
android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
05-09 00:30:21.978: E/AndroidRuntime(16987): at
android.os.Handler.dispatchMessage(Handler.java:99) 05-09
00:30:21.978: E/AndroidRuntime(16987): at
android.os.Looper.loop(Looper.java:137) 05-09 00:30:21.978:
E/AndroidRuntime(16987): at
android.app.ActivityThread.main(ActivityThread.java:5041) 05-09
00:30:21.978: E/AndroidRuntime(16987): at
java.lang.reflect.Method.invokeNative(Native Method) 05-09
00:30:21.978: E/AndroidRuntime(16987): at
java.lang.reflect.Method.invoke(Method.java:511) 05-09 00:30:21.978:
E/AndroidRuntime(16987): at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
05-09 00:30:21.978: E/AndroidRuntime(16987): at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560) 05-09
00:30:21.978: E/AndroidRuntime(16987): at
dalvik.system.NativeStart.main(Native Method) 05-09 00:30:21.978:
E/AndroidRuntime(16987): Caused by: java.lang.NullPointerException
05-09 00:30:21.978: E/AndroidRuntime(16987): at
com.mobilenicity.gen_co_event_marketing_app.MainActivity.onCreate(MainActivity.java:26)
05-09 00:30:21.978: E/AndroidRuntime(16987): at
android.app.Activity.performCreate(Activity.java:5104) 05-09
00:30:21.978: E/AndroidRuntime(16987): at
android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
05-09 00:30:21.978: E/AndroidRuntime(16987): at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144)
05-09 00:30:21.978: E/AndroidRuntime(16987): ... 11 more
Can't figure out what is going wrong. Can anybody see it? Thanks!
Change the call of setContentView(R.layout.activity_main);
Call it just after super.onCreate(savedInstanceState);
When you're doing EditText pw = (EditText) findViewById(R.id.password);, findViewById "can't retrieve" the EditText that you have defined in your layout (because you call setContentView after) so findViewById returns null and when you're doing pw.setTypeface(Typeface.DEFAULT); it throws a NPE because pw is null.
Very short app, you press a button and play a sound bite. The sounds are in mp3/wav format, the app works on the VM in eclipse but does not when trying it on phone (Galaxy S2).
public class SoundBites extends Activity {
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.soundbite);
}
public void SheldonButtonListener(View v){
MediaPlayer mp_bazinga = MediaPlayer.create(getBaseContext(), R.raw.bazinga);
mp_bazinga.start();
}
public void SpanishButtonListener(View v){
MediaPlayer mp_spanish = MediaPlayer.create(getBaseContext(), R.raw.spanish_inquisition);
mp_spanish.start();
}
public void NudgeButtonListener(View v){
MediaPlayer mp_nudge = MediaPlayer.create(getBaseContext(), R.raw.nudge_nudge);
mp_nudge.start();
}
}
with xml-file:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:weightSum="1.0">
<View
android:id="#+id/buttons_helper1"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_centerHorizontal="true" />
<View
android:id="#+id/buttons_helper2"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_centerVertical="true" />
<Button
android:id="#+id/bazinga_button"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_toLeftOf="#+id/buttons_helper1"
android:layout_above="#+id/buttons_helper2"
android:background="#drawable/sheldon_cooper"
android:onClick="SheldonButtonListener" />
<Button
android:id="#+id/spanish_button"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_toRightOf="#+id/buttons_helper1"
android:layout_above="#+id/buttons_helper2"
android:background="#drawable/spanish_inquisition"
android:onClick="SpanishButtonListener" />
<Button
android:id="#+id/nudge_button"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_below="#+id/buttons_helper2"
android:background="#drawable/nudge_nudge"
android:onClick="NudgeButtonListener" />
</RelativeLayout>
and I get the following error:
05-09 20:12:15.395: E/MediaPlayer(15110): Unable to to create media player
05-09 20:12:15.405: D/MediaPlayer(15110): create failed:
05-09 20:12:15.405: D/MediaPlayer(15110): java.io.IOException: setDataSourceFD failed.: status=0x80000000
05-09 20:12:15.405: D/MediaPlayer(15110): at android.media.MediaPlayer.setDataSource(Native Method)
05-09 20:12:15.405: D/MediaPlayer(15110): at android.media.MediaPlayer.create(MediaPlayer.java:741)
05-09 20:12:15.405: D/MediaPlayer(15110): at com.example.goran.SoundBites.NudgeButtonListener(SoundBites.java:30)
05-09 20:12:15.405: D/MediaPlayer(15110): at java.lang.reflect.Method.invokeNative(Native Method)
05-09 20:12:15.405: D/MediaPlayer(15110): at java.lang.reflect.Method.invoke(Method.java:511)
05-09 20:12:15.405: D/MediaPlayer(15110): at android.view.View$1.onClick(View.java:3064)
05-09 20:12:15.405: D/MediaPlayer(15110): at android.view.View.performClick(View.java:3591)
05-09 20:12:15.405: D/MediaPlayer(15110): at android.view.View$PerformClick.run(View.java:14263)
05-09 20:12:15.405: D/MediaPlayer(15110): at android.os.Handler.handleCallback(Handler.java:605)
05-09 20:12:15.405: D/MediaPlayer(15110): at android.os.Handler.dispatchMessage(Handler.java:92)
05-09 20:12:15.405: D/MediaPlayer(15110): at android.os.Looper.loop(Looper.java:137)
05-09 20:12:15.405: D/MediaPlayer(15110): at android.app.ActivityThread.main(ActivityThread.java:4507)
05-09 20:12:15.405: D/MediaPlayer(15110): at java.lang.reflect.Method.invokeNative(Native Method)
05-09 20:12:15.405: D/MediaPlayer(15110): at java.lang.reflect.Method.invoke(Method.java:511)
05-09 20:12:15.405: D/MediaPlayer(15110): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:790)
05-09 20:12:15.405: D/MediaPlayer(15110): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:557)
05-09 20:12:15.405: D/MediaPlayer(15110): at dalvik.system.NativeStart.main(Native Method)
05-09 20:12:15.405: D/AndroidRuntime(15110): Shutting down VM
05-09 20:12:15.405: W/dalvikvm(15110): threadid=1: thread exiting with uncaught exception (group=0x40c3e1f8)
05-09 20:12:15.420: E/AndroidRuntime(15110): FATAL EXCEPTION: main
05-09 20:12:15.420: E/AndroidRuntime(15110): java.lang.IllegalStateException: Could not execute method of the activity
05-09 20:12:15.420: E/AndroidRuntime(15110): at android.view.View$1.onClick(View.java:3069)
05-09 20:12:15.420: E/AndroidRuntime(15110): at android.view.View.performClick(View.java:3591)
05-09 20:12:15.420: E/AndroidRuntime(15110): at android.view.View$PerformClick.run(View.java:14263)
05-09 20:12:15.420: E/AndroidRuntime(15110): at android.os.Handler.handleCallback(Handler.java:605)
05-09 20:12:15.420: E/AndroidRuntime(15110): at android.os.Handler.dispatchMessage(Handler.java:92)
05-09 20:12:15.420: E/AndroidRuntime(15110): at android.os.Looper.loop(Looper.java:137)
05-09 20:12:15.420: E/AndroidRuntime(15110): at android.app.ActivityThread.main(ActivityThread.java:4507)
05-09 20:12:15.420: E/AndroidRuntime(15110): at java.lang.reflect.Method.invokeNative(Native Method)
05-09 20:12:15.420: E/AndroidRuntime(15110): at java.lang.reflect.Method.invoke(Method.java:511)
05-09 20:12:15.420: E/AndroidRuntime(15110): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:790)
05-09 20:12:15.420: E/AndroidRuntime(15110): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:557)
05-09 20:12:15.420: E/AndroidRuntime(15110): at dalvik.system.NativeStart.main(Native Method)
05-09 20:12:15.420: E/AndroidRuntime(15110): Caused by: java.lang.reflect.InvocationTargetException
05-09 20:12:15.420: E/AndroidRuntime(15110): at java.lang.reflect.Method.invokeNative(Native Method)
05-09 20:12:15.420: E/AndroidRuntime(15110): at java.lang.reflect.Method.invoke(Method.java:511)
05-09 20:12:15.420: E/AndroidRuntime(15110): at android.view.View$1.onClick(View.java:3064)
05-09 20:12:15.420: E/AndroidRuntime(15110): ... 11 more
05-09 20:12:15.420: E/AndroidRuntime(15110): Caused by: java.lang.NullPointerException
05-09 20:12:15.420: E/AndroidRuntime(15110): at com.example.goran.SoundBites.NudgeButtonListener(SoundBites.java:31)
05-09 20:12:15.420: E/AndroidRuntime(15110): ... 14 more
Tried to google this badboy but have come up empty handed so far, anyone got any ideas? The thing that perturbs me is that it works on the VM but not on my phone.
EDIT: Found two problems, one was that I needed to take control over the Audio Volume, the other one seems to be that my WAV-files are corrupt, made it output the mp3 now at least!
According to this question: R.raw.anything cannot be resolved
Eclipse decided to import android.R not your package_name.R file...
Or
You need to use your full package name to reference raw resources.
MediaPlayer mp_nudge = MediaPlayer.create(getBaseContext(), com.exmaple.goran.R.raw.nudge_nudge);
Try Fix Project Properties. Then cleaning your project!
R wil be generated again.
My program is working absolutely fine from android 2.1 to android 2.3
But its not working on higher version of android
I have used in my manifest file
<uses-sdk android:minSdkVersion="7"
android:targetSdkVersion="10"
android:maxSdkVersion="15"/>
Logcat output error while running the project on android 4.0.3 avd results in
05-09 12:45:12.051: E/AndroidRuntime(530): FATAL EXCEPTION: main`
05-09 12:45:12.051: E/AndroidRuntime(530): java.lang.RuntimeException:
Unable to start activity ComponentInfo{giv.home/giv.home.Start}:
android.os.NetworkOnMainThreadException 05-09 12:45:12.051:
E/AndroidRuntime(530): at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1956)
05-09 12:45:12.051: E/AndroidRuntime(530): at
android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
05-09 12:45:12.051: E/AndroidRuntime(530): at
android.app.ActivityThread.access$600(ActivityThread.java:123) 05-09
12:45:12.051: E/AndroidRuntime(530): at
android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
05-09 12:45:12.051: E/AndroidRuntime(530): at
android.os.Handler.dispatchMessage(Handler.java:99) 05-09
12:45:12.051: E/AndroidRuntime(530): at
android.os.Looper.loop(Looper.java:137) 05-09 12:45:12.051:
E/AndroidRuntime(530): at
android.app.ActivityThread.main(ActivityThread.java:4424) 05-09
12:45:12.051: E/AndroidRuntime(530): at
java.lang.reflect.Method.invokeNative(Native Method) 05-09
12:45:12.051: E/AndroidRuntime(530): at
java.lang.reflect.Method.invoke(Method.java:511) 05-09 12:45:12.051:
E/AndroidRuntime(530): at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
05-09 12:45:12.051: E/AndroidRuntime(530): at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551) 05-09
12:45:12.051: E/AndroidRuntime(530): at
dalvik.system.NativeStart.main(Native Method) 05-09 12:45:12.051:
E/AndroidRuntime(530): Caused by:
android.os.NetworkOnMainThreadException 05-09 12:45:12.051:
E/AndroidRuntime(530): at
android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode.java:1099)
05-09 12:45:12.051: E/AndroidRuntime(530): at
java.net.InetAddress.lookupHostByName(InetAddress.java:391) 05-09
12:45:12.051: E/AndroidRuntime(530): at
java.net.InetAddress.getAllByNameImpl(InetAddress.java:242) 05-09
12:45:12.051: E/AndroidRuntime(530): at
java.net.InetAddress.getAllByName(InetAddress.java:220) 05-09
12:45:12.051: E/AndroidRuntime(530): at
org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:137)
05-09 12:45:12.051: E/AndroidRuntime(530): at
org.apache.http.impl.conn.AbstractPoolEntry.open(AbstractPoolEntry.java:164)
05-09 12:45:12.051: E/AndroidRuntime(530): at
org.apache.http.impl.conn.AbstractPooledConnAdapter.open(AbstractPooledConnAdapter.java:119)
05-09 12:45:12.051: E/AndroidRuntime(530): at
org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:360)
05-09 12:45:12.051: E/AndroidRuntime(530): at
org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:555)
05-09 12:45:12.051: E/AndroidRuntime(530): at
org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:487)
05-09 12:45:12.051: E/AndroidRuntime(530): at
org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:465)
05-09 12:45:12.051: E/AndroidRuntime(530): at
giv.home.ConnectionClass.connectToServer(ConnectionClass.java:41)
05-09 12:45:12.051: E/AndroidRuntime(530): at
giv.home.Start.onCreate(Start.java:64) 05-09 12:45:12.051:
E/AndroidRuntime(530): at
android.app.Activity.performCreate(Activity.java:4465) 05-09
12:45:12.051: E/AndroidRuntime(530): at
android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
05-09 12:45:12.051: E/AndroidRuntime(530): at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1920)
05-09 12:45:12.051: E/AndroidRuntime(530): ... 11 more
I think this is because you're trying to use HTTPConnect in the main thread... Android no longer supports using HTTP in the main thread and requires that you do it in a background thread. Just guessing, of course... but that's what I suspect is happening.
However, if your target SDK version is 10, then why not just skip setting the max? I mean... what is it about ICS that you feel will be the absolute highest level that your app can run on? the min and target are totally sufficient, I believe. The point of setting a Max is so that (for example) your app won't be installable on ICS now that ICS is available and you know there's something about it that your app doesn't support. So, in that case you'd set 13 and only Honeycomb users (and lower) would be able to use it. Since 15 is the highest version available, setting it is premature... 16 might be just as capable of handling your app as all the rest, for all you know! :)
[EDIT]
You don't even need an AsyncTask (though that would be the more Androidy way to do it).
For now just use a regular Thread...
Handler h = new Handler();
private Runnable stuffToDoAfterPost = new Runnable(){
public void run(){
//whatever you wish to happen after you have done your server call
}
};
private class CallServer extends Thread{
public void run(){
//make your server call here...
//then...
h.post(stuffToDoAfterPost);
}
}
new CallServer().start();
To resovled StrictMode issue you need to use below code in your activity -
static{
StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
StrictMode.setThreadPolicy(policy);
}
I am trying to run a sample bluetooth chat application onto my smartphone (running Android 2.3). The target build project in Eclipse uses Android API level 10
the same project includes this in the manifest:
<uses-sdk minSdkVersion="6" android:targetSdkVersion="10" />
How do I get around this problem? Any Idea
These are my console errors
2012-05-09 12:30:09 - BluetoothChat] Android Launch!
[2012-05-09 12:30:09 - BluetoothChat] adb is running normally.
[2012-05-09 12:30:09 - BluetoothChat] Performing com.example.android.BluetoothChat.BluetoothChat activity launch
[2012-05-09 12:30:09 - BluetoothChat] Automatic Target Mode: Several compatible targets. Please select a target device.
[2012-05-09 12:30:13 - BluetoothChat] WARNING: Application does not specify an API level requirement!
[2012-05-09 12:30:13 - BluetoothChat] Device API version is 10 (Android 2.3.3)
[2012-05-09 12:30:13 - BluetoothChat] Uploading BluetoothChat.apk onto device 'emulator-5556'
[2012-05-09 12:30:14 - BluetoothChat] Installing BluetoothChat.apk...
[2012-05-09 12:30:21 - BluetoothChat] Success!
[2012-05-09 12:30:21 - BluetoothChat] Starting activity com.example.android.BluetoothChat.BluetoothChat on device emulator-5556
[2012-05-09 12:30:23 - BluetoothChat] ActivityManager: Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=com.example.android.BluetoothChat/.BluetoothChat }
And logcat showing these errors
05-09 06:53:04.284: W/dalvikvm(435): threadid=1: thread exiting with uncaught exception (group=0x40015560)
05-09 06:53:04.524: E/AndroidRuntime(435): FATAL EXCEPTION: main
05-09 06:53:04.524: E/AndroidRuntime(435): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.example.android.BluetoothChat/com.example.android.BluetoothChat.BluetoothChat}: java.lang.ClassNotFoundException: com.example.android.BluetoothChat.BluetoothChat in loader dalvik.system.PathClassLoader[/data/app/com.example.android.BluetoothChat-2.apk]
05-09 06:53:04.524: E/AndroidRuntime(435): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1569)
05-09 06:53:04.524: E/AndroidRuntime(435): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
05-09 06:53:04.524: E/AndroidRuntime(435): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
05-09 06:53:04.524: E/AndroidRuntime(435): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
05-09 06:53:04.524: E/AndroidRuntime(435): at android.os.Handler.dispatchMessage(Handler.java:99)
05-09 06:53:04.524: E/AndroidRuntime(435): at android.os.Looper.loop(Looper.java:123)
05-09 06:53:04.524: E/AndroidRuntime(435): at android.app.ActivityThread.main(ActivityThread.java:3683)
05-09 06:53:04.524: E/AndroidRuntime(435): at java.lang.reflect.Method.invokeNative(Native Method)
05-09 06:53:04.524: E/AndroidRuntime(435): at java.lang.reflect.Method.invoke(Method.java:507)
05-09 06:53:04.524: E/AndroidRuntime(435): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
05-09 06:53:04.524: E/AndroidRuntime(435): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
05-09 06:53:04.524: E/AndroidRuntime(435): at dalvik.system.NativeStart.main(Native Method)
05-09 06:53:04.524: E/AndroidRuntime(435): Caused by: java.lang.ClassNotFoundException: com.example.android.BluetoothChat.BluetoothChat in loader dalvik.system.PathClassLoader[/data/app/com.example.android.BluetoothChat-2.apk]
05-09 06:53:04.524: E/AndroidRuntime(435): at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:240)
05-09 06:53:04.524: E/AndroidRuntime(435): at java.lang.ClassLoader.loadClass(ClassLoader.java:551)
05-09 06:53:04.524: E/AndroidRuntime(435): at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
05-09 06:53:04.524: E/AndroidRuntime(435): at android.app.Instrumentation.newActivity(Instrumentation.java:1021)
05-09 06:53:04.524: E/AndroidRuntime(435): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1561)
05-09 06:53:04.524: E/AndroidRuntime(435): ... 11 more
05-09 06:57:27.854: I/Process(435): Sending signal. PID: 435 SIG: 9
Check your classpath and project.properties file of your Eclipse project, I thought it was not set properly.
Try this way, using information of these files from a normal project that you have created before. Maybe it could help.