Amazon java.lang.VerifyError Android - android

I have been trying to submit 2 separate apps into the Amazon App store but they keep being rejected. Here is the stack trace for the first:
11-05 11:14:36.488 E/AndroidRuntime(28128): FATAL EXCEPTION: AsyncTask #1
11-05 11:14:36.488 E/AndroidRuntime(28128): java.lang.RuntimeException: An error occured while executing doInBackground()
11-05 11:14:36.488 E/AndroidRuntime(28128): at android.os.AsyncTask$3.done(AsyncTask.java:200)
11-05 11:14:36.488 E/AndroidRuntime(28128): at java.util.concurrent.FutureTask$Sync.innerSetException(FutureTask.java:273)
11-05 11:14:36.488 E/AndroidRuntime(28128): at java.util.concurrent.FutureTask.setException(FutureTask.java:124)
11-05 11:14:36.488 E/AndroidRuntime(28128): at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:307)
11-05 11:14:36.488 E/AndroidRuntime(28128): at java.util.concurrent.FutureTask.run(FutureTask.java:137)
11-05 11:14:36.488 E/AndroidRuntime(28128): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1068)
11-05 11:14:36.488 E/AndroidRuntime(28128): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:561)
11-05 11:14:36.488 E/AndroidRuntime(28128): at java.lang.Thread.run(Thread.java:1096)
11-05 11:14:36.488 E/AndroidRuntime(28128): Caused by: java.lang.VerifyError: com.companionfree.WLThemeViewer.AmazonClientManager
11-05 11:14:36.488 E/AndroidRuntime(28128): at com.companionfree.WLThemeViewer.UpdateDBs.doInBackground(UpdateDBs.java)
11-05 11:14:36.488 E/AndroidRuntime(28128): at com.companionfree.WLThemeViewer.UpdateDBs.doInBackground(UpdateDBs.java)
11-05 11:14:36.488 E/AndroidRuntime(28128): at android.os.AsyncTask$2.call(AsyncTask.java:185)
11-05 11:14:36.488 E/AndroidRuntime(28128): at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
11-05 11:14:36.488 E/AndroidRuntime(28128): ... 4 more
And the relevant logcat for the second
10-12 15:41:48.929 D/dalvikvm( 2451): GC_FOR_MALLOC freed 8099 objects / 524416 bytes in 34ms
10-12 15:41:49.327 I/RPC ( 1563): rx thread timeout (1 clients):
10-12 15:41:49.828 I/RPC ( 1563): rx thread timeout (1 clients):
10-12 15:41:50.089 I/ActivityManager( 1563): Starting activity: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=com.companionfree.pushup/.MainScreen }
10-12 15:41:50.099 D/SurfaceFlinger( 1563): Layer::setBuffers(this=0xeafa50), pid=1563, w=1, h=1
10-12 15:41:50.099 D/SurfaceFlinger( 1563): Layer::setBuffers(this=0xeafa50), pid=1563, w=1, h=1
10-12 15:41:50.139 D/SurfaceFlinger( 1563): Layer::requestBuffer(this=0xeafa50), index=0, pid=1563, w=480, h=800 success
10-12 15:41:50.189 I/ActivityManager( 1563): Start proc com.companionfree.pushup for activity com.companionfree.pushup/.MainScreen: pid=2644 uid=10129 gids={1015, 3003}
10-12 15:41:50.319 I/RPC ( 1563): rx thread timeout (1 clients):
10-12 15:41:50.359 W/dalvikvm( 2644): VFY: Lcom/companionfree/pushup/WorkoutDbAdapter; is not instance of Landroid/app/Activity;
10-12 15:41:50.369 W/dalvikvm( 2644): VFY: bad arg 0 (into Landroid/app/Activity;)
10-12 15:41:50.369 W/dalvikvm( 2644): VFY: rejecting call to Lcom/amazon/android/Kiwi;.onActivityResult (Landroid/app/Activity;IILandroid/content/Intent;)Z
10-12 15:41:50.369 W/dalvikvm( 2644): VFY: rejecting opcode 0x71 at 0x0000
10-12 15:41:50.369 W/dalvikvm( 2644): VFY: rejected Lcom/companionfree/pushup/WorkoutDbAdapter;.onActivityResult (IILandroid/content/Intent;)V
10-12 15:41:50.369 W/dalvikvm( 2644): Verifier rejected class Lcom/companionfree/pushup/WorkoutDbAdapter;
10-12 15:41:50.369 D/AndroidRuntime( 2644): Shutting down VM
10-12 15:41:50.369 W/dalvikvm( 2644): threadid=1: thread exiting with uncaught exception (group=0x40025a70)
10-12 15:41:50.369 E/AndroidRuntime( 2644): FATAL EXCEPTION: main
10-12 15:41:50.369 E/AndroidRuntime( 2644): java.lang.VerifyError: com.companionfree.pushup.WorkoutDbAdapter
10-12 15:41:50.369 E/AndroidRuntime( 2644): at com.companionfree.pushup.MainScreen.onCreateMainScreen(MainScreen.java)
10-12 15:41:50.369 E/AndroidRuntime( 2644): at com.companionfree.pushup.MainScreen.onCreate(MainScreen.java)
10-12 15:41:50.369 E/AndroidRuntime( 2644): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1088)
10-12 15:41:50.369 E/AndroidRuntime( 2644): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2802)
10-12 15:41:50.369 E/AndroidRuntime( 2644): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2859)
10-12 15:41:50.369 E/AndroidRuntime( 2644): at android.app.ActivityThread.access$2300(ActivityThread.java:136)
10-12 15:41:50.369 E/AndroidRuntime( 2644): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2179)
10-12 15:41:50.369 E/AndroidRuntime( 2644): at android.os.Handler.dispatchMessage(Handler.java:99)
10-12 15:41:50.369 E/AndroidRuntime( 2644): at android.os.Looper.loop(Looper.java:143)
10-12 15:41:50.369 E/AndroidRuntime( 2644): at android.app.ActivityThread.main(ActivityThread.java:5073)
10-12 15:41:50.369 E/AndroidRuntime( 2644): at java.lang.reflect.Method.invokeNative(Native Method)
10-12 15:41:50.369 E/AndroidRuntime( 2644): at java.lang.reflect.Method.invoke(Method.java:521)
10-12 15:41:50.369 E/AndroidRuntime( 2644): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:858)
10-12 15:41:50.369 E/AndroidRuntime( 2644): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
10-12 15:41:50.369 E/AndroidRuntime( 2644): at dalvik.system.NativeStart.main(Native Method)
10-12 15:41:50.379 W/ActivityManager( 1563): Force finishing activity com.companionfree.pushup/.MainScreen
10-12 15:41:50.399 D/SurfaceFlinger( 1563): Layer::setBuffers(this=0xeff6b8), pid=1563, w=1, h=1
10-12 15:41:50.399 D/SurfaceFlinger( 1563): Layer::setBuffers(this=0xeff6b8), pid=1563, w=1, h=1
10-12 15:41:50.419 D/SurfaceFlinger( 1563): Layer::requestBuffer(this=0xeff6b8), index=0, pid=1563, w=480, h=337 success
10-12 15:41:50.469 D/dalvikvm( 2451): GC_FOR_MALLOC freed 7889 objects / 521072 bytes in 105ms
10-12 15:41:50.819 I/RPC ( 1563): rx thread timeout (1 clients):
I see the same verify error on both but I can't figure it out. The only common library used between the 2 apps is the FlurryAgent.jar for analytics.
For the top app I have
For the bottom app I have
in the manifests. The only information I have been able to find out is about libraries (GSON) and needing to use dx but I am using Eclipse so that doesn't help.
To make this more difficult, the error does NOT occur on the Android Market. Yet the testers at Amazon say that it FC 5/5 times on each of their devices (I tried using an emulator for their test devices and they worked fine). I know they use "wrapper" code around my app and I think it must be interfering in some way.
Does anyone have any experience with this?

