Unable to fill List Layout in App - android

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);

Related

Using Cider on Android

I am trying to follow this tutorial on lein-droid-based Clojure development on Android. However, the tutorial skips on setting up Cider support.
I start with a default lein-droid project by adding
:user {:plugins [ [lein-droid "0.4.0-alpha4"] ]}
to my ~/.lein/profiles.clj, and then run
$ lein droid new android-hello com.example.android_hello
According to the tutorial, I should be able to do a lein droid doall and then connect with Cider to localhost:9999 at this point; however, it is unusable because of nREPL missing on the Android side:
; CIDER 0.9.1 (Java 0, Clojure 1.7.0-beta3-r2, nREPL nil)
WARNING: CIDER's version (0.9.1) does not match cider-nrepl's version (not installed)
So then, according to this other tutorial that I've found, I should add cider-nrepl to my Android dependencies by adding this to ~/.lein/profiles.clj:
:android-user {:plugins [[cider/cider-nrepl "0.9.1"]]
:android {:aot-exclude-ns ["cider.nrepl.middleware.util.java.parser"
"cider.nrepl" "cider-nrepl.plugin"]}}}
So I do a new lein clean; lein droid doall to make sure everything is picked up nicely; and now the resulting program crashes on Android at startup:
W/dalvikvm( 2508): Exception Ljava/lang/IllegalArgumentException; thrown while initializing Ldeps/cljfmt/v0v1v10/cljfmt/core__init;
W/dalvikvm( 2508): Exception Ljava/lang/ExceptionInInitializerError; thrown while initializing Lcider/nrepl/middleware/format__init;
W/dalvikvm( 2508): threadid=10: thread exiting with uncaught exception (group=0xb5157180)
E/AndroidRuntime( 2508): FATAL EXCEPTION: ClojureLoadingThread
E/AndroidRuntime( 2508): java.lang.ExceptionInInitializerError
E/AndroidRuntime( 2508): at java.lang.Class.classForName(Native Method)
E/AndroidRuntime( 2508): at java.lang.Class.forName(Class.java:217)
E/AndroidRuntime( 2508): at clojure.lang.RT.classForName(RT.java:2201)
E/AndroidRuntime( 2508): at clojure.lang.RT.classForName(RT.java:2210)
E/AndroidRuntime( 2508): at clojure.lang.RT.loadClassForName(RT.java:2229)
E/AndroidRuntime( 2508): at clojure.lang.RT.load(RT.java:461)
E/AndroidRuntime( 2508): at clojure.lang.RT.load(RT.java:437)
E/AndroidRuntime( 2508): at clojure.core$load$fn__5442.invoke(core.clj:5858)
E/AndroidRuntime( 2508): at clojure.core$load.doInvoke(core.clj:5857)
E/AndroidRuntime( 2508): at clojure.lang.RestFn.invoke(RestFn.java:408)
E/AndroidRuntime( 2508): at clojure.core$load_one.invoke(core.clj:5663)
E/AndroidRuntime( 2508): at clojure.core$load_lib$fn__5391.invoke(core.clj:5703)
E/AndroidRuntime( 2508): at clojure.core$load_lib.doInvoke(core.clj:5702)
E/AndroidRuntime( 2508): at clojure.lang.RestFn.applyTo(RestFn.java:142)
E/AndroidRuntime( 2508): at clojure.core$apply.invoke(core.clj:630)
E/AndroidRuntime( 2508): at clojure.core$load_libs.doInvoke(core.clj:5741)
E/AndroidRuntime( 2508): at clojure.lang.RestFn.applyTo(RestFn.java:137)
E/AndroidRuntime( 2508): at clojure.core$apply.invoke(core.clj:630)
E/AndroidRuntime( 2508): at clojure.core$require.doInvoke(core.clj:5824)
E/AndroidRuntime( 2508): at clojure.lang.RestFn.invoke(RestFn.java:408)
E/AndroidRuntime( 2508): at neko.tools.repl$start_repl$fn__6556$fn__6557.invoke(repl.clj:77)
E/AndroidRuntime( 2508): at clojure.core$map$fn__4547.invoke(core.clj:2616)
E/AndroidRuntime( 2508): at clojure.lang.LazySeq.sval(LazySeq.java:40)
E/AndroidRuntime( 2508): at clojure.lang.LazySeq.seq(LazySeq.java:49)
E/AndroidRuntime( 2508): at clojure.lang.RT.seq(RT.java:534)
E/AndroidRuntime( 2508): at clojure.core$seq__4122.invoke(core.clj:135)
E/AndroidRuntime( 2508): at clojure.core$apply.invoke(core.clj:628)
E/AndroidRuntime( 2508): at neko.tools.repl$start_repl$fn__6556.invoke(repl.clj:75)
E/AndroidRuntime( 2508): at clojure.core$with_redefs_fn.invoke(core.clj:7185)
E/AndroidRuntime( 2508): at neko.tools.repl$start_repl.doInvoke(repl.clj:72)
E/AndroidRuntime( 2508): at clojure.lang.RestFn.applyTo(RestFn.java:139)
E/AndroidRuntime( 2508): at clojure.core$apply.invoke(core.clj:630)
E/AndroidRuntime( 2508): at neko.tools.repl$init.doInvoke(repl.clj:102)
E/AndroidRuntime( 2508): at clojure.lang.RestFn.invoke(RestFn.java:397)
E/AndroidRuntime( 2508): at clojure.lang.Var.invoke(Var.java:375)
E/AndroidRuntime( 2508): at neko.App.loadClojure(App.java:40)
E/AndroidRuntime( 2508): at neko.App$1.run(App.java:51)
E/AndroidRuntime( 2508): at java.lang.Thread.run(Thread.java:856)
E/AndroidRuntime( 2508): Caused by: java.lang.ExceptionInInitializerError
E/AndroidRuntime( 2508): at java.lang.Class.classForName(Native Method)
E/AndroidRuntime( 2508): at java.lang.Class.forName(Class.java:217)
E/AndroidRuntime( 2508): at clojure.lang.RT.classForName(RT.java:2201)
E/AndroidRuntime( 2508): at clojure.lang.RT.classForName(RT.java:2210)
E/AndroidRuntime( 2508): at clojure.lang.RT.loadClassForName(RT.java:2229)
E/AndroidRuntime( 2508): at clojure.lang.RT.load(RT.java:461)
E/AndroidRuntime( 2508): at clojure.lang.RT.load(RT.java:437)
E/AndroidRuntime( 2508): at clojure.core$load$fn__5442.invoke(core.clj:5858)
E/AndroidRuntime( 2508): at clojure.core$load.doInvoke(core.clj:5857)
E/AndroidRuntime( 2508): at clojure.lang.RestFn.invoke(RestFn.java:408)
E/AndroidRuntime( 2508): at clojure.core$load_one.invoke(core.clj:5663)
E/AndroidRuntime( 2508): at clojure.core$load_lib$fn__5391.invoke(core.clj:5703)
E/AndroidRuntime( 2508): at clojure.core$load_lib.doInvoke(core.clj:5702)
E/AndroidRuntime( 2508): at clojure.lang.RestFn.applyTo(RestFn.java:142)
E/AndroidRuntime( 2508): at clojure.core$apply.invoke(core.clj:630)
E/AndroidRuntime( 2508): at clojure.core$load_libs.doInvoke(core.clj:5741)
E/AndroidRuntime( 2508): at clojure.lang.RestFn.applyTo(RestFn.java:137)
E/AndroidRuntime( 2508): at clojure.core$apply.invoke(core.clj:630)
E/AndroidRuntime( 2508): at clojure.core$require.doInvoke(core.clj:5824)
E/AndroidRuntime( 2508): at clojure.lang.RestFn.invoke(RestFn.java:703)
E/AndroidRuntime( 2508): at cider.nrepl.middleware.format$loading__5334__auto____6889.invoke(format.clj:1)
E/AndroidRuntime( 2508): at cider.nrepl.middleware.format__init.load(Unknown Source)
E/AndroidRuntime( 2508): at cider.nrepl.middleware.format__init.<clinit>(Unknown Source)
E/AndroidRuntime( 2508): ... 38 more
E/AndroidRuntime( 2508): Caused by: java.lang.IllegalArgumentException: No implementation of method: :make-reader of protocol: #'clojure.java.io/IOFactory found for class: nil
E/AndroidRuntime( 2508): at clojure.core$_cache_protocol_fn.invoke(core_deftype.clj:554)
E/AndroidRuntime( 2508): at clojure.java.io$fn__8970$G__8946__8977.invoke(io.clj:69)
E/AndroidRuntime( 2508): at clojure.java.io$reader.doInvoke(io.clj:102)
E/AndroidRuntime( 2508): at clojure.lang.RestFn.invoke(RestFn.java:410)
E/AndroidRuntime( 2508): at clojure.lang.AFn.applyToHelper(AFn.java:154)
E/AndroidRuntime( 2508): at clojure.lang.RestFn.applyTo(RestFn.java:132)
E/AndroidRuntime( 2508): at clojure.core$apply.invoke(core.clj:630)
E/AndroidRuntime( 2508): at clojure.core$slurp.doInvoke(core.clj:6645)
E/AndroidRuntime( 2508): at clojure.lang.RestFn.invoke(RestFn.java:410)
E/AndroidRuntime( 2508): at clojure.core$comp$fn__4489.invoke(core.clj:2432)
E/AndroidRuntime( 2508): at clojure.core$comp$fn__4489.invoke(core.clj:2432)
E/AndroidRuntime( 2508): at deps.cljfmt.v0v1v10.cljfmt.core__init.load(Unknown Source)
E/AndroidRuntime( 2508): at deps.cljfmt.v0v1v10.cljfmt.core__init.<clinit>(Unknown Source)
E/AndroidRuntime( 2508): ... 61 more
W/ActivityManager( 867): Force finishing activity hu.erdi.gergo.clojure_android_hello.debug/hu.erdi.gergo.clojure_android_hello.SplashActivity
W/WindowManager( 867): Failure taking screenshot for (180x300) to layer 21010
D/dalvikvm( 867): GC_CONCURRENT freed 561K, 13% free 11324K/12871K, paused 0ms+2ms
W/NetworkManagementSocketTagger( 867): setKernelCountSet(10041, 0) failed with errno -2
Seems you made a small mistake when following the tutorial you referenced above.
This:
:android-user {:plugins [[cider/cider-nrepl "0.9.1"]]
:android {:aot-exclude-ns ["cider.nrepl.middleware.util.java.parser"
"cider.nrepl" "cider-nrepl.plugin"]}}}
Should be:
:android-user {:dependencies [[cider/cider-nrepl "0.9.1"]]
:android {:aot-exclude-ns ["cider.nrepl.middleware.util.java.parser"
"cider.nrepl" "cider-nrepl.plugin"]}}

