Why java.lang.ClassNotFoundException when trying to use mediaplayer? - android

I was trying to run a program with a mediaplayer. Why am I getting this exception?
java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.android.myplayer/com.andr
oid.myplayer.MediaPlayerDemo_video}: java.lang.ClassNotFoundException: com.android.myplayer.MediaPlayerDemo_video in loader dal
vik.system.PathClassLoader#349c48d8
E/AndroidRuntime( 4102): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2417)
E/AndroidRuntime( 4102): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2512)
E/AndroidRuntime( 4102): at android.app.ActivityThread.access$2200(ActivityThread.java:119)
E/AndroidRuntime( 4102): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1863)
E/AndroidRuntime( 4102): at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime( 4102): at android.os.Looper.loop(Looper.java:123)
E/AndroidRuntime( 4102): at android.app.ActivityThread.main(ActivityThread.java:4363)
E/AndroidRuntime( 4102): at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime( 4102): at java.lang.reflect.Method.invoke(Method.java:521)
E/AndroidRuntime( 4102): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
E/AndroidRuntime( 4102): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
E/AndroidRuntime( 4102): at dalvik.system.NativeStart.main(Native Method)
E/AndroidRuntime( 4102): Caused by: java.lang.ClassNotFoundException: com.android.myplayer.MediaPlayerDemo_video in loader dalv
ik.system.PathClassLoader#349c48d8
E/AndroidRuntime( 4102): at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:243)
E/AndroidRuntime( 4102): at java.lang.ClassLoader.loadClass(ClassLoader.java:573)
E/AndroidRuntime( 4102): at java.lang.ClassLoader.loadClass(ClassLoader.java:532)
E/AndroidRuntime( 4102): at android.app.Instrumentation.newActivity(Instrumentation.java:1021)
E/AndroidRuntime( 4102): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2409)
E/AndroidRuntime( 4102): ... 11 more

That exception usually means a CLASSPATH problem: the class loader hasn't been told where to find that class when the JVM needs to load it. So you'll need to figure out which JAR contains that class and add it to the CLASSPATH.

Related

Why no sqlite error codes