I had a similar problem - resolved it by removing the non activity class from AndroidManifest.xml
Amazon injects their own code into your apps Activities life-cycle events. Knowing that and looking at the log you've provided:
10-12 15:41:50.359 W/dalvikvm( 2644): VFY: Lcom/companionfree/pushup/WorkoutDbAdapter; is not instance of Landroid/app/Activity;
It appears that Amazon's code tried to instrument a class (WorkoutDbAdapter) which is NOT an Activity (doesn't extends Activity), ending up being rejected by the JVM's verifier.
With my app this happened since the class was listed was listed an an Activity on AndroidManifest.xml. Removing this listing from AndroidManifest.xml resolved the issue and the app was admitted to the market.
Sarp wrote that renaming your class' packaged solved the issue, perhaps by doing so you've made your listing on AndroidManifest.xml no longer relevant. Thereby circumventing the problem.

I'd say this is the problem of the Amazon. Apparently they are injecting some DRM code into your apk: Injecting code into APK
Other people are seeing similar errors - Android app issue (Amazon)

In my case, the class that was causing a VerifyError was in a package called util. It was probably clashing with an injected package by Amazon, because renaming it to utils solved the problem.
Because our app was using Facebook SDK, it was given a "No, I will sign my binary" option when uploading a new binary. When you upload an unsigned APK this way, Amazon will let you download the processed binary (that includes their injected code) as Step 2 so that you can sign it. I was able to download a copy of my APK that crashes, and test my changes without going through the approval process this way.

