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.
Related
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.
This is my .java code
public class MainHelp extends PreferenceActivity {
#Override
public void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.help_main);
}
}
and this is the layout
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" >
<Preference
android:title="Commands Documentation"
android:key="#string/commands"/>
<Preference
android:title = "How To Use"
android:key="#string/howToUse"/>
<Preference
android:title="Write Us"
android:key="#string/writeUs"/>
<Preference
android:title="About"
android:key="#string/aboutSuppApp"/>
</PreferenceScreen>
When I run the program the above code works perfectly....But, when i hit home button and try to go to this Activity, I get error saying
E/AndroidRuntime( 495): Uncaught handler: thread main exiting due to uncaught exception
E/AndroidRuntime( 495): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.suppapp/com.suppapp.help.MainHelp}: android.view.InflateException: Binary XML file line #10: Error inflating class prferences
E/AndroidRuntime( 495): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2496)
E/AndroidRuntime( 495): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2512)
E/AndroidRuntime( 495): at android.app.ActivityThread.access$2200(ActivityThread.java:119)
E/AndroidRuntime( 495): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1863)
E/AndroidRuntime( 495): at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime( 495): at android.os.Looper.loop(Looper.java:123)
E/AndroidRuntime( 495): at android.app.ActivityThread.main(ActivityThread.java:4363)
E/AndroidRuntime( 495): at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime( 495): at java.lang.reflect.Method.invoke(Method.java:521)
E/AndroidRuntime( 495): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
E/AndroidRuntime( 495): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
E/AndroidRuntime( 495): at dalvik.system.NativeStart.main(Native Method)
E/AndroidRuntime( 495): Caused by: android.view.InflateException: Binary XML file line #10: Error inflating class prferences
E/AndroidRuntime( 495): at android.preference.GenericInflater.createItemFromTag(GenericInflater.java:441)
E/AndroidRuntime( 495): at android.preference.GenericInflater.rInflate(GenericInflater.java:481)
E/AndroidRuntime( 495): at android.preference.GenericInflater.inflate(GenericInflater.java:326)
E/AndroidRuntime( 495): at android.preference.GenericInflater.inflate(GenericInflater.java:263)
E/AndroidRuntime( 495): at android.preference.PreferenceManager.inflateFromResource(PreferenceManager.java:254)
E/AndroidRuntime( 495): at android.preference.PreferenceActivity.addPreferencesFromResource(PreferenceActivity.java:253)
E/AndroidRuntime( 495): at com.suppapp.help.MainHelp.onCreate(MainHelp.java:19)
E/AndroidRuntime( 495): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
E/AndroidRuntime( 495): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2459)
E/AndroidRuntime( 495): ... 11 more
E/AndroidRuntime( 495): Caused by: java.lang.ClassNotFoundException: android.preference.prferences in loader dalvik.system.PathClassLoader#44c06600
E/AndroidRuntime( 495): at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:243)
E/AndroidRuntime( 495): at java.lang.ClassLoader.loadClass(ClassLoader.java:573)
E/AndroidRuntime( 495): at java.lang.ClassLoader.loadClass(ClassLoader.java:532)
E/AndroidRuntime( 495): at android.preference.GenericInflater.createItem(GenericInflater.java:375)
E/AndroidRuntime( 495): at android.preference.GenericInflater.onCreateItem(GenericInflater.java:417)
E/AndroidRuntime( 495): at android.preference.GenericInflater.createItemFromTag(GenericInflater.java:428)
E/AndroidRuntime( 495): ... 19 more
I tried to link my activity with the other .xml file but getting the same error again!! Even Caused by: android.view.InflateException: Binary XML file line #10: Error inflating class prferences shows the same line number(#10) for other .xml files
i changed the version code(inside manifest file) and re-installed the app...its working fine now.
I assume that you can open images from your resources folder with Intent.ACTION_VIEW?
If not then let me know, and don't bother reading on! haha
If you can then I have this code:
Intent mainIntent = new Intent(Intent.ACTION_VIEW);
Uri uri = Uri.parse("android.resource://com.tclayson.myapp/"+extrasImgs.mImagesIds[position]);
mainIntent.setDataAndType(uri, "image/jpg");
startActivity(mainIntent);
And yet it is giving me this error:
E/AndroidRuntime( 309): FATAL EXCEPTION: main
E/AndroidRuntime( 309): android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.VIEW dat=android.resource://com.tclayson.myapp/2130837611 }
E/AndroidRuntime( 309): at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1512)
E/AndroidRuntime( 309): at android.app.Instrumentation.execStartActivity(Instrumentation.java:1384)
E/AndroidRuntime( 309): at android.app.Activity.startActivityForResult(Activity.java:3190)
E/AndroidRuntime( 309): at android.app.Activity.startActivity(Activity.java:3297)
E/AndroidRuntime( 309): at com.tclayson.myapp.FBRadioPlayer$SlidingContentPagerAdapter$5.onItemClick(TheActivity.java:226)
E/AndroidRuntime( 309): at android.widget.AdapterView.performItemClick(AdapterView.java:292)
E/AndroidRuntime( 309): at android.widget.AbsListView.performItemClick(AbsListView.java:1058)
E/AndroidRuntime( 309): at android.widget.AbsListView$PerformClick.run(AbsListView.java:2514)
E/AndroidRuntime( 309): at android.widget.AbsListView$1.run(AbsListView.java:3168)
E/AndroidRuntime( 309): at android.os.Handler.handleCallback(Handler.java:605)
E/AndroidRuntime( 309): at android.os.Handler.dispatchMessage(Handler.java:92)
E/AndroidRuntime( 309): at android.os.Looper.loop(Looper.java:137)
E/AndroidRuntime( 309): at android.app.ActivityThread.main(ActivityThread.java:4424)
E/AndroidRuntime( 309): at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime( 309): at java.lang.reflect.Method.invoke(Method.java:511)
E/AndroidRuntime( 309): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
E/AndroidRuntime( 309): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
E/AndroidRuntime( 309): at dalvik.system.NativeStart.main(Native Method)
W/ActivityManager( 152): Force finishing activity com.tclayson.myapp/.MyActivity
I have no idea what could be wrong with this! Any help would be brilliant.
Thanks
What means the scheme 'android.resource' ? I have never seen before. Your error message means no Application is found that can handle your URI scheme.
I couldn't find the answer to this. So I created my own image viewer in the app.
You should add http:// at the beginning of the URL. ie. use
Uri uri = Uri.parse("http://android.resource://com.tclayson.myapp/"+extrasImgs.mImagesIds[position]);
instead of
Uri uri = Uri.parse("android.resource://com.tclayson.myapp/"+extrasImgs.mImagesIds[position]);
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.
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.