Why am I not getting error codes for SQLite failures? I am trying to create a database and getting the following stacktrace (well, the top of the trace):
E/SqliteDatabaseCpp(11974): sqlite3_open_v2
("/mnt/sdcard/myapp/mydatabase.db", &handle, 6, NULL) failed
E/SQLiteDatabase(11974): Failed to open the database. closing it.
E/SQLiteDatabase(11974): android.database.sqlite.SQLiteCantOpenDatabaseException: unable to open database file
E/SQLiteDatabase(11974): at android.database.sqlite.SQLiteDatabase.dbopen(Native Method)
My code works in the emulator, works on a Nexus 7, but fails on another device
public SQLiteDatabase openOrCreateDatabase (String name, int mode,
SQLiteDatabase.CursorFactory factory,
DatabaseErrorHandler errorHandler)
{
File f = getDatabasePath (name);
System.out.println ("opening db: " + f.getPath());
return super.openOrCreateDatabase (f.getPath(), mode, factory, errorHandler);
}
Here's a full log from a second try. It's a little different than the first, but still no error code.
W/dalvikvm( 3314): threadid=1: thread exiting with uncaught exception (group=0x40a801f8)
E/AndroidRuntime( 3314): FATAL EXCEPTION: main
E/AndroidRuntime( 3314): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.myapp.myapp/com.myapp.myapp.main.MainActivity}: android.database.sqlite.SQLiteCantOpenDatabaseException: unable to open database file
E/AndroidRuntime( 3314): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1956)
E/AndroidRuntime( 3314): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
E/AndroidRuntime( 3314): at android.app.ActivityThread.access$600(ActivityThread.java:123)
E/AndroidRuntime( 3314): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
E/AndroidRuntime( 3314): at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime( 3314): at android.os.Looper.loop(Looper.java:137)
E/AndroidRuntime( 3314): at android.app.ActivityThread.main(ActivityThread.java:4424)
E/AndroidRuntime( 3314): at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime( 3314): at java.lang.reflect.Method.invoke(Method.java:511)
E/AndroidRuntime( 3314): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:812)
E/AndroidRuntime( 3314): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:579)
E/AndroidRuntime( 3314): at dalvik.system.NativeStart.main(Native Method)
E/AndroidRuntime( 3314): Caused by: android.database.sqlite.SQLiteCantOpenDatabaseException: unable to open database file
E/AndroidRuntime( 3314): at android.database.sqlite.SQLiteDatabase.dbopen(Native Method)
E/AndroidRuntime( 3314): at android.database.sqlite.SQLiteDatabase.openDatabase(SQLiteDatabase.java:1013)
E/AndroidRuntime( 3314): at android.database.sqlite.SQLiteDatabase.openDatabase(SQLiteDatabase.java:986)
E/AndroidRuntime( 3314): at android.database.sqlite.SQLiteDatabase.openOrCreateDatabase(SQLiteDatabase.java:1051)
E/AndroidRuntime( 3314): at android.app.ContextImpl.openOrCreateDatabase(ContextImpl.java:782)
E/AndroidRuntime( 3314): at android.content.ContextWrapper.openOrCreateDatabase(ContextWrapper.java:221)
E/AndroidRuntime( 3314): at android.content.ContextWrapper.openOrCreateDatabase(ContextWrapper.java:221)
E/AndroidRuntime( 3314): at com.myapp.myapp.dbaccess.DatabaseContext.openOrCreateDatabase(DbHelper.java:63)
E/AndroidRuntime( 3314): at android.database.sqlite.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:157)
E/AndroidRuntime( 3314): at com.myapp.myapp.dbaccess.DbHelper.getDb(DbHelper.java:184)
E/AndroidRuntime( 3314): at com.myapp.myapp.dbaccess.DbHelper.getZRoot(DbHelper.java:650)
E/AndroidRuntime( 3314): at com.myapp.myapp.dbaccess.ZNodeCache.getRequiredNodes(ZNodeCache.java:37)
E/AndroidRuntime( 3314): at com.myapp.myapp.dbaccess.ZNodeCache.<init>(ZNodeCache.java:22)
E/AndroidRuntime( 3314): at com.myapp.myapp.main.MainActivity.onCreate(MainActivity.java:81)
E/AndroidRuntime( 3314): at android.app.Activity.performCreate(Activity.java:4465)
E/AndroidRuntime( 3314): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
E/AndroidRuntime( 3314): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1920)
E/AndroidRuntime( 3314): ... 11 more
Well, this was stupid. If you have your device connected and you select a "USB storage" connection, the sdcard becomes inaccessable. Moral of story: don't enable "USB storage" if your app accesses the sdcard.
Still, Android should emit an error code - I'll file a bug.

App crashed when installed from Market but not if the Apk is installed manually.