Crash at startup on port to Cordova Crosswalk (Android)

I'm porting an existing android cordova app to cordova crosswalk.
Using cordova 4, crosswalk-cordova-10.39.235.9-x86 and Android SDK 19
The app crashes at startup with the following logs in logcat:
D/AndroidRuntime( 7208): Shutting down VM
W/dalvikvm( 7208): threadid=1: thread exiting with uncaught exception (group=0x41caeda0)
E/AndroidRuntime( 7208): FATAL EXCEPTION: main
E/AndroidRuntime( 7208): Process: myapp.cqa, PID: 7208
E/AndroidRuntime( 7208): java.lang.ExceptionInInitializerError
E/AndroidRuntime( 7208): at org.apache.cordova.CordovaActivity.makeWebView(CordovaActivity.java:295)
E/AndroidRuntime( 7208): at org.apache.cordova.CordovaActivity.init(CordovaActivity.java:348)
E/AndroidRuntime( 7208): at org.apache.cordova.CordovaActivity.init(CordovaActivity.java:323)
E/AndroidRuntime( 7208): at myapp.cqa.CordovaApp.onCreate(CordovaApp.java:31)
E/AndroidRuntime( 7208): at android.app.Activity.performCreate(Activity.java:5451)
E/AndroidRuntime( 7208): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1093)
E/AndroidRuntime( 7208): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2358)
E/AndroidRuntime( 7208): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2452)
E/AndroidRuntime( 7208): at android.app.ActivityThread.access$900(ActivityThread.java:172)
E/AndroidRuntime( 7208): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1302)
E/AndroidRuntime( 7208): at android.os.Handler.dispatchMessage(Handler.java:102)
E/AndroidRuntime( 7208): at android.os.Looper.loop(Looper.java:136)
E/AndroidRuntime( 7208): at android.app.ActivityThread.main(ActivityThread.java:5586)
E/AndroidRuntime( 7208): at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime( 7208): at java.lang.reflect.Method.invoke(Method.java:515)
E/AndroidRuntime( 7208): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1268)
E/AndroidRuntime( 7208): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1084)
E/AndroidRuntime( 7208): at dalvik.system.NativeStart.main(Native Method)
E/AndroidRuntime( 7208): Caused by: java.lang.RuntimeException: java.lang.RuntimeException: Use SharedXWalkView if you want to support shared mode
E/AndroidRuntime( 7208): at org.xwalk.core.ReflectionHelper.handleException(ReflectionHelper.java:233)
E/AndroidRuntime( 7208): at org.xwalk.core.ReflectionHelper.handleException(ReflectionHelper.java:237)
E/AndroidRuntime( 7208): at org.xwalk.core.ReflectionHelper.init(ReflectionHelper.java:132)
E/AndroidRuntime( 7208): at org.xwalk.core.ReflectionHelper.loadClass(ReflectionHelper.java:199)
E/AndroidRuntime( 7208): at org.xwalk.core.XWalkPreferences.setValue(XWalkPreferences.java:112)
E/AndroidRuntime( 7208): at org.apache.cordova.CordovaWebView.<clinit>(CordovaWebView.java:890)
E/AndroidRuntime( 7208): ... 18 more
E/AndroidRuntime( 7208): Caused by: java.lang.RuntimeException: Use SharedXWalkView if you want to support shared mode
E/AndroidRuntime( 7208): ... 23 more
Any idea why it crashes ?
OK, after a night of sleeping, I realized I was using x86 crosswalk instead of the ARM one. Sorry for the dumb issue post...

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.

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

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.

