bluetoothchat application showing errors - android

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.

Related

Caused by: java.lang.UnsatisfiedLinkError: Cannot load library: load_library[1098]: Library '/system/lib/libhoudini.so' not found

I updated Android Studio to 3.0.0 and Gradle to 3.0.0
After run my app on emulator Genymotion (API 16-19) crashed.
Error:
E/AndroidRuntime: FATAL EXCEPTION: main
java.lang.ExceptionInInitializerError
at android.support.v4.app.SupportActivity.<init>(SupportActivity.java:68)
at android.support.v4.app.BaseFragmentActivityGingerbread.<init>(BaseFragmentActivityGingerbread.java:37)
at android.support.v4.app.BaseFragmentActivityHoneycomb.<init>(BaseFragmentActivityHoneycomb.java:29)
at android.support.v4.app.BaseFragmentActivityJB.<init>(BaseFragmentActivityJB.java:30)
at android.support.v4.app.FragmentActivity.<init>(FragmentActivity.java:79)
at android.support.v7.app.AppCompatActivity.<init>(AppCompatActivity.java:61)
at com.myapp.start.BaseActivity.<init>(BaseActivity.java:37)
at com.myapp.start.StartActivity.<init>(StartActivity.java:40)
at java.lang.Class.newInstanceImpl(Native Method)
at java.lang.Class.newInstance(Class.java:1319)
at android.app.Instrumentation.newActivity(Instrumentation.java:1053)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1974)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
at android.app.ActivityThread.access$600(ActivityThread.java:130)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4745)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.UnsatisfiedLinkError: Cannot load library: load_library[1098]: Library '/system/lib/libhoudini.so' not found
Native methods in my app not using. What could be the problem?
Check your advanced profiling Run-->Edit Configurations.. --> Profiling Tab
--> Uncheck (Enable advanced profiling)

google app invites(beta) not working in android 2.3.6

Google App Invites(Beta) is not working in android 2.3.6 devices.
I tried out in a 4 devices of different versions & it failed only in 2.3.6.
Kindly point me to resources to resolve this error!
Below is the stacktrace
06-16 08:49:13.939 6396-6396/? E/AndroidRuntime﹕ FATAL EXCEPTION: main
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.google.android.gms/com.google.android.gms.appinvite.AppInviteActivity}: java.lang.NullPointerException
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1651)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1667)
at android.app.ActivityThread.access$1500(ActivityThread.java:117)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:935)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:130)
at android.app.ActivityThread.main(ActivityThread.java:3687)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:867)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:625)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.NullPointerException
at com.google.android.gms.appinvite.ui.widget.g.<init>(SourceFile:167)
at com.google.android.gms.appinvite.ui.widget.s.b(SourceFile:80)
at com.google.android.gms.appinvite.ui.widget.d.a(SourceFile:76)
at com.google.android.gms.appinvite.ui.context.h.a(SourceFile:409)
at android.support.v4.app.Fragment.b(SourceFile:1786)
at android.support.v4.app.s.a(SourceFile:953)
at android.support.v4.app.s.a(SourceFile:1136)
at android.support.v4.app.a.run(SourceFile:739)
at android.support.v4.app.s.h(SourceFile:1499)
at android.support.v4.app.l.onStart(SourceFile:548)
at com.google.android.gms.appinvite.AppInviteActivity.onStart(SourceFile:270)

No Activity found to handle intent error

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?

Android app stops unexpectedly

I wrote a program for android which connects to internet.
I got the following error:
The application has stopped unexpectedly.Please try again..
What's the problem?
Log cat in Eclipse is as follows:
09-02 12:43:42.421: W/dalvikvm(12362): threadid=1: thread exiting with uncaught exception (group=0x40018578)
09-02 12:43:42.437: E/AndroidRuntime(12362): FATAL EXCEPTION: main
09-02 12:43:42.437: E/AndroidRuntime(12362): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.example.android.networkusage/com.example.networkusage.NetworkActivity}: java.lang.ClassNotFoundException: com.example.networkusage.NetworkActivity in loader dalvik.system.PathClassLoader[/data/app/com.example.android.networkusage-1.apk]
09-02 12:43:42.437: E/AndroidRuntime(12362): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1573)
09-02 12:43:42.437: E/AndroidRuntime(12362): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1667)
09-02 12:43:42.437: E/AndroidRuntime(12362): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
09-02 12:43:42.437: E/AndroidRuntime(12362): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:935)
09-02 12:43:42.437: E/AndroidRuntime(12362): at android.os.Handler.dispatchMessage(Handler.java:99)
09-02 12:43:42.437: E/AndroidRuntime(12362): at android.os.Looper.loop(Looper.java:130)
09-02 12:43:42.437: E/AndroidRuntime(12362): at android.app.ActivityThread.main(ActivityThread.java:3687)
09-02 12:43:42.437: E/AndroidRuntime(12362): at java.lang.reflect.Method.invokeNative(Native Method)
09-02 12:43:42.437: E/AndroidRuntime(12362): at java.lang.reflect.Method.invoke(Method.java:507)
09-02 12:43:42.437: E/AndroidRuntime(12362): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:867)
09-02 12:43:42.437: E/AndroidRuntime(12362): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:625)
09-02 12:43:42.437: E/AndroidRuntime(12362): at dalvik.system.NativeStart.main(Native Method)
09-02 12:43:42.437: E/AndroidRuntime(12362): Caused by: java.lang.ClassNotFoundException: com.example.networkusage.NetworkActivity in loader dalvik.system.PathClassLoader[/data/app/com.example.android.networkusage-1.apk]
09-02 12:43:42.437: E/AndroidRuntime(12362): at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:240)
09-02 12:43:42.437: E/AndroidRuntime(12362): at java.lang.ClassLoader.loadClass(ClassLoader.java:551)
09-02 12:43:42.437: E/AndroidRuntime(12362): at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
09-02 12:43:42.437: E/AndroidRuntime(12362): at android.app.Instrumentation.newActivity(Instrumentation.java:1021)
09-02 12:43:42.437: E/AndroidRuntime(12362): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1565)
09-02 12:43:42.437: E/AndroidRuntime(12362): ... 11 more
Found that my package name is:
com.example.android.networkusage
and on the manifest is as:
android:name="com.example.networkusage.NetworkActivity"
so changed the manifest to:
android:name="com.example.android.networkusage.NetworkActivity"
Looks like your com.example.networkusage.NetworkActivity class is missing.
If it is declared in an external library, add that jar file to the "libs" folder and add it to the build path and then build your project again.
Don't forget to clean it too!

Unable to create media player, short Android app

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.

Categories

Resources