I just solved my problem and may help to you
I just update the AS to 2.0 and ADT, and the verify issue come out
finally, be careful with the constructor like:
class abc {
abc(int x) {
....
}
abc(byte x) {
....
}
}

Related

Error in running Android's TouchPaint example program

I am just trying out the "TouchPaint" sample provided by Google Android examples at:
http://developer.android.com/resources/samples/ApiDemos/src/com/example/android/apis/graphics/TouchPaint.html
Created my own AndroidManifest.xml, and I figured that "GraphicsActivity.java" and "PictureLayout.java" are two other java files before I could compiled and create the apk successfully.
After I load into my Android phone, it displayed a blank screen. At this point nothing happened yet, but once I touch the screen, the apps died, and generated the following trace in logcat output:
D/dalvikvm( 4939): GC_CONCURRENT freed 44K, 49% free 2779K/5379K, external 3286K/4104K, paused 4ms+2ms
D/dalvikvm( 365): GC_CONCURRENT freed 1102K, 54% free 3271K/7047K, external 2612K/3262K, paused 4ms+4ms
I/ActivityManager( 266): Displayed com.example.android.apis.graphics/.TouchPaint: +382ms
D/AndroidRuntime( 4939): Shutting down VM
W/dalvikvm( 4939): threadid=1: thread exiting with uncaught exception (group=0x2aac8578)
E/AndroidRuntime( 4939): FATAL EXCEPTION: main
E/AndroidRuntime( 4939): java.lang.NoSuchMethodError: android.view.MotionEvent.getButtonState
E/AndroidRuntime( 4939): at com.example.android.apis.graphics.TouchPaint$PaintView.onTouchOrHoverEvent(TouchPaint.java:346)
E/AndroidRuntime( 4939): at com.example.android.apis.graphics.TouchPaint$PaintView.onTouchEvent(TouchPaint.java:337)
E/AndroidRuntime( 4939): at android.view.View.dispatchTouchEvent(View.java:3952)
E/AndroidRuntime( 4939): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:961)
E/AndroidRuntime( 4939): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:961)
E/AndroidRuntime( 4939): at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:1711)
E/AndroidRuntime( 4939): at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1145)
E/AndroidRuntime( 4939): at android.app.Activity.dispatchTouchEvent(Activity.java:2096)
E/AndroidRuntime( 4939): at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:1695)
E/AndroidRuntime( 4939): at android.view.ViewRoot.deliverPointerEvent(ViewRoot.java:2217)
E/AndroidRuntime( 4939): at android.view.ViewRoot.handleMessage(ViewRoot.java:1901)
E/AndroidRuntime( 4939): at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime( 4939): at android.os.Looper.loop(Looper.java:130)
E/AndroidRuntime( 4939): at android.app.ActivityThread.main(ActivityThread.java:3701)
E/AndroidRuntime( 4939): at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime( 4939): at java.lang.reflect.Method.invoke(Method.java:507)
E/AndroidRuntime( 4939): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:866)
E/AndroidRuntime( 4939): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:624)
E/AndroidRuntime( 4939): at dalvik.system.NativeStart.main(Native Method)
W/ActivityManager( 266): Force finishing activity com.example.android.apis.graphics/.TouchPaint
W/ActivityManager( 266): Activity pause timeout for HistoryRecord{2afed900 com.example.android.apis.graphics/.TouchPaint}
I/InputDispatcher( 266): Application is not responding: Window{2b3f4d00 com.example.android.apis.graphics/com.example.android.apis.graphics.TouchPaint paused=false}. 5002.0ms since event, 5001.8ms since wait started
I/InputDispatcher( 266): Dropping event because the pointer is not down.
I/WindowManager( 266): Input event dispatching timed out sending to com.example.android.apis.graphics/com.example.android.apis.graphics.TouchPaint
W/ActivityManager( 266): Activity destroy timeout for HistoryRecord{2afed900 com.example.android.apis.graphics/.TouchPaint}
D/lights ( 266): set_light_backlight: brightness=20
I/ActivityManager( 266): No longer want com.facebook.katana (pid 4319): hidden #16
W/ActivityManager( 266): Scheduling restart of crashed service com.facebook.katana/.service.UploadManager in 5000ms
I am puzzled over what is the possible cause of crashing?
This method is only available since API Level 14, set minSdkVersion to 14 in the Manifest
public final int getButtonState ()
Since: API Level 14
Gets the state of all buttons that are pressed such as a mouse or stylus button.
Returns
The button state.
I found the answer:
http://developer.android.com/resources/dashboard/platform-versions.html
http://developer.android.com/guide/appendix/api-levels.html
From the web page's table, since I know my phone is using Android 2.3.4, so that max target API for SDK should be 10. So instead of using the TouchPaint.java sample from android-14, I copied the TouchPaint.java from android-10,change the minSDK version to 10 inside my AndroidManifest.xml file:
<uses-sdk android:minSdkVersion="10"/>
Everything works!! Thanks to Rajdeep Dua too!!!