My App works fine if I just install it manually by moving the apk onto the phone and installing it, however when I put it on the Market it crashes on the first Activity, this is the logcat.
E/AndroidRuntime( 999): FATAL EXCEPTION: main
E/AndroidRuntime( 999): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.mbwasi.funapp/com.mbwasi.funapp.Splash}: java.lang.ClassNotFoundException: com.mbwasi.funapp.Splash in loader dalvik.system.PathClassLoader[/data/app/com.mbwasi.funapp-1.apk]
E/AndroidRuntime( 999): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
E/AndroidRuntime( 999): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2721)
E/AndroidRuntime( 999): at android.app.ActivityThread.access$2300(ActivityThread.java:132)
E/AndroidRuntime( 999): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2071)
E/AndroidRuntime( 999): at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime( 999): at android.os.Looper.loop(Looper.java:123)
E/AndroidRuntime( 999): at android.app.ActivityThread.main(ActivityThread.java:4669)
E/AndroidRuntime( 999): at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime( 999): at java.lang.reflect.Method.invoke(Method.java:521)
E/AndroidRuntime( 999): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:876)
E/AndroidRuntime( 999): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:634)
E/AndroidRuntime( 999): at dalvik.system.NativeStart.main(Native Method)
E/AndroidRuntime( 999): Caused by: java.lang.ClassNotFoundException: com.mbwasi.funapp.Splash in loader dalvik.system.PathClassLoader[/data/app/com.mbwasi.funapp-1.apk]
E/AndroidRuntime( 999): at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:243)
E/AndroidRuntime( 999): at java.lang.ClassLoader.loadClass(ClassLoader.java:573)
E/AndroidRuntime( 999): at java.lang.ClassLoader.loadClass(ClassLoader.java:532)
E/AndroidRuntime( 999): at android.app.Instrumentation.newActivity(Instrumentation.java:1021)
E/AndroidRuntime( 999): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2619)
E/AndroidRuntime( 999): ... 11 more
What could be happening here? I also notice in the log that the apk name has a -1 at the end too,
com.mbwasi.funapp-1.apk
where would this be coming from?
Is this on the same phone? Are you sure you are uploading the exact same APK? ClassNotFoundException could mean that some class your Splash activity is using is not found, you might be missing some library.
Well I left it overnight, refreshed the market page for my App and now it not only shows as compatible with all my devices but also works when installed. So it was a Market issue. There was a tip in the other thread to unpublish and publish and I did that, no idea if it actually did anything though.

Navit Excepition:java.lang.ExceptionInInitializerError

While running the Navit code for car navigation, I am getting the following exception, i thought that navit library is not available. please any one help me.
E/AndroidRuntime( 365): Uncaught handler: thread main exiting due to uncaught exception
E/AndroidRuntime( 365): java.lang.ExceptionInInitializerError
E/AndroidRuntime( 365): at java.lang.Class.newInstanceImpl(Native Method)
E/AndroidRuntime( 365): at java.lang.Class.newInstance(Class.java:1472)
E/AndroidRuntime( 365): at android.app.Instrumentation.newActivity(Instrumentation.java:1097)
E/AndroidRuntime( 365): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2316)
E/AndroidRuntime( 365): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2417)
E/AndroidRuntime( 365): at android.app.ActivityThread.access$2100(ActivityThread.java:116)
E/AndroidRuntime( 365): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1794)
E/AndroidRuntime( 365): at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime( 365): at android.os.Looper.loop(Looper.java:123)
E/AndroidRuntime( 365): at android.app.ActivityThread.main(ActivityThread.java:4203)
E/AndroidRuntime( 365): at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime( 365): at java.lang.reflect.Method.invoke(Method.java:521)
E/AndroidRuntime( 365): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:791)
E/AndroidRuntime( 365): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:549)
E/AndroidRuntime( 365): at dalvik.system.NativeStart.main(Native Method)
E/AndroidRuntime( 365): Caused by: java.lang.UnsatisfiedLinkError: Library navit not found
E/AndroidRuntime( 365): at java.lang.Runtime.loadLibrary(Runtime.java:489)
E/AndroidRuntime( 365): at java.lang.System.loadLibrary(System.java:557)
i downloaded the Navit code from , navit svn.ttps://navit.svn.sourceforge.net/svnroot/navit/trunk/navit But unable to run the code.
i want to run this code in Eclipse for Android Project.
You need to download Android NDK
Create standalong tools for your ARCH
Cross compile to ARM
Run make apkg
This error is due to missing libnavit.so.
Put libnavit.so it in /data/local
Change System.LoadLibrary to System.Load("/data/local/libnavit.so");
make apkg
Install
This exception should go away.

Android - Extra-weird uncaught exception on a basic activity

