Android Question File not found error. [Solved]

Roger Daley

Well-Known Member
Licensed User
Longtime User
Hi All

This is my entry for the stupidest question of the week

Out of "Lock Down" boredom if am attempting to strip down an existing app to a light weight version. The App GUI relies on lots of images, many "glued" together.
1. With almost all the labels, buttons etc now statelist drawable most PNG files are gone.
2. I have started editing the code to eliminate the manipulation of images but the code is a suspect mess.
3. There are 3 layouts in total I am currently working on one. [Portrait]
4. As I try to compile and run to find what works and what doesn't eliminating errors as I go. Now I have come to a sticking point.

Problem: When I run the App I get errors of "File not found" where nothing should be looking for that file. Also an error saying an image view should be initialised, nothing should be looking for an image view.

Speculation: Having convinced myself that nothing in code or designer code is looking for these files I have to ask, Can there be something residual from the original App that I need to delete?


This is a long shot that someone may have come across something similar so don't worry if nothing comes to mind.

Regards Roger



The line where the IDE indicates the Imageview error is in Activity create:


B4X:
Sub Activity_Create(FirstTime As Boolean)
    ScrnOrientVal = StateManager.GetSetting2("ScrnOrientVal", 1)
    Private SR As Double
   
    If ScrnOrientVal = 0 Then
        SR = (Max(100%y,100%x))/(Min(100%y,100%x))      
        If SR < 1.6 Then
            Activity.LoadLayout("landscape")
            Log("SR Pre = "&SR)
        Else
            Activity.LoadLayout("landscape2")
        End If      
    Else  
        Log("6")
        Activity.LoadLayout("portrait")
    End If


The error log.

Logger connected to: samsung SM-A705YN
--------- beginning of main

** Activity (main) Create, isFirst = true **