table not getting created

I have written for tables creation but when i am trying to access the table from one of my screen its throwing exception .
Even when i went do shell in commannd prompt i was not able to find that table . Any clue that i need to do .
logs :
W/System.err( 275): at java.lang.Thread.run(Thread.java:1096)
I/Database( 275): sqlite returned: error code = 1, msg = no such table: woman_registration
D/AndroidRuntime( 275): Shutting down VM
W/dalvikvm( 275): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
E/AndroidRuntime( 275): FATAL EXCEPTION: main
E/AndroidRuntime( 275): android.database.sqlite.SQLiteException: no such table: woman_registration: , while compiling: SELECT DISTINCT
* FROM woman_registration WHERE (m_name = ? AND f_name = ? and m_age_range = ?)
E/AndroidRuntime( 275): at android.database.sqlite.SQLiteCompiledSql.native_compile(Native Method)
E/AndroidRuntime( 275): at android.database.sqlite.SQLiteCompiledSql.compile(SQLiteCompiledSql.java:91)
E/AndroidRuntime( 275): at android.database.sqlite.SQLiteCompiledSql.<init>(SQLiteCompiledSql.java:64)
E/AndroidRuntime( 275): at android.database.sqlite.SQLiteProgram.<init>(SQLiteProgram.java:80)
E/AndroidRuntime( 275): at android.database.sqlite.SQLiteQuery.<init>(SQLiteQuery.java:46)
E/AndroidRuntime( 275): at android.database.sqlite.SQLiteDirectCursorDriver.query(SQLiteDirectCursorDriver.java:42)
E/AndroidRuntime( 275): at android.database.sqlite.SQLiteDatabase.rawQueryWithFactory(SQLiteDatabase.java:1345)
E/AndroidRuntime( 275): at android.database.sqlite.SQLiteDatabase.queryWithFactory(SQLiteDatabase.java:1229)
E/AndroidRuntime( 275): at android.database.sqlite.SQLiteDatabase.query(SQLiteDatabase.java:1184)
E/AndroidRuntime( 275): at org.atl.db.DBAdapter.isWomanAlreadyRegisgtered(DBAdapter.java:376)
E/AndroidRuntime( 275): at com.accenturelabs.idoc.RegisterWoman.registerMother(RegisterWoman.java:237)
E/AndroidRuntime( 275): at com.accenturelabs.idoc.RegisterWoman.access$1(RegisterWoman.java:223)
E/AndroidRuntime( 275): at com.accenturelabs.idoc.RegisterWoman$4.onClick(RegisterWoman.java:141)
E/AndroidRuntime( 275): at android.view.View.performClick(View.java:2408)
E/AndroidRuntime( 275): at android.view.View$PerformClick.run(View.java:8816)
E/AndroidRuntime( 275): at android.os.Handler.handleCallback(Handler.java:587)
E/AndroidRuntime( 275): at android.os.Handler.dispatchMessage(Handler.java:92)
E/AndroidRuntime( 275): at android.os.Looper.loop(Looper.java:123)
E/AndroidRuntime( 275): at android.app.ActivityThread.main(ActivityThread.java:4627)
E/AndroidRuntime( 275): at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime( 275): at java.lang.reflect.Method.invoke(Method.java:521)
E/AndroidRuntime( 275): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
E/AndroidRuntime( 275): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
E/AndroidRuntime( 275): at dalvik.system.NativeStart.main(Native Method)
D/dalvikvm( 58): GC_FOR_MALLOC freed 18388 objects / 947880 bytes in 106ms
W/ActivityManager( 58): Force finishing activity com.accenturelabs.idoc/.RegisterWoman
I/ARMAssembler( 58): generated scanline__00000077:03515104_00000000_00000000 [ 33 ipp] (47 ins) at [0x34d7b0:0x34d86c] in 7148901 ns
Try to chek from your ddms data -> data -> your package ->database
here you will find that table is created of not.
also it you pull it out and open with SQllite browser u will get all the table list in it.
Hope this will help you
You should be extending SQLiteOpenHelper for your database code if you are not already.
Then check that your onUpgrade() method also calls back to your onCreate() method. You may be dropping all your tables and then not re-creating them. Make sure you bump the database version number every time you make a change to your tables.
The google iosched app has a complete, if not slightly complex example of how to do this.
http://code.google.com/p/iosched/source/browse/android/src/com/google/android/apps/iosched/provider/ScheduleDatabase.java
Actually i had to uninstall the application from the emulator .it worked fine after that

