Showing posts with label troubleshooting. Show all posts
Showing posts with label troubleshooting. Show all posts

Apr 26, 2015

Prevent Constant Security Popups on Genymotion with Google Play During ADB Installs

Problem

After installing Google Play services on Genymotion devices, I get a popup every time I try to install an APK. This popup prevents the adb install from completing until I either decline or accept. I've had this happen before but I keep forgetting how to turn it off. Googling doesn't help so I'm making this post for the next time I get into this mess.

Symptoms

A popup with the following message every time you try to install an app:

Allow Google to regularly check device activity for security problems, and prevent or warn about potential harm. Learn more in the Google Settings app.



Solution

Choose decline, then open the Google settings app (i.e. not the regular settings ... the other one. That's the key part I keep forgetting.) and turn off this option:

Scan device for security threats

Just to state the obvious, I think this is fine for an emulator but probably not something you want to disable on an actual phone that contains sensitive information. In that case, it's probably best to just "accept" the scanning, instead.

Apr 25, 2015

Upgrading to Google Play Services 7.0.0 Broke GCM

Problem

After upgrading from Google play services 6.5.87 to 7.0.0 I got compile errors in sections of code I hadn't touched.

Symptoms

I got errors similar to these:

  • error: package com.google.android.gms.gcm does not exist
    import com.google.android.gms.gcm.GoogleCloudMessaging;
  • error: package GoogleCloudMessaging does not exist
    if (GoogleCloudMessaging.MESSAGE_TYPE_MESSAGE.equals(messageType)) {
  • error: cannot find symbol
    GoogleCloudMessaging gcm = GoogleCloudMessaging.getInstance(this);

Solution

Simply put: add the GCM API to your gradle file:

Due to Dex limit issues, I stopped importing the full/bulky GooglePlayServices dependency the moment Google made that an option. Instead, I selectively compile the APIs that we need. It seems that version 7.0.0 of Google Play Services is a bit more modular than the previous one and more APIs have have been split out into individual packages.

So to fix this problem, all I had to do was add the new GCM api to my gradle build file. Compile errors went away and both the command-line and IDE builds were happy again!

compile 'com.google.android.gms:play-services-gcm:7.0.0'
As an added bonus, the "location" APIs have also been split out. After adding that, I was finally able to get rid of the play-services-base dependency that I previously relied on for the GCM & location packages.

Jun 28, 2013

Installing Genymotion for Mac OS X

Problem

After installing Genymotion, it doesn't work. Running the application gives errors and the shell script fails with segment faults.

Symptoms

  • The application fails with the following error: Unable to load VirtualBox engine
  • Accessing any device information from the shell script gives the following error: Segmentation fault: 11

Solution


UPDATE [7/15/13]: in addition to my initial post below, I just found some good information in the Genymotion docs. Not sure how I missed that the first time around. It covers everything in my post and more.

You need to download and install Oracle's VirtualBox from the VirtualBox site. Once this is installed and present in your Applications folder, Genymotion works!

It's easy to miss but on the Genymotion download page, it actually tells you that you need to download this. Of course, in my haste, I completely overlooked the underlined portion below:

Oops! It's also worth noting that I had problems registering on their website--it refused to send me a confirmation email. Once I switched from Chrome to Safari, it worked just fine. Now, I finally have Genymotion working and all is right with the world.

Mar 30, 2013

Android Robolectric: java.lang.RuntimeException: Stub! while using libraries like JSONObject

Problem

While running a unit test under Robolectric on Android, the following error occurs:
java.lang.RuntimeException: Stub!

Symptoms

  • When you step through the code, portions of it work just fine
  • The exception occurs after returning from a constructor
  • Some library code is being used, like JSONObject

Solution

As stated in the Robolectric help documentation:

Make sure that robolectric and its dependencies (including JUnit) appear before the Android API jars in the classpath.

In other words, assuming you set things up correctly, then from that point forward, all you have to do is be sure that your classes are coming from either Robolectric or pure Java. In my case, the code under test was using JSONObject and that was coming from the android jar. To fix this, I had to:


  1. Add the JSONObject jar to my test project's dependencies. Depending on how your project is setup, that could be as simple as copying it to the lib folder
  2. Re-order the dependencies in the classpath such that Roboelectric and the other Java jars appear before anything Android-related. In Eclipse, that looks like this:

In this case, I pulled Robolectric and JSON up to the top and pushed android and maps down to the bottom. After this change, my test worked perfectly.

Mar 29, 2012

Arrow Keys and Backspace stop working in Flash Builder or Eclipse

I just ran into a problem SO annoying, I had to stop EVERYTHING and write down how to fix this, immediately. That way, the next time it happens, I won't pull the rest of my hair out!

Problem

Suddenly, the arrow keys and backspace button stop working in Flash Builder or Eclipse.

Symptoms

  • Arrow keys don't work in Flash Builder
  • Arrow keys work fine in other applications
  • Backspace key does nothing
  • Opening and closing Flash Builder or Eclipse doesn't necessarily fix the problem.

Solution

It's odd but to fix this, you just have to click every mouse button. For me, the problem went away as soon as I left-clicked.

I found the solution here:
http://board.flashkit.com/board/showthread.php?t=798172

Where the problem is described as:

"It seems to be a mouse driver issue. Sometimes the program will register one of the mouse buttons as stuck. To fix it, I have to press each button until it works again.

Apparently it was fixed in the new eclipse, but flex which is based off eclipse never fixed this bug."

Mar 24, 2012

Slow Mac WiFi but Internet Fine on PC?

Occasionally, my internet gets REALLY slow on my laptop. Then I go use my wife's PC and everything is fine. Since few things are more aggravating than Windows machines working better than Macs, I decided to post this solution so I won't forget it.

Problem

MacBook Pro internet is slow over wifi and ethernet.

Symptoms

  • After opening several tabs, they all show no content--just perpetual spinning
  • Things worked fine for a few seconds, then suddenly, everything is slow
  • You see none of these issues on your Windows machine on the same network
  • You do not have this issue on your mobile phone or tablet, using WiFi

Solution

Add DNS servers in "System Preferences > Network" under the "Advanced" options. By default, my settings were pointing to Comcast. Once I added Open DNS, instead, everything worked fine.


As an added bonus, you can create an account at opendns.com and get some pretty cool features.

Mar 3, 2011

Recovering Lost Data In Safari

While trying to recover lost data typed into a web page on Safari, I stumbled across this forum and one response was worth remembering for later:
"If you wish to open cache.db you'd use the sqlite3 command.
It comes with your mac and it's easy to use if you know SQL.
Open Terminal an type in:
"cd ~/Library/Caches/com.apple.Safari;sqlite3 cache.db".
it'll open up the database and you can type ".tables" to show
the table names  then ".output FILENAME" 
then "select * from TABLENAME;" and it'll output to the
desired file you could do "foo.txt" as the file name. I have
3 tables, cfurl_cache_blob_data, cfurl_cache_schema_version,
cfurl_cache_response, in it so i did the steps three times
starting with the .output command for three separate files..."
This is a handy way to search through your old safari data by dumping everything in a file and then grepping the contents. The exact commands I used to accomplish this were:
cd ~/Library/Caches/com.apple.Safari
sqlite3 cache.db
.output temp.txt
select * from cfurl_cache_blob_data;
It's kind of surprising to see what's actually in your cache! I had no idea that the pages I surf were being stored to this extent. Turned out to be very handy.

But scary.

Other useful commands:

.help
.schema cfurl_cache_blob_data
.exit

Sep 16, 2010

Subclipse / SVN Working copy locked - Solution

Problem

I could not update or commit a certain folder in my subversion project using subclipse in eclipse.

Symptoms

Both commit and update failed with the error:

svn: Working copy 'path/to/folder/that/was/not/working' locked; try performing 'cleanup'

I also got warnings that the directory was not under version control.

To get this problem, I had copied files from one project to another (in the file system not in subclipse). Although I deleted the .svn directory after copying, I still ran into this issue.

Solution

On the command line, cd to the project directory and run svn cleanup as in:

cd path/to/folder/that/was/not/working
svn cleanup

The problem should go away!

Jul 15, 2010

Maven - Sun JAR Issues (javamail, jms, jmx, jdmk, persistence)

Problem

Compiling fails because of dependencies related to Sun, such as javamail, jms, jmx. These failures have some of the symptoms listed below.

Background. Many of Sun's Java projects do not have licenses that allow for redistribution. Basically, their stuff is somewhat "locked down." To get it, you have to click through a Software License Agreement; meaning, their libraries can, at times, be a pain to download. Historically, their JARs have not been in public Maven Repositories. As such, Maven tends not to automatically download Sun dependencies. Nowadays, they are available in the default repository . . . supposedly. However, over here IN REALITY, that doesn't really work.

If you have "Maven: The Definitive Guide," read page 73 under the section "Adding J2EE Dependencies" for related information.

Symptoms

Some symptoms of this problem I saw while trying to solve it include:

  • Failed to resolve artifact
  • Missing:
    ----------
    1) javax.persistence:ejb:jar:3.0-public_review
  • [INFO] Unable to find resource 'javax.persistence:ejb:jar:3.0-public_review' in repository JBoss Repository (https://repository.jboss.org/nexus/content/groups/public/)
  • error: error reading /Users/keving/.m2/repository/com/sun/jdmk/jmxtools/1.2.1/jmxtools-1.2.1.jar; cannot read zip file
  • error: error reading /Users/keving/.m2/repository/javax/mail/mail/1.4.1/mail-1.4.1.jar; cannot read zip file
  • error: error reading /Users/keving/.m2/repository/com/sun/jmx/jmxri/1.2.1/jmxri-1.2.1.jar; cannot read zip file
  • [INFO] Unable to find resource 'javax.jms:jms:jar:1.1' in repository central (http://repo1.maven.org/maven2)
  • [INFO] Unable to find resource 'javax.persistence:ejb:jar:3.0-public_review' in repository maven.springframework.org (http://maven.springframework.org/snapshot)
  • [INFO] Unable to find resource 'javax.persistence:ejb:jar:3.0-public_review' in repository central (http://repo1.maven.org/maven2)
  • Failed to resolve artifact. com.sun.jmx:jmxri:jar:1.2.1
  • Failed to resolve artifact. com.sun.jdmk:jmxtools:jar:1.2.1
  • Solutions

    I recommend solution 4, below. After an hour or two of Googling, reading and learning, my final course of action (Solution 4) was to first delete all the troubled Sun dependencies, then painstakingly download the right JARs directly from Sun/Oracle and install them in the local repository. Below, I have listed all the useful solutions I found and tried during my journey to finding a complete repair.

    Solution 1 - Fastest, Easiest Fix

    Simplest solution: change just one character in the POM fille... use version 1.2.14 instead of 1.2.15. So the log4j dependency section
    changes FROM:

    <dependency>
    <groupid>log4j</groupid>
    <artifactid>log4j</artifactid>
    <version>1.2.15</version>
    </dependency>

    TO:

    <dependency>
    <groupid>log4j</groupid>
    <artifactid>log4j</artifactid>
    <version>1.2.14</version>
    </dependency>

    Solution 2 - Quick Fix

    Next simplest solution: exclude Sun jars by adding the following exclusions to the Log4j dependency within the pom.xml file:

    Solution 3 - Ideal Fix (didn't work for me)

    Best Solution (but doesn't work...or at least I can't get it to work): Use the special repositories provided by Sun: add to POM.xml

    Supposedly, this repository is provided by Sun and contains the missing jars. Each one has a "Reference Implementation" of the underlying API. Somehow, this allows for a looser license so the code can be redistributed without clicking through an SLA. When I tried this, it only successfully installed 1 of the JARs--javamail.

    Solution 4 - Thorough Repair (my choice)

    This is the longer, yet more complete solution--get the actual jars from Sun/Oracle. I kept track of all the little things I did and listed them below, keeping as many things "cut and pasteable" as possible. These are the steps I took and the commands I happened to run along the way:

    Delete the jars from the local repository:

      rm -rf ~/.m2/repository/javax/persistence/ejb/
      rm -rf ~/.m2/repository/javax/jms
      rm -rf ~/.m2/repository/javax/mail
      rm -rf ~/.m2/repository/com/sun/jdmk
      rm -rf ~/.m2/repository/com/sun/jmx

    run maven again (at least to the compile phase) to see exactly which jars fail.

    cd [top-level project directory with pom.xml]
    mvn assembly:directory -Dmaven.test.failure.ignore=true

    then download any remaining, missing JARs directly from SUN. Here are the detailed steps I took, grouped by each type of jar. The exact links may change over time but the basic steps should be the same. Note that the jdmk and jmx jars both come in one download.

    JMS

    1. click here to download the JMS jar from Sun/Oracle, accept the Software License Agreement and download the jar
    2. unpack the zip archive (automatic on my machine to directory ~/Downloads)
    3. cd to the lib directory
    4. cd ~/Downloads/jms1.1/lib/
    5. install the jms jar into the local maven repository, using the following command

    JDMK - JMX Tools and/or JMXRI

    1. click here to download the JDMK jar from Sun/Oracle, accept the Software License Agreement and download the jar
    2. (Found on Sun's Java SE page for the JDMK/JMX project by choosing Download" under the "BINARY DOWNLOAD" section under "JMX 1.2.1 Reference Implementation")
    3. This zip will include jars for both jmxtools and jmxri. Unpack the archive(automatic on my machine to directory ~/Downloads)
    4. cd to the lib directory
    5. cd ~/Downloads/jmx-1_2_1-bin/lib/
    6. install both jars into the local repository, using the following commands

    Persistence

    1. click here to access the javax.persistence jar from sourceforge
    2. unpack the archive (automatic on my machine to directory ~/Downloads)
    3. cd to the lib directory
    4. cd ~/Downloads/hibernate-annotations-3.1beta5/lib/
    5. install the javax persistence jar into the local maven repository, using the following command

    JavaMail

    Java mail is now open source so you shold be able to pull it from the default Maven repository. If not, try adding Sun's repository (Solution 3) and seeing if that will pull down the javamail jar. Be sure to completely delete the javamail directory (~/.m2/repository/javax/mail) before running this.


    Summary / Tradeoffs

    Each solution I found, I didn't quite like for different reasons. Solution 4 was the first satisfying choice. Each of the previous approaches involved tradeoffs. The first one downgrades to an earlier version of Log4j and, clearly, they moved to 1.2.15 for a reason.. Maybe there are security patches. Maybe the difference is negligable. Either way, I don't want to deal with figuring it out. So, Solution 1 would be the quick and dirty fix I'd use a coworker who needed to get their environment working in a hurry but it's not something I'd choose as a long-term fix. Solution falls into a similar boat. I like that it doesn't downgrade, but it cuts out dependences that are probably there for a reason. Most of what I read indicated that those libraries are virtually unused. Still, to me, there their for a reason so although I'd prefer solution 2 over solution 1, I wouldn't use it long-term, either. Solution 3 didn't work for me. The claim was that this repository had all the magic jars required but it didn't turn out that way. Upon download, two of them failed the checksum--I couldn't figure out why--and the other two jars didn't appear to be in the repository at all. In fact, it seemed that the only thing I could get, error-free, was the javamail jar. Not good enough.

    Finally, the fourth solution allowed Log4j to remain at the latest version and keep all it's dependencies. Admittedly, it was far more tedious and took me about 20 minutes to complete. Hopefully, this detailed post will greatly reduce that time for at least one person out there. If that person is you, I hope you can have your cake (a complete solution) and eat it too (a quick solution)! Celebrate.

    May 20, 2010

    Uninstall MySQL on Mac OS X (Leopard 10.5 or Snow Leopard 10.6)

    Problem

    You need to completely remove mysql from your system as easily as possible.

    Symptoms

    You want to do a clean delete and a fresh install because you don't want to deal with errors such as:
    • MySQL [your version] for Mac OS X can't be installed in this disk. A newer version of this software already exists on this disk.
    • [ERROR] Can't open the mysql.plugin table. Please run mysql_upgrade to create it.
    • [ERROR] Fatal error: Can't open and lock privilege tables: Table 'mysql.host' doesn't exist

    Solution

    Execute the following commands that I found here and here:
    sudo rm /usr/local/mysql
    sudo rm -rf /usr/local/mysql*
    sudo rm -rf /Library/StartupItems/MySQLCOM
    sudo rm -rf /Library/PreferencePanes/My*
    edit /etc/hostconfig and remove the line MYSQLCOM=-YES-
    sudo rm -rf /Library/Receipts/mysql*
    sudo rm -rf /Library/Receipts/MySQL*
    sudo rm -rf /var/db/receipts/com.mysql.*
    
    Maybe one day, if I'm feeling frisky, I'll come back and write a bash script to remove the MYSQLCOM line auto-magically. Maybe some magic involving sid or awk or something.

    May 7, 2010

    Fix Pixelbender Shader Compile Errors

    Today, I had a small pixelbender issue that I faced once before and forgot about it until I found the solution. Since this is the second time I've faced this, I decided to record the solution here.

    Problem

    Flex code, related to PixelBender, isn't compiling.

    Symptoms

    In Flex Builder / Flash Builder, I get the following errors:

    • 1046: Type was not found or was not a compile-time constant: Shader.
    • 1046: Type was not found or was not a compile-time constant: ShaderFilter.
    • 1172: Definition flash.display:Shader could not be found.
    • 1172: Definition flash.filters.ShaderFilter could not be found.
    • 1180: Call to a possibly undefined method Shader.
    • 1180: Call to a possibly undefined method ShaderFilter.

    Solution

    Clearly, these errors make no sense because both Shader and ShaderFilter are built-in classes distributed with Flash. Luckily, the solution is simple--you have to adjust your target Flash Player version. Make sure it's at least version 10:
    1. Right click your project and choose properties
    2. Go to the Flex Compiler section
    3. At the bottom, in the HTML wrapper section, check the Require Flash Player version box (which requires the Generate HTML wrapper file box to be checked)
    4. Enter at least version 10.0.0
    5. Celebrate!
    That's it. Here's a picture!

    Feb 11, 2010

    Mac OS X : Open Ports, Network Connections, PIDs

    Yesterday, my MacBook Pro was acting VERY strangely. I was hacked! (or so I thought) I feared that some evildoer hacked my home network and ran amuck.

    Quickly, I had to figure out what was happening on my network. I wanted to know what ports were open, what connections were live and which applications were using those connections. Finding Linux info was easy. Mac OS X info? Not so much!

    After hunting dozens of Google pages, here's what I've come up with:

    Check All Network Connections
    Run the following shell command to display all network connections:
    netstat -an | grep 'LIS\|WAIT\|Recv-Q'

    This will show all ESTABLISHED, LISTEN and TIME_WAIT connections and also displays the header for convenience.
    Show Processes On Network
    The command above is good but it doesn't show you WHO is on those ports. The following allows us to see the PID and Name of each process using the network!
    sudo lsof -Pnl +M -i

    Note: the first flag is -PNL (the last character is not a one). The first time I ran the lsof command, I couldn't see the ports that were listening. This was my main concern (evildoers love listening on ports). The key is to run this command as root (via sudo). Also note, with the netstat call, you can use egrep 'LIS|WAIT'. Honestly, I haven't gotten around to learning what egrep does. All I know is you don't have to escape the | symbol with egrep.