Java Question Mysterious vanishing text resources

mjcoon

Well-Known Member
Licensed User
(N.B. I'm not really a library developer; I'm just feeling my way with Java and libraries!)

I like the CompassView library but would like to tweak it in minor cosmetic ways. My changes so far seem to behave in the way I expected in that I can set the value of a new property. I built the library using Simple Library Compiler v1.11. But my tweaked CompassView app fails to run under the debugger because as soon as the first text display should occur I get a crash which looks like this:
Connected to B4A-Bridge (Wifi)
** Activity (main) Resume **
android.content.res.Resources$NotFoundException: String resource ID #0x0
at android.content.res.Resources.getText(Resources.java:375)
at android.content.res.Resources.getString(Resources.java:468)
at main.com.redinput.compassview.CompassView.onDraw(CompassView.java:231)
at android.view.View.draw(View.java:21696)
at android.view.View.updateDisplayListIfDirty(View.java:20558)
at android.view.View.draw(View.java:21423)
at android.view.ViewGroup.drawChild(ViewGroup.java:4476)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4213)
at android.view.View.updateDisplayListIfDirty(View.java:20549)
at android.view.View.draw(View.java:21423)
at android.view.ViewGroup.drawChild(ViewGroup.java:4476)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4213)
at android.view.View.updateDisplayListIfDirty(View.java:20549)
at android.view.View.draw(View.java:21423)
at android.view.ViewGroup.drawChild(ViewGroup.java:4476)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4213)
at android.view.View.updateDisplayListIfDirty(View.java:20549)
at android.view.View.draw(View.java:21423)
at android.view.ViewGroup.drawChild(ViewGroup.java:4476)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4213)
at android.view.View.draw(View.java:21699)
at com.android.internal.policy.DecorView.draw(DecorView.java:859)
at android.view.View.updateDisplayListIfDirty(View.java:20558)
at android.view.ThreadedRenderer.updateViewTreeDisplayList(ThreadedRenderer.java:576)
at android.view.ThreadedRenderer.updateRootDisplayList(ThreadedRenderer.java:582)
at android.view.ThreadedRenderer.draw(ThreadedRenderer.java:655)
at android.view.ViewRootImpl.draw(ViewRootImpl.java:3998)
at android.view.ViewRootImpl.performDraw(ViewRootImpl.java:3793)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:3096)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:2005)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:8204)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1085)
at android.view.Choreographer.doCallbacks(Choreographer.java:908)
at android.view.Choreographer.doFrame(Choreographer.java:835)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:1070)
at android.os.Handler.handleCallback(Handler.java:883)
at android.os.Handler.dispatchMessage(Handler.java:100)
at android.os.Looper.loop(Looper.java:228)
at android.app.ActivityThread.main(ActivityThread.java:7782)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:981)

Even worse, I endeavoured to clean my Additional Libraries back to the original published libraries that worked perfectly well when first downloaded and the app fails in exactly the same way. So perhaps the problem is not in the library itself but how it is being incorporated in the app. But I know nothing about how the resource mechanism is meant to work so cannot see how to uncover the problem. Any hints, please?
 

mjcoon

Well-Known Member
Licensed User
It is really a mistake to use a library for such features. It is very simple to create a compass. You can use two ImageViews, declared as B4XView and rotate the needle with B4XView.SetRotationAnimated.

Thanks Erel but I did not want a rotating compass (as in the existing compass library, for which the demo rotates in the wrong direction!). I want a linear one as in CompassView, to emulate a "hand bearing compass" which is held vertically to view a distant object.

Fortunately I have executed a deeper "clean" and am now making progress. So am much less interested in any forensic analysis of what was happening...
 
Top