Android Smack chat client

Hi freinds I an using Smack3.2.1.jar downloaded from following url
http://www.igniterealtime.org/downloads/index.jsp
I added jar to my buildpath But when I run the application I get the following Error log
10-12 13:11:59.464: ERROR/AndroidRuntime(1957): FATAL EXCEPTION: main
10-12 13:11:59.464: ERROR/AndroidRuntime(1957): java.lang.VerifyError: org.jivesoftware.smack.sasl.SASLMechanism
10-12 13:11:59.464: ERROR/AndroidRuntime(1957): at java.lang.Class.getDeclaredConstructors(Native Method)
10-12 13:11:59.464: ERROR/AndroidRuntime(1957): at java.lang.Class.getConstructor(Class.java:477)
10-12 13:11:59.464: ERROR/AndroidRuntime(1957): at org.jivesoftware.smack.SASLAuthentication.authenticate(SASLAuthentication.java:314)
10-12 13:11:59.464: ERROR/AndroidRuntime(1957): at org.jivesoftware.smack.XMPPConnection.login(XMPPConnection.java:203)
10-12 13:11:59.464: ERROR/AndroidRuntime(1957): at org.jivesoftware.smack.Connection.login(Connection.java:348)
10-12 13:11:59.464: ERROR/AndroidRuntime(1957): at org.apache.android.xmpp.SettingsDialog.onClick(SettingsDialog.java:54)
10-12 13:11:59.464: ERROR/AndroidRuntime(1957): at android.view.View.performClick(View.java:2408)
10-12 13:11:59.464: ERROR/AndroidRuntime(1957): at android.view.View$PerformClick.run(View.java:8816)
10-12 13:11:59.464: ERROR/AndroidRuntime(1957): at android.os.Handler.handleCallback(Handler.java:587)
10-12 13:11:59.464: ERROR/AndroidRuntime(1957): at android.os.Handler.dispatchMessage(Handler.java:92)
10-12 13:11:59.464: ERROR/AndroidRuntime(1957): at android.os.Looper.loop(Looper.java:123)
10-12 13:11:59.464: ERROR/AndroidRuntime(1957): at android.app.ActivityThread.main(ActivityThread.java:4627)
10-12 13:11:59.464: ERROR/AndroidRuntime(1957): at java.lang.reflect.Method.invokeNative(Native Method)
10-12 13:11:59.464: ERROR/AndroidRuntime(1957): at java.lang.reflect.Method.invoke(Method.java:521)
10-12 13:11:59.464: ERROR/AndroidRuntime(1957): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
10-12 13:11:59.464: ERROR/AndroidRuntime(1957): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
10-12 13:11:59.464: ERROR/AndroidRuntime(1957): at dalvik.system.NativeStart.main(Native Method)
Can anyone help ...
Smack doesn't work on android out of the box, you may want to use aSmack (http://code.google.com/p/asmack/) which is a port of smack for Android.
Finally I got the Concrete implementation
Anyone who want to develop chat client then follow the steps mentioned below.
Go to link
http://www.beem-project.com/projects/beem/files
Download
asmack-android-7-source-beem.zip
Now modify this source as per your requirement.
You will find the lib asmack-android-7-beem.jar to obtain javadoc for this lib its same as javadoc for smack what i did is as follows.
Download source smack-3.2.1 from link below
http://www.igniterealtime.org/downloads/index.jsp
When you extract the jar you will get the folder named javadoc now just attach this folder to asmack-android-7-beem.jar by going to the properties of your project.
Hip Hip Hurray....
You can't use vanilla Smack prior Smack 4 on Android. Have a look at "Android and XMPP: Currently available solutions"
use dependencies inject this in your build.gradle
compile 'org.igniterealtime.smack:smack-android:4.1.6'
compile 'org.igniterealtime.smack:smack-tcp:4.1.6'
compile 'org.igniterealtime.smack:smack-im:4.1.6'
compile 'org.igniterealtime.smack:smack-extensions:4.1.6'