java.lang.reflect.InvocationTargetException
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.DynamicBuilder.build(DynamicBuilder.java:21)
at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayoutHelper(LayoutBuilder.java:349)
at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayoutHelper(LayoutBuilder.java:453)
at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayout(LayoutBuilder.java:148)
at anywheresoftware.b4a.objects.ActivityWrapper.LoadLayout(ActivityWrapper.java:209)
at b4a.C_Calc.main._activity_create(main.java:986)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:196)
at b4a.C_Calc.main.afterFirstLayout(main.java:104)
at b4a.C_Calc.main.access$000(main.java:17)
at b4a.C_Calc.main$WaitForLayout.run(main.java:82)
at android.os.Handler.handleCallback(Handler.java:873)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:214)
at android.app.ActivityThread.main(ActivityThread.java:7094)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:494)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:975)
Caused by: java.lang.RuntimeException: java.io.FileNotFoundException: display.png
at anywheresoftware.b4a.objects.ImageViewWrapper.setImage(ImageViewWrapper.java:103)
at anywheresoftware.b4a.objects.ImageViewWrapper.build(ImageViewWrapper.java:124)
... 19 more
Caused by: java.io.FileNotFoundException: display.png
at android.content.res.AssetManager.nativeOpenAsset(Native Method)
at android.content.res.AssetManager.open(AssetManager.java:796)
at android.content.res.AssetManager.open(AssetManager.java:773)
at anywheresoftware.b4a.objects.streams.File.OpenInput(File.java:207)
at anywheresoftware.b4a.objects.drawable.CanvasWrapper$BitmapWrapper.Initialize(CanvasWrapper.java:516)
at anywheresoftware.b4a.objects.drawable.BitmapDrawable.build(BitmapDrawable.java:69)
at anywheresoftware.b4a.objects.ImageViewWrapper.setImage(ImageViewWrapper.java:101)
... 20 more
main_activity_create (java line: 986)
java.lang.RuntimeException: java.lang.RuntimeException: Object should first be initialized (ImageView).
at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayout(LayoutBuilder.java:170)
at anywheresoftware.b4a.objects.ActivityWrapper.LoadLayout(ActivityWrapper.java:209)
at b4a.C_Calc.main._activity_create(main.java:986)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:196)
at b4a.C_Calc.main.afterFirstLayout(main.java:104)
at b4a.C_Calc.main.access$000(main.java:17)
at b4a.C_Calc.main$WaitForLayout.run(main.java:82)
at android.os.Handler.handleCallback(Handler.java:873)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:214)
at android.app.ActivityThread.main(ActivityThread.java:7094)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:494)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:975)
Caused by: java.lang.RuntimeException: Object should first be initialized (ImageView).
at anywheresoftware.b4a.AbsObjectWrapper.getObject(AbsObjectWrapper.java:50)
at anywheresoftware.b4a.objects.ViewWrapper.innerInitialize(ViewWrapper.java:73)
at anywheresoftware.b4a.objects.ImageViewWrapper.innerInitialize(ImageViewWrapper.java:36)
at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayoutHelper(LayoutBuilder.java:434)
at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayoutHelper(LayoutBuilder.java:453)
at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayout(LayoutBuilder.java:148)
... 14 more
java.lang.RuntimeException: java.lang.RuntimeException: Object should first be initialized (ImageView).
** Activity (main) Resume **
main$ResumableSub_FMask_clickresume (java line: 8959)
java.lang.RuntimeException: Object should first be initialized (JavaObject).
at anywheresoftware.b4a.AbsObjectWrapper.getObject(AbsObjectWrapper.java:50)
at anywheresoftware.b4j.object.JavaObject.getCurrentClass(JavaObject.java:258)
at anywheresoftware.b4j.object.JavaObject.RunMethod(JavaObject.java:118)
at b4a.C_Calc.main$ResumableSub_FMask_click.resume(main.java:8959)
at b4a.C_Calc.main._fmask_click(main.java:8937)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:196)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:180)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:176)
at anywheresoftware.b4a.objects.ViewWrapper$1.onClick(ViewWrapper.java:80)
at android.view.View.performClick(View.java:7339)
at android.widget.TextView.performClick(TextView.java:14279)
at android.view.View.performClickInternal(View.java:7305)
at android.view.View.access$3200(View.java:846)
at android.view.View$PerformClick.run(View.java:27787)
at android.os.Handler.handleCallback(Handler.java:873)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:214)
at android.app.ActivityThread.main(ActivityThread.java:7094)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:494)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:975)
java.lang.RuntimeException: Object should first be initialized (JavaObject).
main$ResumableSub_FMask_clickresume (java line: 8959)
java.lang.RuntimeException: Object should first be initialized (JavaObject).
at anywheresoftware.b4a.AbsObjectWrapper.getObject(AbsObjectWrapper.java:50)
at anywheresoftware.b4j.object.JavaObject.getCurrentClass(JavaObject.java:258)
at anywheresoftware.b4j.object.JavaObject.RunMethod(JavaObject.java:118)
at b4a.C_Calc.main$ResumableSub_FMask_click.resume(main.java:8959)
at b4a.C_Calc.main._fmask_click(main.java:8937)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:196)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:180)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:176)
at anywheresoftware.b4a.objects.ViewWrapper$1.onClick(ViewWrapper.java:80)
at android.view.View.performClick(View.java:7339)
at android.widget.TextView.performClick(TextView.java:14279)
at android.view.View.performClickInternal(View.java:7305)
at android.view.View.access$3200(View.java:846)
at android.view.View$PerformClick.run(View.java:27787)
at android.os.Handler.handleCallback(Handler.java:873)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:214)
at android.app.ActivityThread.main(ActivityThread.java:7094)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:494)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:975)
java.lang.RuntimeException: Object should first be initialized (JavaObject).
** Activity (main) Pause, UserClosed = false **
main_activity_pause (java line: 1854)
java.lang.RuntimeException: Object should first be initialized (Label).
at anywheresoftware.b4a.AbsObjectWrapper.getObject(AbsObjectWrapper.java:50)
at anywheresoftware.b4a.objects.TextViewWrapper.getText(TextViewWrapper.java:36)
at b4a.C_Calc.main._activity_pause(main.java:1854)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:196)
at b4a.C_Calc.main.onPause(main.java:271)
at android.app.Activity.performPause(Activity.java:7662)
at android.app.Instrumentation.callActivityOnPause(Instrumentation.java:1469)
at android.app.ActivityThread.performPauseActivityIfNeeded(ActivityThread.java:4263)
at android.app.ActivityThread.performPauseActivity(ActivityThread.java:4228)
at android.app.ActivityThread.handlePauseActivity(ActivityThread.java:4180)
at android.app.servertransaction.PauseActivityItem.execute(PauseActivityItem.java:45)
at android.app.servertransaction.TransactionExecutor.executeLifecycleState(TransactionExecutor.java:145)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:70)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1960)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:214)
at android.app.ActivityThread.main(ActivityThread.java:7094)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:494)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:975)
java.lang.RuntimeException: Object should first be initialized (Label).
Ignoring event: rdisplay_focuschanged
** Activity (main) Resume **
main$ResumableSub_FMask_clickresume (java line: 8959)
java.lang.RuntimeException: Object should first be initialized (JavaObject).
at anywheresoftware.b4a.AbsObjectWrapper.getObject(AbsObjectWrapper.java:50)
at anywheresoftware.b4j.object.JavaObject.getCurrentClass(JavaObject.java:258)
at anywheresoftware.b4j.object.JavaObject.RunMethod(JavaObject.java:118)
at b4a.C_Calc.main$ResumableSub_FMask_click.resume(main.java:8959)
at b4a.C_Calc.main._fmask_click(main.java:8937)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:196)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:180)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:176)
at anywheresoftware.b4a.objects.ViewWrapper$1.onClick(ViewWrapper.java:80)
at android.view.View.performClick(View.java:7339)
at android.widget.TextView.performClick(TextView.java:14279)
at android.view.View.performClickInternal(View.java:7305)
at android.view.View.access$3200(View.java:846)
at android.view.View$PerformClick.run(View.java:27787)
at android.os.Handler.handleCallback(Handler.java:873)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:214)
at android.app.ActivityThread.main(ActivityThread.java:7094)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:494)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:975)
java.lang.RuntimeException: Object should first be initialized (JavaObject).
** Activity (main) Pause, UserClosed = false **
main_activity_pause (java line: 1854)
java.lang.RuntimeException: Object should first be initialized (Label).
at anywheresoftware.b4a.AbsObjectWrapper.getObject(AbsObjectWrapper.java:50)
at anywheresoftware.b4a.objects.TextViewWrapper.getText(TextViewWrapper.java:36)
at b4a.C_Calc.main._activity_pause(main.java:1854)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:196)
at b4a.C_Calc.main.onPause(main.java:271)
at android.app.Activity.performPause(Activity.java:7662)
at android.app.Instrumentation.callActivityOnPause(Instrumentation.java:1469)
at android.app.ActivityThread.performPauseActivityIfNeeded(ActivityThread.java:4263)
at android.app.ActivityThread.performPauseActivity(ActivityThread.java:4228)
at android.app.ActivityThread.handlePauseActivity(ActivityThread.java:4180)
at android.app.servertransaction.PauseActivityItem.execute(PauseActivityItem.java:45)
at android.app.servertransaction.TransactionExecutor.executeLifecycleState(TransactionExecutor.java:145)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:70)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1960)
at android.os.Handler.dispatchMessage(Handler.java:106)
at anywheresoftware.b4a.Msgbox.waitForMessage(Msgbox.java:231)
at anywheresoftware.b4a.Msgbox.msgbox(Msgbox.java:170)
at anywheresoftware.b4a.BA.ShowErrorMsgbox(BA.java:270)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:234)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:180)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:176)
at anywheresoftware.b4a.objects.ViewWrapper$1.onClick(ViewWrapper.java:80)
at android.view.View.performClick(View.java:7339)
at android.widget.TextView.performClick(TextView.java:14279)
at android.view.View.performClickInternal(View.java:7305)
at android.view.View.access$3200(View.java:846)
at android.view.View$PerformClick.run(View.java:27787)
at android.os.Handler.handleCallback(Handler.java:873)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:214)
at android.app.ActivityThread.main(ActivityThread.java:7094)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:494)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:975)
java.lang.RuntimeException: Object should first be initialized (Label).
 
Last edited:

KMatle

Expert
Licensed User
Longtime User
First: Are there any backups (B4x does this automatically if you haven't deactivated it)?

If not:

Solve it step by step:

1. Check which images are missing (see the logs) and add them again (you have a copy of the files, do you? If not: Add any file with the same name and replace it later). Check the files tab, too: Can you see the image-files there?
2. There are some other errors like "Object should first be initialized (ImageView). ". Add the views again (check the GLOBALS sub if all definitions are there)
3. It's a step by step procedure. Fix the first error and go on to the next.
 
Upvote 0
Top