Eclipse - Blackberry SDK - Debugging on device: "details unavailable - not supported by VM" - eclipse

I'm having a strange problem while debugging my Blackberry Application on a real device (BB Bold 9700). When I debug the same application within the BB emulator, the app runs fine, but when I run it on the real device, the app behaves differently (custom painting goes completely wrong). What's even worse is that my Eclipse environment seems to be unable to view live objects correctly while being at a break point (debug time).
I've added a screenshot to illustrate the strange behaviour:
As you can see, the app stops at the breakpoint within the IF statement, but the Variables pane says that the variable "methodName" equals null. Moreover, when I want to look at the variable "methodArguments" which is of type org.json.me.JSONArray, it says "details unavailable - not supported by VM".
Does anyone know what's going on here? My app works great on the emulator, but it's currently useless on the real device.
Thanks in advance!

I think I fixed it:
The problem was that I was laying out Fields on a manager that wasn't yet added to the viewstack.
What did the trick for me was overriding onDisplay() in the manager that contained the Fields that were displayed wrong:
protected void onDisplay()
{
//Make sure superclass is called
super.onDisplay();
/*You have to call "this.setDirty(true)" when you perform layout on a
*manager that isn't added to the viewstack. Then you can use
*"this.isDirty()" to determine whether you need to re-layout the fields
*when the manager becomes visible.*/
if(this.isDirty())
{
//I'm not sure if I need to use "invokeAndWait" and not "invokeLater"
UiApplication.getUiApplication().invokeAndWait(new Runnable()
{
public void run()
{
for (int i = 0; i < getFieldCount(); i++)
{
/*This (custom) function makes sure the Field gets its
*size and position*/
layoutItem(getField(i));
}
}
});
//Make sure you set "dirty" to false, to make sure this only happens once
this.setDirty(false);
}
}
If anyone has a better solution, I'd be glad to hear it (and maybe improve my app).

org.json.me.JSONArray, it says "details unavailable - not supported by VM".
the JSON related stuff is not available on device running 4.5 and 4.6 BB OS. Import it into the code.
Download it from here.
https://github.com/douglascrockford/JSON-java
it is available as Open Source and then use it into your applications.

Related

How do I prevent my app from running in the "recent menu" on Android 12

