resources.getIdentifier() in kotlin fragment - android-fragments

A very simple operation fails to build for reasons that I can't understand:
resources.getIdentifier(tokens[1],"drawable", requireContext().toString()) produces an incomprehensible (to me) error message: "Type mismatch: inferred type is New1Fragment
but Context! was expected"
New1Fragment is the fragment name. 'tokens' is an array of String vars that contains in index [1] the filename: String of the image resource in drawable whose integer identifier I need.
The code works as expected in an Activity (with "packageName" in place of "requireContext().toString()".
As a work-around, I could write a post processor to iterate through the drawables folder and grab the IDs of each item but that is clumsy and error prone.
What on earth does Context! mean? How may people of ordinary skill in the art know that?
Tried every possibility the IDE offered.
The compiler always gives the same incomprehensible error message.

Related

How to locate the method using an error message string?

I would like to know where is this error code located in the AOT. Would like to know the path to understand the structure and develop custom code.
Transaction has been selected, for settlement, although settlement type: none was selected
I generally use one of two methods to locate message strings.
Provided the cross reference is updated (it should be in dev) use the "Label editor" to to search for then string, see this answer.
Put a breakpoint in top of info.add method, disable CIL if needed, then rerun to get the error message invoking the debugger, see this answer.

Error messages: result.rejectvalue 3rd argument

in the following code what is the point of the third argument to rejectValue ?
errors.rejectValue("descriptions", "second_lang_desc_required", new String[] { secondLang.getCode() }, null );
I have this in the message value : Description in second language of application required {0} but this is exactly waht I see in the JSP, no replacement
According to Spring doc the purpose of the third argument is to provide a string array of arguments for replacing vars in messages.
In other words and telling from your code example its exactly what you expected it to be.
I guess you already checked if secondLang.getCode() is different from null. If so please have a look at whether or not you are using the latest release of org.springframework.
It is working in 4.2.4 but I remember having had to use a workaround before switching to 4.2.4 (Yes, of course - a clever guy would check change history and would 'know' instead of assuming, but I never claimed to be one, did I?)

Stack Trace Error for RefTableId field assignment

I created a new table and added a new Integer field (called RefTableId) with an EDT of the standard RefTableId type. Writing NewTable.RefTableId = tableNum(SomeTable); compiles but during run time I get this stack trace error: "Error executing code: Wrong argument types in variable assignment."
I've even tried NewTable.RefTableId = 0; This still fails. And yes, I've triple checked that it is indeed an integer field.
The solution is really stupid, the line before the assignments was reading .data() out of a FormListItem object that had invalid data in it. Instead of showing an error for that line, it skips over it and fails the assignment lines below. It makes no sense to me since I wasn't using any information from that FormListItem object to populate any field data with, yet still caused that to fail for some reason. I'm going to mark this one in the "Bang Head Here" category.
If the code is in a class, be sure to do a compile of all super classes as well as a compile forward (child classes). Remember to do an incremental CIL.
If it still fails do a full compile (axbuild).

Ada83 Constraint Error not Present in Watch Window

I'm looking at a constraint error when running this code. In the debugger it halts on the 2nd line (Menu_Text...). I put the code on the RHS of the assignment into the watch window and I see no problem. It's evaluates exactly as it should.
for I in 1..This_Info_Ptr.Child_Menu_Length loop
Menu_Text := This_Info_Ptr.Child_Menu_Text_Ptr.all(I-1);
Menu_State := This_Info_Ptr.Child_Menu_States_Ptr.all(I-1);
...
The error is when I is 1. I have confirmed that this code works in the watch window:
This_Info_Ptr.Child_Menu_Text_Ptr.all(I-1)
Child_Menu_Text_Ptr and Child_Menu_States_Ptr point to arrays (of strings and enums),
How should I debug this I general? I can't see anything wrong with the code. However, my familiarity with Ada access types is limited. The ..._Ptr variables are access types.
I am using GNAT.
Assuming the arrays being indexed are all of the same dimension and have the same index type, then iterating over them should be done using the 'first & 'last or 'range attributes.
It is likely that the hand coded control of length values has a bug.
Using the inbuilt functionality is safer and more reliable.
You aren't showing enough source text to tell us for sure what is happening. IsThis_Info_Ptr.Child_Menu_Text_Ptr.all a function or an array? What is it's specification?
If it is an array, you should remember that Ada allows arrays to be indexed by any discrete type, and that arrays in Ada always know their own indexing bounds.

Specflow error using TestDriven.Net - Couldn't Find Type

I'm trying out Specflow for the first time, and have created a VS2010 project with a reference to TechTalk.SpecFlow, as well as nunit.framework. I've added a sample Feature file:
Feature: Addition
In order to avoid silly mistakes
As a math idiot
I want to be told the sum of two numbers
#mytag
Scenario: Add two numbers
Given I have entered 50 into the calculator
And I have entered 70 into the calculator
When I press add
Then the result should be 120 on the screen
When I execuyte the test (using TestDriven.Net), I get the following error:
Test 'T:SpecFlowFeature1' failed: Couldn't find type with name 'SpecFlowFeature1'
System.Exception: Couldn't find type with name 'SpecFlowFeature1'
at MutantDesign.Xml.Documentation.MemberInfoUtilities.FindMemberInfo(Assembly assembly, String cref)
at TestDriven.TestRunner.AdaptorTestRunner.Run(ITestListener testListener, ITraceListener traceListener, String assemblyPath, String testPath)
at TestDriven.TestRunner.ThreadTestRunner.Runner.Run()
Anyone know what I'm missing?
Actually traced this down to how I was running the test. Right clicking the ".feature" file (or anywhere within that file) and selecting "Run Tests" resulted in the error. Right clicking the underlying ".feature.cs" file and selecting "Run Tests" executed correctly. Looks like TestDriven.Net wasn't able to "understand" the "*.feature" file.
I typically start "Couldn't find type..." errors in my references folder and make sure that the library that I'm referencing is being referenced correctly and that the version that's being referenced isn't outdated.
Also, make sure that your SpecFlowFeature1 class isn't mistakenly declared as private. Visual Studio creates new classes (by default) as private and if you don't specify a class as public, it will remain private and not "visible" to outside projects.

Resources