Of Code and Me

Somewhere to write down all the stuff I'm going to forget and then need

Setting child divider on an ExpandableListView causes weird flashing overlay on some Samsung phones November 29, 2011

Filed under: Android,Error — Rupert Bates @ 2:22 pm

This is a weird niche bug which I’m documenting here in case I need it in future.

Affected devices:
I have only seen it occur on a Samsung Galaxy S2 but I’m guessing it probably happens on any 2.x Samsung device running TouchWiz (it doesn’t happen on the Nexus S)

Steps to reproduce:
Create an activity with an ExpandableListView and set the childDivider property of the ExpandableListView to any colour, say red for ease of viewing


<ExpandableListView android:id="@+id/pageBundles"
                        android:layout_width="fill_parent"
                        android:layout_height="fill_parent"
                        android:childDivider="@color/red"
                        android:cacheColorHint="@color/white"/>

Now if you scroll the list for a while, particularly if you sort of wiggle it up and down quickly and then let it go the list will be completely covered by a solid block of the colour specified in the childDivider property. This will remain for a few seconds and then disappear.

To fix this issue just remove the childDivider property setting

 

Failure [INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES] error when trying to install an app in Android June 11, 2011

Filed under: Android,Error — Rupert Bates @ 8:34 pm
             Failure [INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES]

This error occurs when you try to install an app via ADB and there is already another version of the same app which was installed from a different development machine.

To get round it uninstall the previous version and rerun the install.

 

Motorola Xoom connects to wi-fi but not the internet – How to fix it May 7, 2011

Filed under: Android,Error,Xoom — Rupert Bates @ 9:01 am

I’ve recently got a Motorola Xoom tablet and when I first tried to connect to the internet at home was surprised and annoyed to find that although it would connect to my wifi no problem, it could not get an internet connection.

It seems that the problem lies in the DHCP interaction between the Xoom and my wireless router which results in the Xoom not picking up gateway information from the router. The solution was to configure a static IP address for the Xoom.

To do this do the following:

  • Go into Settings, then ‘Wireless & networks’ then ‘Wi-Fi settings’
  • Find your wi-fi network in the list and press and hold then select ‘Modify network’ from the pop up
  • Scroll down to the ‘IP settings’ drop down and switch it from DHCP to Static
  • In the ‘IP address’ box enter the same IP address which is shown higher up the same form
  • In the ‘Gateway’ box you will need to put the IP address of your router, to find this out I opened a command prompt window on a PC on the same network and typed ipconfig this will give you a Default gateway address which is what you need
  • In the the ‘Network prefix length’ box put 24 (this assumes the subnet mask from ipconfig is 255.255.255.0)
  • Finally in the ‘DNS 1’ box put the same IP you put in the Gateway box
Now click Save, disconnect and reconnect from the network and when you are reconnected you should have internet access.
Note: There has been some discussion around the save button being greyed out, resulting in the following:
“the save option is usually greyed out until you have entered your password at the top, network prefix, and dns 1. make sure you have entered these things or else it wont let you save. also make sure you have entered them and they are not just grey. “
 

java.net.UnknownHostException on Android – a list of possible causes February 22, 2011

Filed under: Android,Error,WebServices — Rupert Bates @ 3:54 pm

This is a list of possible solutions to the error:

     java.net.UnknownHostException: myapp.co.uk  at java.net.InetAddress.lookupHostByName(InetAddress.java:513)

when trying to access a website on Android.

They run from most to least likely, start at the top and work your way down:

  1. Check that you have <uses-permission android:name=”android.permission.INTERNET” /> set in your AndroidManifest.xml file (on the same level as application tag)
  2. If you are behind a proxy you may need to do the following:
    System.setProperty("http.proxyHost", "my.proxyhost.com");
    System.setProperty("http.proxyPort", "1234");
    
  3. If you are using an emulator try deleting and recreating the virtual device.
  4. If you are on a real device try switching the wifi on and then off again
  5. If it is something which happens once when an emulator or device boots but is ok later you could try ‘warming up’ the dns by running code such as the following before your own web request :
    try {
    InetAddress address = InetAddress.getByName(Url);
    } catch (UnknownHostException e) {
    e.printStackTrace();
    }
    
  6. Try rebooting your development machine – I’ve heard of this working

If none of the above work and you find another solution then let me know.

 

Error .apk.res not found In IntelliJ Idea Android project January 27, 2011

Filed under: Android,Error,Git,IntelliJ,Java — Rupert Bates @ 10:32 am

After pulling the latest source of an android project I am working on from GitHub I got the following error:


MyProject.apk.res not found. Try to rebuild project

