Hi all,
our android apps crashes after android update (2.2.1) on HTC Desire HD & Z. We get the following error:
java.lang.NullPointerException
at android.widget.TextView.onTouchEvent(TextView.java:7202)
Anybody facing the same issue?
Thanks for your help!
Sandro
Don't know how general this is, but I had same error:
java.lang.NullPointerException
at android.widget.TextView.onTouchEvent(TextView.java:7202)
at android.view.View.dispatchTouchEvent(View.java:3778)
when user clicked on textview/button just on certain phones ( HTC Desire HD, just this one).
I first used TextView with setClickable, and thought i'd set
text.setInputType(InputType.TYPE_CLASS_TEXT
| InputType.TYPE_TEXT_VARIATION_NORMAL
| InputType.TYPE_TEXT_FLAG_MULTI_LINE);
Then I changed to button, but didn't remove this line. Error was same. Button is subclass of TextView?!.
Other phones survived this (ignore, default value, don't know), this model didn't.
After I removed this line, application works.
Same problem on HTC Droid Incredible, 2.3.4
I'm having the same problem with an HTC Incredible running 2.3.4. TextView crashes with a NullPointerException in onTouchEvent (at line 7443 (different line number because of different OS version) when I touch a TextView with a particular configuration. I haven't been able to isolate what it is about my configuration of TextView that causes the problem. From single-stepping through the code in the debugger, it is clear that the code in question is something HTC added to Google's standard source for 2.3.4 TextView.onTouchEvent. (There are no pointers being accessed at this point in Google's code.) (I should note that the app works fine with the emulator and Google's 2.3.4; also with phones from other manufacturers with 2.2.3 and 4.1.1. Of the configurations I've been able to test, only the HTC has the problem.)
Did you solve your problem? Do you remember how?
Workaround
Ok. In case anyone else comes here with the same problem, here's what I found.
I was creating an editable TextView (not an EditText) programmatically (not inflating from XML). On HTC phones (Incredible running 2.3.4 in my case, it looks like other HTC phones with other versions of Android may also have had this problem) something in the TextView object does not get initialized correctly when constructing from "new TextView(..)" where you also call setInputMode(EditorInfo.TYPE_CLASS_TEXT) (part of making it editable) on the object. Whatever it is, it _does_ get initialized properly when inflated from XML (where you set the android:inputMode="text" attribute).
What I had to do is inflate a TextView from XML (only the 'android:inputMode="text"' attribute is expressly required), and then adjust it programmatically as needed (including further calls to setInputMode if required).
Related
Hi guys
I've just started working with Silvermoon. When testing the demo app (as well as my own app) on my HD2, it works fine for 6 times, but when I start the app for the 7th time, it crashes without any message.
Has anyone else had this problem? Any ideas?
Any help would be appreciated!
Thanks, Rob
I don't have these problems on my HD. It looks like some resources are not cleaned up at application exit. Do you call 'Screen.Close();' when exiting the application?
edit:
As you're using an HD2 you don't have the libGLES_cm.dll and I assume you have copied the one of the demo. This is a software implementation and could also be the reason of running out of memory. The OpenGLES 1.x dll on GLES2 devices is called something like libGLESv1.dll. To use OpenGLES in a managed application/library the methods have to be imported from the dll and the dll name has to be defined at compile time. So, take a look at the silvermoon sources and if you find dllimport(...) using libGLES_cm.dll you'll have to replace this dll name with libGLESv1.dll (look up the correct name in your /windows directory) and rebuild framework.
(had to do that in my OpenGL test app for gles2 devices)
edit2:
Had a quick look into the silvermoon sources and for gles2 devices it has to be recompiled after changing the dll names:
in Silvermoon\OpenGL\Native\
egl.cs: change const string LibGlesDllName = "libgles_cm.dll"; to ... = "libEGL.dll"
gl.cs: change const string LibGlesDllName = "libgles_cm.dll"; to ... = "libGLESv1.dll"
(the egl dll could also be changed to "libGLESv1.dll" just in case this doesn't work)
You'll need VS2008 to compile the solution.
Hello heliosdev,
Thank you very much for your reply, I really appreciate it!!! I am calling Screen.Close() in my app and have the same problem in Silvermoon demo, so this shouldn't be the issue...
My HD2 has the following files in Windows directory:
libEGL.dll
libEGL_org.dll
libGLES_CL.dll
libGLES_CM.dll
libGLESv1_CM.dll
libGLESv2.dll
I recompiled OpenGl.dll in VS2008 with the folowing combinations & results:
libGLES_CM.dll in gl.cs & libEGL.dll in egl.cs -> app not starting at all.
libGLES_CM.dll in gl.cs & egl.cs -> app crashes at 7th start
libGLESv1_CM.dll in gl.cs & egl.cs -> app not starting at all.
libGLESv1_CM.dll in gl.cs & libEGL.dll in egl.cs -> app crashes at 7th start
Any further ideas?
I think the last version (v1 and egl) should be used on gles2 devices instead of the software renderer.
Now it's getting difficult.
Maybe try to disable Manila (Sense) restart device and test your app.
If it still fails:
Try to start another opengles app several times. (try my opengl test app (snapdragon version))
edit:
something else to try (yes, I'm getting out of ideas...)
Before Screen.Close() you could call gl.DeleteTextures() with for example an array of 100 uints starting at 1.
Disabling "HTC Sense" allows for one extra launch of the app, meaning it crashes at the 8th start attempt. Exactly the same problems using your TestOpenGL.
The only difference is, that when trying to launch my app for the 7th/8th time, the busy cursor appears shortly on the screen, as if it were starting up, but then just disappears and nothing more happens. When I launch TestOpenGL, the busy cursor appears and freezes, then nothing more happens.
ok, so it looks like resources are not cleaned up.
Try the glDeleteTextures suggestion. (even though this is called)
btw: Are you using a stock rom? Have you installed any 3d drivers (like chainfire's patch found in the sticky thread in the forum)?
Nope, unfortunately gl.DeleteTextures(1, 100) just before Screen.Close() is not helping either...
I'm using Xannys Pandora ROM which has GLTweaks integrated. However, taking into consideration the posts from codeplex, where several people are having the exact same problem on different phones (tg01, hd2), can it really be a ROM problem?
BTW: Thank you so much for taking the time to try and help!!!!
I struggle with the same issue in my own app (here) using silvermoon (7th start fails using HW renderers).
heliosdev Test app runs fine and can start numerous times without problems (gave up after 20 starts), also tried "coin toss" (here) without problems running multiple times.
Running on Miri's 6.5.x v8 without any enhancements installed.
Ok, I've created a small test app, which simply loads a form containing a Silvermoon window control, with a ChromeButton on it. On clicking the button, I call Screen.Close() to exit the app.
Testing on the Emulator works fine, but on my HD2 the 7th attempt to launch the app results in the following error: "Error on glGenTexture.". I have traced this Error to Line 37 in "Texture.cs" of the OpenGL source:
Code:
public Texture()
: base()
{
this.Name = gl.GenTexture();
[b]if (this.Name == 0) throw new OpenGlException("Error on glGenTexture.");[/b]
}
I added a line in Texture.cs to output the gl.GenTexture() uint value. On the first 6 start attempts it returns the values 1 and 2, but on the 7th it returns 0, which obviously is what causes the error.
Digging further, the GenTexture() method (which is returning 0) comes from pInvoking glGenTextures() in libgles_cm.dll.
Sadly, this is where my programming skills end... I really hope we can find a solution to this issue! It would hurt, having to give up on Silvermoon.
Looks like 'out of memory'. Call the following method before and after the GenTexture call (1285 is out of memory error).
Code:
private void CheckErrorGL(string info)
{
uint err = gl.GetError();
if (err != gl.GL_NO_ERROR)
{
MessageBox.Show(err.ToString(), "GL " + info);
}
}
Doesn't seem to be OutOfMemory... gl.GetError() is returning 0.
The exception is thrown without any glerror message box?
Run cleanRAM before calling it for the 7th time.
Correct, it's not throwing a glerror! Although, VS2008 is not showing me GL_NO_ERROR option on gl. But an if I remove the if-clause from your code (if (err != gl.GL_NO_ERROR)), the messagebox always returns 0.
Just ran a level 3 purge with cleanRAM... problem remains
The error definitions are in the namespace Silvermoon.OpenGL.Native (gl/egl)
And what does egl.GetError() return? (EGL_SUCCESS is 12288)
Code:
private void CheckErrorEGL(string info)
{
int err = egl.GetError();
if (err != egl.EGL_SUCCESS)
{
MessageBox.Show(err.ToString(), "EGL " + info);
}
}
the error definitions are surrrounded by a
#region obsolete
#if false
...
#endif
Change the false to true to access them.
get a EGL 12294 before calling gl.GenTexture()
seems to be a EGL_BAD_CONTEXT
Before calling gl.GenTexture() I'm also getting error code 12294 (EGL_BAD_CONTEXT) and afterwards 12288 (EGL_SUCCESS).
(Had a typo in my code, therefore I got the wrong result previously...)
I have the same problem with my tiny graphics engine. I think its the same problem because the egl.cs and its setup are nearly identical. So here's what I've found out:
- Its only about Egl, not about OpenGl, so forget deleteTextures etc (I've written a little test, that simply creates a display, context and surface and destorys them, no Gl calls and the same bug)
- create context creates a "Gl_Bad_Alloc" error
- everything that is allocated by egl is also destroyed
I think its also not a bug in the driver, because there is for example that ogles 2 game electopia or something like that, and this game is not affected!
I found a solution!!! I don't know about Silvermoon, but it works with my tigre engine. I can't explain it, I have no idea, and itse not the best solution, but it seems to work. Just DO NOT destroy the display, DO NOT delete context and DO NOT delete the surface. Any one have a idea why it is like that?
Phippu said:
I found a solution!!! I don't know about Silvermoon, but it works with my tigre engine. I can't explain it, I have no idea, and itse not the best solution, but it seems to work. Just DO NOT destroy the display, DO NOT delete context and DO NOT delete the surface. Any one have a idea why it is like that?
Click to expand...
Click to collapse
Amazing! That did the trick with silvermoon too. Great find, thanks!
No idea why that works though.
Sometimes it seems to be better leaving a mess instead of cleaning everything up properly
Hi all-
I am relatively new to android development, and the current project I've picked out for myself has proven to be more difficult than I thought it would be.
My goal is to create an app that will tell me about wimax network(s) my phone sees with more detail than you get from the settings application or something. Looking at the WifiManager class in developer.android, it looks like I am looking for the Wimax equivalent to getScanResults() - something that returns the list of networks seen in the last scan.
So after some digging online I found references to a Toggle4G widget that does getSystemService("wimax") to get a WimaxManager object, and uses reflection to get the getWimaxState() and setWimaxState(bool) methods. I used getMethods() on the WimaxManager object, and got a list similar to this one I found on pastebin:
EDIT: new user = unable to post links? Well, here's the pastebin code so you can find it
pastebin: 8ktAtcpm
The method of interest at the moment is ndssGetScanResults(), excerpt from pastebin below:
Code:
I/System.out( 1972): Method Name: ndssGetScanResults
I/System.out( 1972): Parameter Type = [Lcom.sqn.dcc.ScanResult;
Unlike the WifiManager though, it looks like this one takes an array of this ScanResult class instead of returning a list of networks. Not exactly sure how this works. I used java.lang.reflect.array to create an array of ScanResults and invoked the ndssGetScanResults() method, but I dont appear to be getting anything - even when I'm already connected on wimax! Can anyone please explain how to call this method correctly so that it will return what networks the phone sees?
I've searched these forums for ndssGetScanResults and other methods that seemed applicable, but I haven't found anything that appears to answer this question. Any help would be appreciated. Thanks!
ROMs affected for sure: iNsertCoin v2.0.0 and RCMixHD v3.5 (both A2SD)
Whenever I type in characters in HTC Dialer to search for a name (e.g. 846 for contacts named 'Tim') the first number gets ignored, resulting in search results starting with characters represented by the numbers '46', e.g. 'Ho...'.
Similarly, when I try to access the test screen via *#*#4636#*#*, the first character '*' gets ignored (it even disappears after putting in the first '#').
If I put in something, then remove it with backspace and start over, it does work.
Don't think it's relevant, but Baseband version is 32.49.00.32U_5.11.05.27.
What is happening here? Tried setting different locale in settings, different keyboards, no change. Thanks in advance.
Ok second post now. Maybe your phone is a little nakered, rom broke a little. It seems your just getting software errors which happen when you flash custom roms.
Posted this here in Q&A after iNsertCoin developer suggested me to do so. He heard of this problem before, but had no solution. Hopefully other ppl have found one, but an extensive search both here and on other forums did not give any result.
Solved
After (quite!) some more research, I've found a similar problem described in the topics below. The presented fix there also solved my problem (see quote):
With great help of some participants of xda forum a workaround for this issue has been found: just remove the dialer shortcut from the dock (set it to "blank") and then add it back in (a shortcut to "Phone" app). This will fix the problem.
Apparently, people who are not experiencing the issue are the people who already recreated their dialer shortcut while customizing the dock. Meanwhile, people who keep the initial dock (or, more precisely, the initial dialer shortcut) all experience this problem. The problem is not limited to Plus version - a plain LaucherPro has it as well.
It looks like LauncherPro, as shipped, uses some unorthodox way to launch the dialer (I wonder why), which is what's causing the latter to act up. Recreating it as an ordinary app shortcut fixes the problem.
Click to expand...
Click to collapse
Sources:
http://www.launcherpro.com/forum/viewtopic.php?f=14&t=5884
http://forum.xda-developers.com/showpost.php?p=10490200&postcount=15
Hi all,
I'm new to xda-developers, and I didn't find a thread with a similar problem, so I'm hoping you could help or point me in the right direction.
I wrote an auto-dialing app, which uses the Android SDK's Intent.ACTION_CALL and the URI "tel:<number>#".
I tested it on an HTC Desire HD phone (with stock Froyo ROM). So far so good.
However, since I updated my phone's ROM to HTC's Gingerbread (2.3.3), the app started to quietly ignore all "#" characters when dialing the number.
I checked around several users of the app - it seems that only HTC Gingerbread ROMS are affected, so it's not a general Android SDK problem. On the other hand, HTC support was very frustrating so far (e.g. "did you try to reboot the device?").
Does anybody else know about this? Is there any workaround for this?
I'm attaching the source code for a sample app which demonstrates the problem.
Thanks
I have a PhoneGap application designed to work on multiple mobile platforms. I'm loading a dynamic HTML content from an external page on the Internet using jQuery Mobile. The problematic system is Windows Phone 7.
This is what I get from the external page, with the URL of the script tag already replaced to load from the phone instead of from the net to save bandwidth:
HTML:
<script type="text/javascript" charset="utf-8" src="x-wmapp1:/app/www/test.js"></script>
This works fine on Android, iPhone and even BlackBerry when I replaced the x-wmapp1: part by a respective counterpart (e.g. file:///android_asset/www/ on Android). However, on Windows Phone 7 it doesn't seem to work at all.
When I try to load the same URL via $.getScript function, it always returns a 404 eror, even if I try and load it with a relative path only.
Any suggestions?
First of all, this type of question may be better suited to the Software Development or Apps and Games sub-forums, as a lot of the people who hang out here are more familiar with homebrew hacks. I'll give it a shot, though.
First of all, what kind of path are you trying to use? I haven't tried loading scripts or images in HTML or JS, but to dynamically load content within the app itself typically requires some care with regard to the path. For example, is the JS file being built into the assembly (as a resource) or included alongside it (as content)? How about the HTML page?
This is a kind of lame approach, but one option that's sure to work is just inlining the scripts in the page, directly. That won't increase the total app size or load time at all, although it might make maintaining the app take a little bit more effort.
Thanks for the reply, I will try to post this into the more appropriate forum.
With regards to paths - you can see the path in the HTML snippet I provided in the original question. It's all a bit specific and we cannot afford to load JS directly from page, since that does increase the size of the resulting HTML, sent from an external PHP page, thus increasing bandwidth. This is the first reason why we chose to have all JS and CSS files directly bundled with the application and load them internally rather than from Internet.
Also, all of JS files are included alongside the application as content. I'm using the same approach for all images, since if they were included as a resource, they would not show in the application.
GoodDayToDie said:
First of all, this type of question may be better suited to the Software Development or Apps and Games sub-forums, as a lot of the people who hang out here are more familiar with homebrew hacks. I'll give it a shot, though.
First of all, what kind of path are you trying to use? I haven't tried loading scripts or images in HTML or JS, but to dynamically load content within the app itself typically requires some care with regard to the path. For example, is the JS file being built into the assembly (as a resource) or included alongside it (as content)? How about the HTML page?
This is a kind of lame approach, but one option that's sure to work is just inlining the scripts in the page, directly. That won't increase the total app size or load time at all, although it might make maintaining the app take a little bit more effort.
Click to expand...
Click to collapse
First question: have you set the IsScriptEnabled proerty on the control to True? It defaults to False, preventing scripting within the control. Also, changing it only takes effect
on navigation, so if you already loaded the page and then set this property, it still won't work.
Anyhow, I missed that your HTML was coming externally, and only the scripts and stylesheets were local. That's... interesting, and seems reasonable enough, and I can't find any info online that exactly matches your use case. The way you're structuring the script src URI looks weird to me, but I haven't messed with the WebBrowserControl very much at all.
One solution, though a bit hacky:
Use the WebBrowserControl's InvokeScript function to dynamically load scripts into your pages. To do this, you would first need to load the script file content into a .NET String object. The GetResourceStream function is probably your best friend here, combined with ReadToEnd(). Then, just invoke the eval() JS function, which should be built-in, and pass it the JS file content. That will load the JS into the web page, creating objects (including functions) and executing instructions as the files are eval()ed.
Of course, you'd need to do this on every page navigation, but you can actually automate it such that the page itself requests that the app load those scripts. In your app, bind the script-loading function to the ScriptNotify event handler, probably with some parameter such as the name of the script to load. Then, on each page served from your server to the app, instead of including standard <script src=...> tags, use <script>window.external.notify('load localscript1.js')</script> and so on; this will trigger the app's ScriptNotify function for you.
I hope that helps. I can see your use case, but somewhat surprisingly, I couldn't find anybody else online who had either run into your problem or written a tutorial on doing it your way.
Thank you for your reply, it was very informative. One question though - why do you think the way I'm structuring the SCRIPT URI is wierd? I tried to mess around with relative URIs and the such, however those would load the JavaScript file from Internet rather than from the application itself.
The problem I'm running into with your proposed solutions, however is that:
1. the project is a PhoneGap/Cordova application, using its own components, so I have no idea where I would look for IsScriptEnabled here (although this all worked on an older PhoneGap release, so I'm guessing they have it set up correctly)
2. injecting a script programmatically on each navigation would require me to rewrite much of the code we already use for other platforms, not to mention those custom Cordova components, which I don't even know if they can handle such thing
As for my user case - I was surprised to be the only guy on the internet with this methodology in place as well. So it either works for everyone else or nobody really thought of doing it my way, since it's basically an Internet application (maybe the don't want to disclose their sources, who knows).
CyberGhost636 said:
1. the project is a PhoneGap/Cordova application, using its own components, so I have no idea where I would look for IsScriptEnabled here (although this all worked on an older PhoneGap release, so I'm guessing they have it set up correctly)
Click to expand...
Click to collapse
In the WebBrowser properties.
CyberGhost636 said:
As for my user case - I was surprised to be the only guy on the internet with this methodology in place as well.
Click to expand...
Click to collapse
Of course you not "the only guy". I've tried to port/run a few HTML java-script based games on WP7 (Digger and couple more) more then year ago; they runs well with one HUGE exception - touch screen events are freezing scripts execution and make games not playable.
The "x-wmapp1:" URI scheme was what I was referring to. Not sure where that comes from, but I haven't done anything really with the WebBrowser control.
I have no knowledge of PhoneGap or Cordova; I assume they're "we write your app for you" frameworks? One would assume that such tools would know to set IsScriptEnabled, but you may have to do so manually. A bit of web searching on that direction may be fruitful - maybe earlier versions enabled scripting by default, and now it's disabled by default so you have to specify an option somewhere?
Injecting the script on navigation really doesn't require any major change to the server-side code. I mean, is sending
<script>window.external.notify('load localscript1.js')</script>
really much different from sending
<script type="text/javascript" charset="utf-8" src="x-wmapp1:/app/www/test.js"></script>
? If that's too different, you could instead send
<script src="http://yourserver.com/LoadLocalScripts.js"></script>
and put "LoadLocalScripts.js" on your server with the following code:
window.external.notify('load localscript1.js');
This has only a trivial increase in server traffic and load time, but lets you continue using external scripts instead of inline ones. Very little server-side change needed at all.
Now, the additional client-side code to support the window.external.notify and call InvokeScript... normally I'd say that's dead easy, because it is if you have any experience with the .NET framework, but in your case I get the feeling that this isn't so? I code to the framework, or to the underlying native code, and I tend to code "raw" (very little auto-generated code), so I'm not going to be able to help you solve the problems with a "make me an app" wizard unless I can see the code it generates for you.
For what it's worth, here's the approximate raw code that I'd use (it's over-simplified, but close enough):
void HandleNotify (String param) {
String[] parts = param.split(" ");
if (parts[0] == "load") LoadScript(parts[1]);
}
void LoadScript (String script) {
String content = Application.GetResourceStream(new Uri(script, UriType.Absolute)).ReadToEnd();
theBrowserControl.InvokeScript("eval", content);
}
void theBrowserControl_Loaded (...event handler args here...) {
theBrowserControl.IsScriptEnabled = true;
theBrowserControl.ScriptNotify += HandleNotify;
theBrowserControl.Navigate("http://yoursite.com");
}
the URI comes from Windows Phone itself, with this code, you can see for yourself:
var a = document.createElement('a');
a.setAttribute('href', '.');
alert(a.href);
also, I've been informed that this works in Cordova 2.0, so it might be a 1.8.1 bug... will try and see how it goes
thanks for your help so far!
Looks like it was a problem with PhoneGap 1.8.1 - after upgading to Cordova 2.0 (PhoneGap got renamed) it all works now... thanks for all the help!