VerifyError When Running jUnit Test on Android 1.6

Here's what I'm trying to run on Android 1.6:
package com.healthlogger.test;
public class AllTests extends TestSuite
{
public static Test suite()
{
return new TestSuiteBuilder(AllTests.class).includeAllPackagesUnderHere().build();
}
}
and:
package com.healthlogger.test;
public class RecordTest extends AndroidTestCase
{
/**
* Ensures that the constructor will not take a null data tag.
*/
#Test(expected=AssertionFailedError.class)
public void testNullDataTagInConstructor()
{
Record r = new Record(null, Calendar.getInstance(), "Data");
fail("Failed to catch null data tag.");
}
}
The main project is HealthLogger. These are run from a separate test project (HealthLoggerTest). HealthLogger and jUnit4 are in HealthLoggerTest's build path. jUnit4 is also in HealthLogger's build path. The class "Record" is located in com.healthlogger.
Commenting out the "#Test..." and "Record r..." lines allows this test to run. When they are uncommented, I get a VerifyError exception. I am severely blocked by this; why is it happening?
EDIT: some info from logcat after the crash:
E/AndroidRuntime( 3723): Uncaught handler: thread main exiting due to uncaught exception
E/AndroidRuntime( 3723): java.lang.VerifyError: com.healthlogger.test.RecordTest E/AndroidRuntime( 3723): at java.lang.Class.getDeclaredConstructors(Native Method)
E/AndroidRuntime( 3723): at java.lang.Class.getConstructors(Class.java:507) E/AndroidRuntime( 3723): at android.test.suitebuilder.TestGrouping$TestCasePredicate.hasValidConstructor(TestGrouping.java:226)
E/AndroidRuntime( 3723): at android.test.suitebuilder.TestGrouping$TestCasePredicate.apply(TestGrouping.java:215)
E/AndroidRuntime( 3723): at android.test.suitebuilder.TestGrouping$TestCasePredicate.apply(TestGrouping.java:211)
E/AndroidRuntime( 3723): at android.test.suitebuilder.TestGrouping.select(TestGrouping.java:170) E/AndroidRuntime( 3723): at android.test.suitebuilder.TestGrouping.selectTestClasses(TestGrouping.java:160)
E/AndroidRuntime( 3723): at android.test.suitebuilder.TestGrouping.testCaseClassesInPackage(TestGrouping.java:154)
E/AndroidRuntime( 3723): at android.test.suitebuilder.TestGrouping.addPackagesRecursive(TestGrouping.java:115)
E/AndroidRuntime( 3723): at android.test.suitebuilder.TestSuiteBuilder.includePackages(TestSuiteBuilder.java:103)
E/AndroidRuntime( 3723): at android.test.InstrumentationTestRunner.onCreate(InstrumentationTestRunner.java:321)
E/AndroidRuntime( 3723): at android.app.ActivityThread.handleBindApplication(ActivityThread.java:3848)
E/AndroidRuntime( 3723): at android.app.ActivityThread.access$2800(ActivityThread.java:116) E/AndroidRuntime( 3723): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1831)
E/AndroidRuntime( 3723): at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime( 3723): at android.os.Looper.loop(Looper.java:123) E/AndroidRuntime( 3723): at android.app.ActivityThread.main(ActivityThread.java:4203)
E/AndroidRuntime( 3723): at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime( 3723): at java.lang.reflect.Method.invoke(Method.java:521)
E/AndroidRuntime( 3723): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:791)
E/AndroidRuntime( 3723): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:549) E/AndroidRuntime( 3723): at dalvik.system.NativeStart.main(Native Method)
This can occur when you forget to export all dependencies for a test project.
In Eclipse, go to the Java Build Path properties for your projects (both the main project and the test project). Go to the Organize/Export tab and make sure you check all dependencies (select all, except for any JRE or Classpath Container that might be listed).

Categories

Resources