Idea intellij “USB device not found” Android problem

Lately I’ve been really frustrated with this message. I don’t know when it has started to pop up, but every time I’m in the middle of important debugging, and want to restart the app I get this message when starting the app:

USB device not found

I’ve read bunch of blogs and stackoverflow questions and answers but nothing helped. Then I tried one very simple trick:

adb kill-server
adb devices

After that I’ve got this response:

* daemon not running. starting it now on port 5037 *
* daemon started successfully *
List of devices attached
37329B0B96FD00EC    device

After that intellij worked without problems.

Advertisement

Super easy iOS XML parsing

I just love it when you need something simple and easy that perfectly suits your needs. I needed some lightweight XML parser for iOS, and I found it.

To be honest (since I’m coming from java background), I didn’t quite fall in love with objective-c at first, and it seemed to be that I needed a lot more code to make some basic stuff work. For example XML parsing. NSXMLParser is ok, but it’s event driven (link #1, link #2). I wanted some dead simple DOM parser.

So the whole library is just two classes SMXMLElement and SMXMLDocument. To show you how simple it is to parse a file, here is a (reduced) snippet from my application:


- (void) parseData:(NSData *) {

   NSError *error;
   SMXMLDocument *document = [SMXMLDocument documentWithData:data error:&error];

   // check for errors
   if (error) {
   DDLogError(@"Error while parsing the document: %@", error);
   return nil;
}

// Array of objects that we are returning
NSMutableArray *result = [[NSMutableArray alloc] init];

// Get the videos node
SMXMLElement *videos = document.root;

// Go through every sub-element "video"
for (SMXMLElement *video in [videos childrenNamed:@"video"]) {
   VideoInfo *info = [[VideoInfo alloc] init];
   info.name = ;

   // Get other values from XML...
   [result addObject:info];
   [info release];
}

return result;
}

A shorter version of XML that the code above parses is:


<videos>
   <video>
      <name>Yup, this a name of a video</name>
   </video>
   <video>
      <name>And another one :)</name>
   </video>
</videos>

As you can see I’m only using (NSString*) valueWithPath:(NSString *) here, but there are a couple more


- (SMXMLElement *)childNamed:(NSString *)name;
- (NSArray *)childrenNamed:(NSString *)name;
- (SMXMLElement *)childWithAttribute:(NSString *)attributeName  value:(NSString *)attributeValue;
- (NSString *)attributeNamed:(NSString *)name;
- (SMXMLElement *)descendantWithPath:(NSString *)path;
- (NSString *)valueWithPath:(NSString *)path;

Do you really need anything else (in some small applications)? :)
Really awesome, kudos to the creators.