But no amount of rebuilding would fix it.
It turned out that the problem was that somehow the Module had lost track of which Android platform it is targeted to. To fix it I did the following:

  1. Bring up the Project Structure dialog (File/Project Structure or ctrl+alt+shift+s)
  2. Make sure that Modules is selected in the Project settings pane (far left)
  3. Expand the node with the name of your project in the middle pane and click on the Android node underneath it. This selects the Android facet.
  4. At the top of the Facet pane there is a drop-down list which you can use to select your Android platform. If there are no entries in this you can create a new one by clicking ‘New’ and locating the directory your Android SDK is installed in.
  5. Click Ok and rebuild, the problem should now be fixed

It seems that the problem is caused by Git in some way, but I’m not exactly sure how yet. I’ll update here if I find out why.

 

error: value tools is not a member of package scala when using the scala console in IntelliJ IDEA October 20, 2010

Filed under: Error,IntelliJ,Scala — Rupert Bates @ 3:28 pm

If you get the following error whilst trying to use the scala console in Intellij IDEA:


<script>:3: error: value tools is not a member of package scala
var value: scala.tools.nsc.InterpreterSettings = _
^
<script>:4: error: value tools is not a member of package scala
def set(x: Any) = value = x.asInstanceOf[scala.tools.nsc.InterpreterSettings]
^
Exception in thread "main" java.util.NoSuchElementException: None.get
at scala.None$.get(Option.scala:185)
at scala.None$.get(Option.scala:183)
at scala.tools.nsc.Interpreter.bind(Interpreter.scala:622)
at scala.tools.nsc.Interpreter$$anonfun$quietBind$1.apply(Interpreter.scala:630)
at scala.tools.nsc.Interpreter$$anonfun$quietBind$1.apply(Interpreter.scala:630)
at scala.tools.nsc.Interpreter$$anonfun$beQuietDuring$2.apply(Interpreter.scala:171)
at scala.util.control.Exception$Catch.apply(Exception.scala:79)
at scala.tools.nsc.Interpreter.beQuietDuring(Interpreter.scala:169)
at scala.tools.nsc.Interpreter.quietBind(Interpreter.scala:630)
at scala.tools.nsc.Interpreter.recordRequest(Interpreter.scala:276)
at scala.tools.nsc.Interpreter.loadAndRunReq$1(Interpreter.scala:584)
at scala.tools.nsc.Interpreter.interpret(Interpreter.scala:597)
at scala.tools.nsc.Interpreter.interpret(Interpreter.scala:575)
at scala.tools.nsc.InterpreterLoop.reallyInterpret$1(InterpreterLoop.scala:471)
at scala.tools.nsc.InterpreterLoop.interpretStartingWith(InterpreterLoop.scala:514)
at scala.tools.nsc.InterpreterLoop.command(InterpreterLoop.scala:361)
at scala.tools.nsc.InterpreterLoop.processLine$1(InterpreterLoop.scala:242)
at scala.tools.nsc.InterpreterLoop.repl(InterpreterLoop.scala:248)
at scala.tools.nsc.InterpreterLoop.main(InterpreterLoop.scala:558)
at scala.tools.nsc.InterpreterLoop.main(InterpreterLoop.scala:609)
at org.jetbrains.plugins.scala.compiler.rt.ConsoleRunner.main(ConsoleRunner.java:33)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:115)

You can fix it as follows:

  1. From the ‘Run’ menu click ‘Edit Configurations’
  2. Select the Scala Console run configuration and type -usejavacp in the ‘ConsoleArgs’ box
  3. Click Apply

To make this the default for all Scala Console  run configurations

  1. right click on the top leve Scala Console icon and select ‘Edit Defaults’
  2. Type -usejavacp in the ‘ConsoleArgs’ box
  3. Click Ok

It should now work correctly

 

Run NServiceBus generic host as 32bit process on 64bit machine September 7, 2010

Filed under: Error,NServiceBus,Systems Administration — Rupert Bates @ 3:37 pm

I recently encountered the following error when deploying a service in the NServiceBus generic host (NServiceBus.Host.exe) on a 64bit machine,


System.InvalidOperationException: The 'Microsoft.Jet.OLEDB.4.0' provider is not registered on the local machine.

It turns out that this is actually a symptom of a problem which can show itself in a number of ways and is caused by running a service which depends on a 32bit dll (in this case the Microsoft Jet drivers) on a 64bit system in the generic host.

To fix it you can create a version of the generic host which is configured to run as 32bit as follows:

Run a visual studio command prompt and cd to the directory where NServiceBus.Host.exe is.  You will also need the NServiceBus.snk file from the NServiceBus download in the same directory so that you can resign the assembly after configuring it

At the command prompt type:

corflags /32BIT+ /Force NServiceBus.Host.exe

sn -R NserviceBus.Host.exe NServiceBus.snk

You can now deploy this version of the host onto your 64bit server and services which use it will run in 32bit mode