title: How to get rid of Android Verification Errors
body: <p>I'm using this method to get an array of BroadCast addresses.</p>
  
  <p>Some of the methods and Classes used are not present in the old API
  So i have added a version check at the beginning of the method.I'm trying to run this on a Android 1.6 Emulator and it fails with verify errors. </p>
  
  <pre><code>private InetAddress[] getBroadCast() throws SocketException
  {
  
      int currentapiVersion = android.os.Build.VERSION.SDK_INT;
      if (currentapiVersion &lt; 9)
      {       
          try {
              String ipString = getWifiIp();
              int loc = ipString.lastIndexOf(".");
              InetAddress baddrs[] = new InetAddress[1];
              baddrs[0] = new InetAddress.getByName(ipString.substring(0, loc)+".255");
              return baddrs;
          } catch (UnknownHostException e) {
              e.printStackTrace();
              return null;
          }
      }
              else{
      String bcast="";
      for (Enumeration&lt;NetworkInterface&gt; en = NetworkInterface.getNetworkInterfaces(); en.hasMoreElements();) {
          NetworkInterface intf = en.nextElement();
  
          for (InterfaceAddress address : intf.getInterfaceAddresses()) {
              if(address.getBroadcast()!=null) bcast=bcast+address.getBroadcast().toString().substring(1)+"::";
          }}
      String[] bcastarray= bcast.split("::");
      InetAddress baddrs[] = new InetAddress[bcastarray.length];
      for(int i=0;i&lt;bcastarray.length;i++)
          try {
              baddrs[i] = new  InetAddress.getByName(bcastarray[i]);
          } catch (UnknownHostException e) {
              e.printStackTrace();
          }
      return baddrs;
  }
   }
  </code></pre>
  
  <p>These are the errors that come up</p>
  
  <pre><code>10-12 11:38:22.030: W/dalvikvm(297): VFY: unable to resolve virtual method 4463: Ljava/net/NetworkInterface;.getInterfaceAddresses ()Ljava/util/List;
  10-12 11:38:22.030: W/dalvikvm(297): VFY:  rejecting opcode 0x6e at 0x0071
  10-12 11:38:22.040: W/dalvikvm(297): VFY:  rejected Lhello/BroadcastSend;.getBroadCast ()[Lhello/IPMAddress;
  10-12 11:38:22.040: W/dalvikvm(297): Verifier rejected class Lhello/BroadcastSend;
  10-12 11:38:22.040: W/dalvikvm(297): threadid=19: thread exiting with uncaught exception (group=0x4001aa28)
  </code></pre>
  
  <p>android.os.Build.VERSION.SDK_INT is available only from API Level 4 and up. I'm looking for a workaround for these issues</p>