NumberFormatException in GPS processing

I am having a weird problem.
I am developing a program to log GPS and sensor readings periodically. My friend runs the code on his machine using Eclipse Galileo 3.6 and it works perfectly fine for her.
When I run the code on my machine which has Eclipse Galileo 3.5.2 it shows service stopped unexpectedly.
We have the same JDK version. I am not able to figure out what may be the exact problem.
Please let me know what else information I need to give in order to fix the problem.
logcat
I/ActivityManager( 1104): Start proc com.sensor.test for service com.sensor.test/.SensorReadings: pid=3539 uid=10057 gids={3003, 1015}
D/AndroidRuntime( 3539): Shutting down VM
W/dalvikvm( 3539): threadid=1: thread exiting with uncaught exception (group=0x4001d7e0)
E/AndroidRuntime( 3539): FATAL EXCEPTION: main
E/AndroidRuntime( 3539): java.lang.RuntimeException: Error receiving broadcast Intent { act=android.intent.action.BATTERY_CHANGED flg=0x60000000 (has extras) } in com.sensor.test.SensorReadings$2#44770958
E/AndroidRuntime( 3539): at android.app.ActivityThread$PackageInfo$ReceiverDispatcher$Args.run(ActivityThread.java:905)
E/AndroidRuntime( 3539): at android.os.Handler.handleCallback(Handler.java:587)
E/AndroidRuntime( 3539): at android.os.Handler.dispatchMessage(Handler.java:92)
E/AndroidRuntime( 3539): at android.os.Looper.loop(Looper.java:123)
E/AndroidRuntime( 3539): at android.app.ActivityThread.main(ActivityThread.java:4627)
E/AndroidRuntime( 3539): at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime( 3539): at java.lang.reflect.Method.invoke(Method.java:521)
E/AndroidRuntime( 3539): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
E/AndroidRuntime( 3539): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
E/AndroidRuntime( 3539): at dalvik.system.NativeStart.main(Native Method)
E/AndroidRuntime( 3539): Caused by: java.lang.NullPointerException
E/AndroidRuntime( 3539): at com.sensor.test.SensorReadings$2.onReceive(SensorReadings.java:327)
E/AndroidRuntime( 3539): at android.app.ActivityThread$PackageInfo$ReceiverDispatcher$Args.run(ActivityThread.java:892)
E/AndroidRuntime( 3539): ... 9 more
W/ActivityManager( 1104): Activity destroy timeout for HistoryRecord{44b38508 com.sensor.test/.MainScreen}
D/WifiService( 1104): acquireWifiLockLocked: WifiLock{NetworkLocationProvider type=2 binder=android.os.Binder#44963d80}
D/LocationMasfClient( 1104): getNetworkLocation(): Location not found in cache, making network request
D/LocationMasfClient( 1104): getNetworkLocation(): Number of prefetched entries 10
E/LocationMasfClient( 1104): getNetworkLocation(): Returning *server* computed location with accuracy 28
D/libgps ( 1104): GpsInterface_inject_location( 35.772249, -78.673950, 28.000 )
D/WifiService( 1104): releaseWifiLockLocked: WifiLock{NetworkLocationProvider type=2 binder=android.os.Binder#44963d80}
D/WifiService( 1104): acquireWifiLockLocked: WifiLock{NetworkLocationProvider type=2 binder=android.os.Binder#44963d80}
D/WifiService( 1104): releaseWifiLockLocked: WifiLock{NetworkLocationProvider type=2 binder=android.os.Binder#44963d80}
D/NativeCrypto( 1104): Freeing OpenSSL session
D/dalvikvm( 1104): GC_FOR_MALLOC freed 22104 objects / 1169312 bytes in 128ms
D/NativeCrypto( 1104): Freeing OpenSSL session
I/Process ( 3539): Sending signal. PID: 3539 SIG: 9
W/InputManagerService( 1104): Window already focused, ignoring focus gain of: com.android.internal.view.IInputMethodClient$Stub$Proxy#44b40dd0
I/ActivityManager( 1104): Process com.sensor.test (pid 3539) has died.
The pertinent code for line 88 with parsing going on:
public void startService(){
//startService(new Intent(MainScreen.this,SensorReadings.class));
Intent intent = new Intent(MainScreen.this, SensorReadings.class);
**intent.putExtra("lp", Integer.parseInt(""+longPeriod.getText()));// LINE 88**
intent.putExtra("gp", Integer.parseInt(""+gpsPeriod.getText()));
intent.putExtra("sp", Integer.parseInt(""+snrPeriod.getText()));
//startActivity(intent);
startService(intent);
}
Thanks.
AG
E/AndroidRuntime( 2934): java.lang.NumberFormatException: unable to parse '' as integer
E/AndroidRuntime( 2934): at java.lang.Integer.parseInt(Integer.java:412)
E/AndroidRuntime( 2934): at java.lang.Integer.parseInt(Integer.java:382)
E/AndroidRuntime( 2934): at com.sensor.test.MainScreen.startService(MainScreen.java:88)
Perhaps at line 88 in MainScreen.java, your startService method is calling Integer.parseInt with an empty string?
Can you show us the pertinent code?
I don't get why you are putting "".
So to be sure this is not the problem try either this:
intent.putExtra("lp", Integer.parseInt(longPeriod.getText()));
intent.putExtra("gp", Integer.parseInt(gpsPeriod.getText()));
intent.putExtra("sp", Integer.parseInt(snrPeriod.getText()));
or
String lp = longPeriod.getText();
String gp = gpsPeriod.getText();
String sp = snrPeriod.getText();
intent.putExtra("lp", Integer.parseInt(lp));
intent.putExtra("gp", Integer.parseInt(gp));
intent.putExtra("sp", Integer.parseInt(sp));
The second way is better for debugging... so you can see what is actually happening.

Exception on ListPreferences

This is my first Android app and I've encountered an exception when trying to use the ListPreference. The application loads along with the preferences... but when i touch the ListPreference entry the applications "stops unexpectedly".
Settings.java
public class Settings extends PreferenceActivity {
/** Called when the activity is first created. */
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.addPreferencesFromResource(R.layout.settings);
}
}
settings.xml
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android">
<CheckBoxPreference
android:key="chk_enabled"
android:summary="SMS response based on settings"
android:title="Enable"
/>
<ListPreference
android:title="Contacts"
android:summary="Contacs that will be sent SMSs"
android:key="list_contacts"
android:defaultValue="0"
android:entries="#array/list_entries"
android:entryValues="#array/list_values"
/>
</PreferenceScreen>
arrays.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string-array name="list_entries">
<item>All</item>
<item>WhiteList</item>
<item>BlackList</item>
</string-array>
<integer-array name="list_values">
<item>0</item>
<item>1</item>
<item>2</item>
</integer-array>
</resources>
This is the logcat output:
D/AndroidRuntime( 3187): >>>>>>>>>>>>>> AndroidRuntime START <<<<<<<<<<<<<<
D/AndroidRuntime( 3187): CheckJNI is OFF
D/AndroidRuntime( 3187): --- registering native functions ---
I/jdwp ( 3187): received file descriptor 16 from ADB
/ddm-heap( 3187): Got feature list request
I/ActivityManager( 86): Starting activity: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 cmp=tml.UI.main/.MainActivity }
D/AndroidRuntime( 3187): Shutting down VM
D/dalvikvm( 3187): DestroyJavaVM waiting for non-daemon threads to exit
I/ActivityManager( 86): Start proc tml.UI.main for activity tml.UI.main/.MainActivity: pid=3194 uid=10039 gids={1015}
D/dalvikvm( 3187): DestroyJavaVM shutting VM down
D/dalvikvm( 3187): HeapWorker thread shutting down
D/dalvikvm( 3187): HeapWorker thread has shut down
D/jdwp ( 3187): JDWP shutting down net...
D/jdwp ( 3187): +++ peer disconnected
I/dalvikvm( 3187): Debugger has detached; object registry had 1 entries
D/dalvikvm( 3187): VM cleaning up
D/dalvikvm( 3187): LinearAlloc 0x0 used 676380 of 4194304 (16%)
I/jdwp ( 3194): received file descriptor 10 from ADB
D/ddm-heap( 3194): Got feature list request
W/Resources( 3194): Converting to string: TypedValue{t=0x10/d=0x0 a=-1}
I/ActivityManager( 86): Displayed activity tml.UI.main/.MainActivity: 977 ms (total 977 ms)
D/AndroidRuntime( 3194): Shutting down VM
W/dalvikvm( 3194): threadid=3: thread exiting with uncaught exception (group=0x4001da28)
E/AndroidRuntime( 3194): Uncaught handler: thread main exiting due to uncaught exception
E/AndroidRuntime( 3194): java.lang.NullPointerException
E/AndroidRuntime( 3194): at android.preference.ListPreference.findIndexOfValue(ListPreference.java:169)
E/AndroidRuntime( 3194): at android.preference.ListPreference.getValueIndex(ListPreference.java:178)
E/AndroidRuntime( 3194): at android.preference.ListPreference.onPrepareDialogBuilder(ListPreference.java:190)
E/AndroidRuntime( 3194): at android.preference.DialogPreference.showDialog(DialogPreference.java:291)
E/AndroidRuntime( 3194): at android.preference.DialogPreference.onClick(DialogPreference.java:262)
E/AndroidRuntime( 3194): at android.preference.Preference.performClick(Preference.java:811)
E/AndroidRuntime( 3194): at android.preference.PreferenceScreen.onItemClick(PreferenceScreen.java:190)
E/AndroidRuntime( 3194): at android.widget.AdapterView.performItemClick(AdapterView.java:284)
E/AndroidRuntime( 3194): at android.widget.ListView.performItemClick(ListView.java:3246)
E/AndroidRuntime( 3194): at android.widget.AbsListView$PerformClick.run(AbsListView.java:1635)
E/AndroidRuntime( 3194): at android.os.Handler.handleCallback(Handler.java:587)
E/AndroidRuntime( 3194): at android.os.Handler.dispatchMessage(Handler.java:92)
E/AndroidRuntime( 3194): at android.os.Looper.loop(Looper.java:123)
E/AndroidRuntime( 3194): at android.app.ActivityThread.main(ActivityThread.java:4203)
E/AndroidRuntime( 3194): at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime( 3194): at java.lang.reflect.Method.invoke(Method.java:521)
E/AndroidRuntime( 3194): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:791)
E/AndroidRuntime( 3194): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:549)
E/AndroidRuntime( 3194): at dalvik.system.NativeStart.main(Native Method)
I/Process ( 86): Sending signal. PID: 3194 SIG: 3
I/dalvikvm( 3194): threadid=7: reacting to signal 3
I/dalvikvm( 3194): Wrote stack trace to '/data/anr/traces.txt'
I/Process ( 3194): Sending signal. PID: 3194 SIG: 9
I/ActivityManager( 86): Process tml.UI.main (pid 3194) has died.
I/WindowManager( 86): WIN DEATH: Window{4341fd00 tml.UI.main/tml.UI.main.MainActivity paused=false}
W/UsageStats( 86): Unexpected resume of com.android.launcher while already resumed in tml.UI.main
W/InputManagerService( 86): Got RemoteException sending setActive(false) notification to pid 3194 uid 10039
I fixed it... I kept on trying and, at the end, it turns out that I cannot use an integer-array as the entryValues Source. I just changed that integer-array to a string-array and got it working.
If there's a way to use integer-array as the source for entryValues please comment.
I've been searching for a similar solution to what you are looking for, agreeing that you should be able to use an Integer array to read from and store an integer result.
A solution to this problem I found was at http://kvance.livejournal.com/1039349.html, which I found to be useful.
It doesn't quite solve the problem the way I was thinking or that way I think you want it to, instead you still specify your initial / selection values with a String array although when the ListPreference saves it back to the SharedPreferences it saves as an Integer instead of a String (doing the conversion when the user selects it), removing the need to have to convert it possibly many times throughout your application when accessing the preference value.

Categories

Resources