Android 12 introduced the behavior where the last app you had active are continuing to run when inside the recent menu. I'm wondering if there's a flag or something to put in AndroidManifest file to prevent this behavior as it's conflicting with some logics in our app (which works fine for Android < 12). I've googled but it's hard to find unless you know exactly what this "feature" is called.
Steps:
Start app
Open recent menu
Observe that you can interact and that the app is still running as if you had it open/active
Why is this a problem? Because a user is now able to force quit the app (swiping it away) without entering the "paused" state in our game (using Unity) meaning some save logic won't run.
This can be worked around in one way or another, but for now I would like to just pause the app in recent menu if possible (our app has zero reason for being active in recent menu).
EDIT:
As #WyattL mentioned in his answer, android:excludeFromRecents="true" might work, but it will cause drop in playtime and retention of the game and would prefer to have a more proper solution to this "unnecessary" feature of Android 12.
I can't be sure without testing on every phone as it seems the issue varies by device (thanks Ruzihm), but if opening the Recent Apps screen generates an OnApplicationFocus() call, this would provide a solution.
In an active MonoBehaviour:
private void OnApplicationFocus( bool focus )
{
if( focus ) {
UnpauseLogic();
}
else {
PauseLogic();
SaveLogic();
}
}
(It might also be worth trying OnApplicationQuit() in case it's called on specific devices during a swipe termination, but in my own tests it was never called.)
According to some brief research, did you try adding
<activity>
...
android:excludeFromRecents="true"
android:label=""
...
</activity>
to the AndroidManifest.xml?

Memory Access Out of Bounds - WebGL

I was getting this error when I try to load my Web game:
My game is loaded at this domain:
Highest Flavor Website Link
This is my project settings at the time of build export:
Please give me some suggestion to solve this problem.
This error happened to me due to using the dynamic keyword. After replacing all my dynamic types with object the error was gone. Apparently the dynamic keyword is not supported on WebGL builds.
I've finally fixed the same error in my project. Here is what i did:
Narrow down the line of code that crashes WebGL.
Go through the painfull process of pinpointing the line of code that
is the source of the error. I had this "luck" that error occured
when I've hit button and tried to load UIScene in Addition mode. So
at first I found the script in the scene which when disabled got rid
of the crash. Then I've repeated the steps and digged deeper into
lines. After 2 hours of builds, comments etc I've found that the code
was not working was setting the new color for UnityEngine.UI.Image.
Which was pretty weird because in playmode everything worked ok.
Find solution. I think my solution might not be universal but I think there is something going in the Unity gameloop/lifecycle when running WebGL. The source of the problem was that i set the field that was storing my UI.Image in the Start method and then in some function I've tried to change the color.
Property was not exposed in inspector.
public class ModuleUI : MonoBehaviour
{
Image qualityBG;
void Start()
{
qualityBG = GetComponent<Image>();
}
...
then this line below was the cause of the crash
public void Set(Module module)
{
...
qualityBG.color = module.Quality.ToColor();
}
Fixing - so I've added [SerializeField] attribute to the field and set it up in editor, dragged the Image into the inspector slot. An it fixed it. I suspect that WebGL build might perform some methods in different order, or maybe the multipleScene loaded together might to do with it. I'm not sure but the field was not set properly with previous code fot WebGL build.
Bonus:
I've also fixed some issues that was not critical (not crushing WebGL game) but not working properly as expected in playmode. This also has got to do with trying to set some object in Start() method and then doing something on them. The collection was not set up (probably null) in WebGL.
EffectUI[] effects;
Start()
{
effects = GetComponentsInChildren<EffectUI>();
}
void HideAllEffects()
{
if (effects != null)
for (int i = 0; i < effects.Length; ++i)
effects[i].gameObject.SetActive(false);
}
And this also started working when I've added [SerializeField] to effects and hook it up in the scene...
Hope this will help some of you guys & gals!
To run this build within the web browser - I have removed all extra things related code those can't work within the web build like in-app purchase, advertisements, leaderboard, native sharing etc...
After these things code removed from the project, I uploaded the exported build content to my hosting. Then after it started working properly.

How to bind button click commands in ReactiveUI for iOS

I'm trying to learn ReactiveUI for a Xamarin.iOS project and I'm stuck on what should be a simple task. I am unable to bind a button click to a ReactiveCommand in the same way I can in my companion Xamarin.Android project. Here is the Android code that works fine:
this.BindCommand (ViewModel, x => x.ClickMe, view => view._button);
Here is the same pattern used in iOS:
this.BindCommand (ViewModel, x => x.ClickMe, view => view.GetForecastButton);
However, in iOS I get the following warning:
"Couldn't find a Command Binder for MonoTouch.UIKit.UIButton"
Does anyone know what I'm doing wrong? The astonishing thing is that I've looked up dozens of ReactiveUI iOS examples and I still haven't found one that has even a single button in the app. They all do something like show text from a bound property or show a UITableView from a collection in the ViewModel. I'm sure there is a more complete iOS example out there and if anyone knows of one please include in your answer. Many thanks.
You're doing everything correctly, but I believe you're being trolled by a Xamarin.iOS bug that affects ReactiveUI, where Type.GetType won't load assemblies. Paste this into your AppDelegate:
https://github.com/paulcbetts/starter-mobile/blob/master/Starter-iOS/AppDelegate.cs#L35
// NB: GrossHackAlertTiemâ„¢:
//
// Monotouch appears to not load assemblies when you request them
// via Type.GetType, unlike every other platform (even
// Xamarin.Android). So, we've got to manually do what RxUI and
// Akavache would normally do for us
var r = RxApp.MutableResolver;
(new ReactiveUI.Cocoa.Registrations()).Register((f,t) => r.Register(f, t));
(new ReactiveUI.Mobile.Registrations()).Register((f,t) => r.Register(f, t));

.Net Monodroid spinner auto-fill

I am using .Net and Monodroid to develop Android applications, however I seem to have hit a wall when it comes to filling in a Spinner at run time, as I do not have access to the [Spinner Object].SetAdapter(...) method. I have been to both
developer.android.com/resources/tutorials/views/hello-spinner.html
and
android.xamarin.com/Tutorials
as well as
stackoverflow.com/questions/3958866/how-to-change-the-contents-of-spinner-on-run-time-in-android
and everything relies on this method. Is this a limitation of the unregistered version? Because they do not say anything about feature-limits here android.xamarin.com/DownloadTrial
Any help will be appreciated.
In Mono for Android, many cases where Java will have getXXXX/setXXXX methods get translated into properties named XXXX, in order to be more .NET friendly. In this case, Spinner.setAdapter() in Java becomes Spinner.Adapter in Mono for Android:
Spinner spinner = FindViewById<Spinner> (Resource.Id.spinner);
spinner.Adapter = new ArrayAdapter...
Xamarin also has a Spinner tutorial available here that might help you get going.
Solved it - there is an Adapter property that can be used to access the Adapter.
Also it turns out you must check if the adapter is null first - you cannot read a null object :)
if (_itemlist.Adapter == null)
{
adapter = new ArrayAdapter(this, Android.Resource.Layout.SimpleSpinnerItem, items);
}
the only problem is that it does not automatically refresh and the invalidate(...) method does not cause it to redraw with the new items...

Why does XCode show the wrong object address in the debugger window?

My application tested whether my selectedViewController was equal to my moreNavigationController.
if( self.tabBarController.moreNavigationController == self.tabBarController.selectedViewController )
{
// do something awesome.
}
else
{
NSLog(#"No match");
}
The expression always evaluated false, so I started debugging. I put a breakpoint in the code and hovered my pointer over 'self', which caused the yellow cascading popup where I could see the addresses of both Controllers. The addresses were the same in the popup, which must be incorrect since the if statement failed. I see the same result in the debugger window.
I added these logging statements later, which revealed that the objects had 2 different addresses.
NSLog([NSString stringWithFormat:#"%d",(self.tabBarController.moreNavigationController)] );
NSLog([NSString stringWithFormat:#"%d",(self.tabBarController.selectedViewController)] );
Why did the debugger window lie? Specifically, does anyone know what value it displays as its address, and why the controllers would show the same address?
I have had this exact same problem, and I'm 90% sure it's related to building for a 2.1 (or possibly 2.X) SDK while using the 3.0 dev tools. In my case, setting the target SDK for 3.0 fixed this issue.
Having your debugger essentially lie to you is frustrating ;)
I am seeing EXACTLY the same thing. Especially with floats. I switch to 3.1 target and it displays right. The question is, is the code really working correctly under 2.1 (an NSLog of the variables tells me it is).