I can't figure out what it is going on here...after hours...
This is the activity in question (that I have made super-easy in order to narrow down the problem):
public class UserAuthenticationActivity extends Activity {
/** Called when the activity is first created. */
#Override
public void onCreate(Bundle savedInstanceState) {
Log.e("MYAPP", "step1");
super.onCreate(savedInstanceState);
setContentView(R.layout.user_authentication);
Log.e("MYAPP", "step2");
}
#Override
public void onStart()
{
super.onStart();
}
}
And this is layout/user_authentication:
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_height="fill_parent">
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:scrollbars="vertical"
android:padding="15sp"
>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="hello!"
android:paddingTop="15sp"
android:paddingBottom="5sp"
android:textSize="15sp"
/>
</LinearLayout>
</ScrollView>
I get the error screen when I launch the application. The log doesn't show my debug messages but just this exception:
I/ActivityManager( 1032): Starting activity: Intent { comp={com.myapp.android.app/com.myapp.android.app.activity.UserAuthenticationActivity} }
D/Database( 1990): hook db is called for:/data/data/com.myapp.android.app/databases/myappDatabase.db
D/Database( 1990): hook not enabled for /data/data/com.myapp.android.app/databases/myappDatabase.db
E/QC-DSS-LIB( 981): unrecognized ifindex 6
W/dalvikvm( 1990): threadid=3: thread exiting with uncaught exception (group=0x4000fe70)
E/AndroidRuntime( 1990): Uncaught handler: thread main exiting due to uncaught exception
E/AndroidRuntime( 1990): java.lang.NullPointerException
E/AndroidRuntime( 1990): at android.widget.ListView.measureScrapChild(ListView.java:1039)
E/AndroidRuntime( 1990): at android.widget.ListView.measureHeightOfChildren(ListView.java:1120)
E/AndroidRuntime( 1990): at android.widget.ListView.onMeasure(ListView.java:1031)
E/AndroidRuntime( 1990): at android.view.View.measure(View.java:7236)
E/AndroidRuntime( 1990): at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:2875)
E/AndroidRuntime( 1990): at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:888)
E/AndroidRuntime( 1990): at android.widget.LinearLayout.measureVertical(LinearLayout.java:350)
E/AndroidRuntime( 1990): at android.widget.LinearLayout.onMeasure(LinearLayout.java:278)
E/AndroidRuntime( 1990): at android.view.View.measure(View.java:7236)
E/AndroidRuntime( 1990): at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:2875)
E/AndroidRuntime( 1990): at android.widget.FrameLayout.onMeasure(FrameLayout.java:245)
E/AndroidRuntime( 1990): at android.view.View.measure(View.java:7236)
E/AndroidRuntime( 1990): at android.widget.LinearLayout.measureVertical(LinearLayout.java:464)
E/AndroidRuntime( 1990): at android.widget.LinearLayout.onMeasure(LinearLayout.java:278)
E/AndroidRuntime( 1990): at android.view.View.measure(View.java:7236)
E/AndroidRuntime( 1990): at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:2875)
E/AndroidRuntime( 1990): at android.widget.FrameLayout.onMeasure(FrameLayout.java:245)
E/AndroidRuntime( 1990): at android.view.View.measure(View.java:7236)
E/AndroidRuntime( 1990): at android.view.ViewRoot.performTraversals(ViewRoot.java:698)
E/AndroidRuntime( 1990): at android.view.ViewRoot.handleMessage(ViewRoot.java:1482)
E/AndroidRuntime( 1990): at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime( 1990): at android.os.Looper.loop(Looper.java:123)
E/AndroidRuntime( 1990): at android.app.ActivityThread.main(ActivityThread.java:3948)
E/AndroidRuntime( 1990): at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime( 1990): at java.lang.reflect.Method.invoke(Method.java:521)
E/AndroidRuntime( 1990): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:782)
E/AndroidRuntime( 1990): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:540)
E/AndroidRuntime( 1990): at dalvik.system.NativeStart.main(Native Method)
I hope somebody can help me. I don't have any clue.
Thanks,
Dan
Could it be because there is no contentview?
Further points of interest:
There are several Views in your scrollview, but it can have only one child (use something like a linear layout to put more than 1 in there)
How does your manifest look? What activities are declared there? (or, as #kcoppock said: is this your only activity?)
Why is it throwing stuff from .widget? What are you using in e.g. imports?

Unable to fill List Layout in App

I'm attempting to write my first android app and am having a little
problem with filling a List Layout from a DB.
The project itself is here:
http://code.google.com/p/biofuelsfinder/
However the specific code I'm having the problem with is here:
public void fillData(String fueltype){
ArrayList<String> items = new ArrayList<String>();
Cursor retailers = biofuelsDB.getRetailers("b5");
/*while(!retailers.isAfterLast()){
retailers.moveToNext();
try{
items.add(retailers.getString(retailers.getColumnIndex("name")));
} catch(IllegalStateException e){
String msg = e.getMessage();
}
//items.add(user.lastName);
//items.add(user.country);
}*/
items.add("Blah1");
items.add("Blah2");
items.add("Blah3");
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
R.layout.retailers_row, items);
/*setListAdapter(adapter);*/
}
The two portions commented out, if run cause and illegalStateException
error which then aborts the code.
If anyone could have a look and let me know what I'm going wrong that
would be most appreciated.
Below is the stacktrace
W/dalvikvm( 208): threadid=3: thread exiting with uncaught exception (group=0x4001b188)
E/AndroidRuntime( 208): Uncaught handler: thread main exiting due to uncaught exception
E/AndroidRuntime( 208): java.lang.IllegalStateException: Could not execute method of the activity
E/AndroidRuntime( 208): at android.view.View$1.onClick(View.java:2031)
E/AndroidRuntime( 208): at android.view.View.performClick(View.java:2364)
E/AndroidRuntime( 208): at android.view.View.onTouchEvent(View.java:4179)
E/AndroidRuntime( 208): at android.widget.TextView.onTouchEvent(TextView.java:6532)
E/AndroidRuntime( 208): at android.view.View.dispatchTouchEvent(View.java:3709)
E/AndroidRuntime( 208): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:882)
E/AndroidRuntime( 208): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:882)
E/AndroidRuntime( 208): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:882)
E/AndroidRuntime( 208): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:882)
E/AndroidRuntime( 208): at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:1659)
E/AndroidRuntime( 208): at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1107)
E/AndroidRuntime( 208): at android.app.Activity.dispatchTouchEvent(Activity.java:2061)
E/AndroidRuntime( 208): at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:1643)
E/AndroidRuntime( 208): at android.view.ViewRoot.handleMessage(ViewRoot.java:1690)
E/AndroidRuntime( 208): at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime( 208): at android.os.Looper.loop(Looper.java:123)
E/AndroidRuntime( 208): at android.app.ActivityThread.main(ActivityThread.java:4310)
E/AndroidRuntime( 208): at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime( 208): at java.lang.reflect.Method.invoke(Method.java:521)
E/AndroidRuntime( 208): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
E/AndroidRuntime( 208): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
E/AndroidRuntime( 208): at dalvik.system.NativeStart.main(Native Method)
E/AndroidRuntime( 208): Caused by: java.lang.reflect.InvocationTargetException
E/AndroidRuntime( 208): at com.biofuelsfinder.biofuelsfinder.buttonClickHandler(biofuelsfinder.java:37)
E/AndroidRuntime( 208): at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime( 208): at java.lang.reflect.Method.invoke(Method.java:521)
E/AndroidRuntime( 208): at android.view.View$1.onClick(View.java:2026)
E/AndroidRuntime( 208): ... 21 more
E/AndroidRuntime( 208): Caused by: java.lang.NullPointerException
E/AndroidRuntime( 208): at com.biofuelsfinder.RetailerList.fillData(RetailerList.java:34)
E/AndroidRuntime( 208): ... 25 more
Thanks
I think your 'biofuelsDB' is still null!
Add this line after Arrayadapter:
ListView lv;
lv.setAdapter(items);

Categories

Resources