Android: java.lang.RuntimeException: Unable to instantiate activity ComponentInfo
When trying to launch our android application onto the emulator through eclipse, i get the following error:
04-05 15:12:24.082: E/AndroidRuntime(386): FATAL EXCEPTION: main
04-05 15:12:24.082: E/AndroidRuntime(386): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{org.sheriff/org.sheriff.BizTownActivity}: java.lang.ClassNotFoundException: org.sheriff.BizTownActivity in loader dalvik.system.PathClassLoader[/data/app/org.sheriff-2.apk]
04-05 15:12:24.082: E/AndroidRuntime(386): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1739)
04-05 15:12:24.082: E/AndroidRuntime(386): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1831)
04-05 15:12:24.082: E/AndroidRuntime(386): at android.app.ActivityThread.access$500(ActivityThread.java:122)
04-05 15:12:24.082: E/AndroidRuntime(386): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1024)
04-05 15:12:24.082: E/AndroidRuntime(386): at android.os.Handler.dispatchMessage(Handler.java:99)
04-05 15:12:24.082: E/AndroidRuntime(386): at android.os.Looper.loop(Looper.java:132)
04-05 15:12:24.082: E/AndroidRuntime(386): at android.app.ActivityThread.main(ActivityThread.java:4123)
04-05 15:12:24.082: E/AndroidRuntime(386): at java.lang.reflect.Method.invokeNative(Native Method)
04-05 15:12:24.082: E/AndroidRuntime(386): at java.lang.reflect.Method.invoke(Method.java:491)
04-05 15:12:24.082: E/AndroidRuntime(386): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:841)
04-05 15:12:24.082: E/AndroidRuntime(386): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:599)
04-05 15:12:24.082: E/AndroidRuntime(386): at dalvik.system.NativeStart.main(Native Method)
04-05 15:12:24.082: E/AndroidRuntime(386): Caused by: java.lang.ClassNotFoundException: org.sheriff.BizTownActivity in loader dalvik.system.PathClassLoader[/data/app/org.sheriff-2.apk]
04-05 15:12:24.082: E/AndroidRuntime(386): at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:251)
04-05 15:12:24.082: E/AndroidRuntime(386): at java.lang.ClassLoader.loadClass(ClassLoader.java:540)
04-05 15:12:24.082: E/AndroidRuntime(386): at java.lang.ClassLoader.loadClass(ClassLoader.java:500)
04-05 15:12:24.082: E/AndroidRuntime(386): at android.app.Instrumentation.newActivity(Instrumentation.java:1022)
04-05 15:12:24.082: E/AndroidRuntime(386): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1730)
04-05 15:12:24.082: E/AndroidRuntime(386): … 11 more
After searching through StackOverflow and Google. I couldn’t come up with an answer. For some reason I had a look at my .classpath file and noticed something:
<?xml version=”1.0″ encoding=”UTF-8″?>
<classpath>
<classpathentry kind=”src” path=”gen”/>
<classpathentry kind=”con” path=”com.android.ide.eclipse.adt.ANDROID_FRAMEWORK”/>
<classpathentry kind=”con” path=”com.android.ide.eclipse.adt.LIBRARIES”/>
<classpathentry kind=”output” path=”bin/classes”/>
</classpath>
If you look closely you’ll notice that there isn’t a classpathentry for src directory itself where org.sheriff.BizTownActivity is located. I changed the .classpath to reflect the src path:
<?xml version=”1.0″ encoding=”UTF-8″?>
<classpath>
<classpathentry kind=”src” path=”src”/>
<classpathentry kind=”src” path=”gen”/>
<classpathentry kind=”con” path=”com.android.ide.eclipse.adt.ANDROID_FRAMEWORK”/>
<classpathentry kind=”con” path=”com.android.ide.eclipse.adt.LIBRARIES”/>
<classpathentry kind=”output” path=”bin/classes”/>
</classpath>
and it worked!!!
Disable the github issue tracker. Use pull requests instead?
Why is it that github even has an issue tracker? Doesn’t it make more sense to have bug reports and enhancement requests submitted through pull requests?
Think about it for a moment:
How many times has someone filed a bug report giving you little or unclear information. Now you have to waste your time trying to contact the person to get more specific information. This could have been totally avoided if the person would have written a failing test demonstrating the bug in the first place.
How many enhancement requests have you’ve gotten that, though seemed like a good idea, required an enormous amount of effort or was something that a single person needed. Why didn’t the requester take the time to code the enhancement so as to not consume the time of the project author(s)?
As an experiment I’m going to do this with the new project I’ve started. I’m hoping that by removing the issue tracker it will encourage more people to step out of their comfort zone and participate.
ColdFusion 9 64-bit / IIS7.5 / Windows 7 / 500 error
Quick note about setting up ACF9 on Windows 7 and IIS 7.5. In order to get everything working, you need to install the following:
http://download.macromedia.com/pub/coldfusion/cf9_installer/ColdFusion_9_WWEJ_win64.exe
http://download.macromedia.com/pub/coldfusion/updates/901/ColdFusion_update_901_WWEJ_win64.exe
http://helpx.adobe.com/coldfusion/kb/cumulative-hot-fix-2-coldfusion-1.html
In other words, you need to install the base install, the CF 9.0.1 update and the CF 9.0.1 Hot Fix 2. The Hot Fix is probably the most important as if you only install the base and then the update, you will receive a 500 error when trying to access any site running CF especially the CF Administrator.
ASP.net MVC images from virtual directory
Here is something that stumped us for a while. At work we were converting a legacy asp site over to ASP.net MVC. The old site got it images from two virtual directories mapped to a file share on another server. When we went to deploy the new site, we created the virtual directories, however we kept on getting ASP.net error when trying to access any of the images!
Turns out that in order to use a virtual directory under as ASP.net MVC application, you need to make sure that after you create the virtual directory, you convert it to an application.
Apparently without doing this, IIS thinks that the virtual directory is part of the ASP.net MVC application and when requests to the virtual directory come it, the ASP.net MVC routing takes over which was causing the error. By converting it to an application, you remove the virtual directory from the ASP.net MVC application entirely.
RailsTutorial.org problems
below are some of the problems I’ve been having while following the railstutorial.org screencasts. These are in no particular order and may only pertain to my system, but I thought that I would document them here in case others run into them. Also, I’m going by the information that is provided in the screencasts themselves. During the screencasts, there are several time where the author refers to the online book in order to get the proper configuration. Most people are not going to take the time to search through the book to get the proper configuration to follow along in the screencasts. Hopefully this post will help people along when following the screencast and prevent them from having to refer to the book.
Lesson 1
when pushing to heroku, you will receive the following error:
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
/usr/local/bin/ruby extconf.rb
checking for sqlite3.h… no
sqlite3.h is missing. Try ‘port install sqlite3 +universal’
or ‘yum install sqlite-devel’ and check your shared library search path (the
location where your sqlite3 shared library is located).
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers. Check the mkmf.log file for more
details. You may need configuration options.
basically this means that heroku couldn’t compile the sqlite gem. You Gemfile should have the following in it if you’re following along:
source 'https://rubygems.org' gem 'rails', '3.2.5' # Bundle edge Rails instead: # gem 'rails', :git => 'git://github.com/rails/rails.git' gem 'sqlite3' # Gems used only for assets and not required # in production environments by default. group :assets do gem 'sass-rails', '~> 3.2.3' gem 'coffee-rails', '~> 3.2.1' # See https://github.com/sstephenson/execjs#readme for more supported runtimes # gem 'therubyracer', :platforms => :ruby gem 'uglifier', '>= 1.0.3' end gem 'jquery-rails' # To use ActiveModel has_secure_password # gem 'bcrypt-ruby', '~> 3.0.0' # To use Jbuilder templates for JSON # gem 'jbuilder' # Use unicorn as the app server # gem 'unicorn' # Deploy with Capistrano # gem 'capistrano' # To use debugger # gem 'debugger'
To fix, you need to make it so that the sqlite gem is not installed in production. to do this add change the `gem ‘sqlite3′` line in your Gemfile to the following:
gem 'sqlite3', :group => [:development, :test]
Lesson 3
When running the tests from with ruby you receive the error `/bin/sh: rspec: command not found` Basically this is cause because you having started SublimeText from the command line and don’t have `~/bin` in your path. To add `~/bin` to your path open up your .bash_profile file in an editor. WARNING! During the installation tutorial, you installed RVM so that you can manage your ruby installation. This causes a major problem because creating a `.bash_profile` to allow you to edit your path will cause rvm to break, which will result in rails to break. In order to prevent this, YOU MUST run the rvm script from within your `.bash_profile`. Below is a fixed path and script for your .bash_profile:
export PATH=/opt/local/bin:/opt/local/sbin:$HOME/bin:$PATH [[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm"
Depending on the installation of your system, your path could contain a bunch of stuff. Don’t worry what it looks like, just make sure you add `$HOME/bin` to the end. Now close and reopen the Terminal. Next follow the instructions here to link the `subl` executable to by issuing the following command in the Terminal window:
ln -s "/Applications/Sublime Text 2.app/Contents/SharedSupport/bin/subl" ~/bin/subl
After that, you should be able to open SublimeText from a command prompt by doing `subl .`
subl .
Now when you run RubyTests it will be able to find rspec and work.
Lesson 10
The css for the micropost is located at Listing 10.24.
CFWheels and implementing a Service Layer
A couple of weeks ago Doug Boude (rhymes with loud) authored a post about providing a service layer in CFWheels. I’m not going to go into what a service layer is or the use of it. If you want to know that, check out his post here.
Personally I never saw I use for this before. In keeping with the MVC tradition of doing thing, I always felt that these `services` could live in the model layer. However I absolutely love when people make me fall on my sword and I can clearly say that a service layer is definitely something that is needed in CFWheels. I still wouldn’t go so far as using it with a DI like WireBox, but who knows if I’ll change my mind about that later in life as well.
Following Doug’s post, I was able to implement a service layer with ease. The issue I had with his approach though was that it made testing very awkward. Having the initialization of the service layer living in the controller init method, made it a little hard to test, not impossible mind you, but a little harder then it should have been.
After giving it some thought, I figured out a way to not only make it so that the services initialized when CFWheels booted, but also was able to make the service() method global so that you can easily test against it.
If you take a look at this gist I created you’ll see the changes I made. Basically all I did was move his initServices() method into the events/onapplicationstart.cfm file and move the service() method into the events/functions.cfm file. The big change I made though was to the initServices() method so that it would automatically initialize any new services that you add to the services directory.
By putting these methods into their new homes, the services are loading once when CFWheels boots as apposed to every time a controller is created and also you’re able to access the service() method from anywhere in your application which make it easy to call in tests.
rvm install 1.9.3 fails: truncated tar archive
installing ruby 1.9.3 via rvm and it fails with `trucated tar archive` which you can see by going doing `more ~/.rvm/log/ruby-1.9.3-p194/extract.log`.
the simpliest way to fix this is to uninstall rvm and reinstall. you can uninstall rvm by doing `rvm implode` and install by following the installation instructions: https://rvm.io/rvm/install/
xcode 3.2.6 installation failed: CSSMERR_TP_CERT_EXPIRED
when installing xcode 3.2.6 on OS X 10.6.6 (Hazard) the installation might fail with the following error when viewing the /var/log/install.log CSSMERR_TP_CERT_EXPIRED. this is because obviously the certificate has expired and xcode can’t verify that the certificate is valid.
a quick and easy solution is to change your system data to 1/1/2012 and then perform the install.
http://stackoverflow.com/questions/9953835/xcode-3-2-3-installation-failed-on-mac-10-6-3
Pitfalls with jQuery Mobile and how to over come them
At work I’ve been tasked with creating a mobile app using jQuery Mobile and Phonegap. Needless to say, I’ve had nothing but issues. Below are some of the pitfalls that I’ve been running into and how to over come them. This post is a work in progress and I will add to it as things come up.
1) When creating additional pages, ONLY include the `data-role=”page”`.
First, let me explain what I mean by data-role=”page”. When you create your index.html for your jQuery Mobile project, you set it up like so:
<!– index.html –>
<!DOCTYPE html>
<html>
<head>
<title>My Project</title>
<meta name=”viewport” content=”width=device-width, initial-scale=1″/>
<link rel=”stylesheet” href=”css/jquery.mobile-1.1.0.min.css” />
<script type=”text/javascript” charset=”utf-8″ src=”js/jquery-1.7.1.min.js”></script>
<script type=”text/javascript” charset=”utf-8″ src=”js/jquery.mobile-1.1.0.min.js”></script>
<script type=”text/javascript” charset=”utf-8″ src=”js/phonegap-1.4.1.js”></script>
</head>
<body>
<div data-role=”page” id=”home”>
<div data-role=”header”>
<h1>Your header</h1>
</div>
<div data-role=”content”>
<p>The content goes here</p>
</div>
<div data-role=”footer”>
<p>The footer goes here</p>
</div>
</div>
</body>
</html>
Notice that we have our opening html tag, our head section with all our stylesheets and javascript includes, our opening body tag, our page div (containing the head, content and footer of the page), our closing body tag and closing html tag. This is standard when creating a html page and something we’re all use to.
Now let’s say you want to create another page called search.html. You would think that you would need to copy the head section, body and html tags to the search.html page, but THIS IS WRONG! All the search.html page would contain is the page div like so:
<!– search.html –>
<div data-role=”page” id=”search”>
<div data-role=”header”>
<h1>Search</h1>
</div>
<div data-role=”content”>
<p>The form used to search</p>
</div>
<div data-role=”footer”>
<p>The footer goes here</p>
</div>
</div>
The reason for this is that jQuery Mobile will inject the search.html page’s content into the index.html via ajax. Because of this, if you put the html, head, and body tags into your search.html page, they will get duplicated. This can cause all sorts of issues that I won’t even go into. Just remember that you only need the html, head and body tags on the index.html page.
2) Disable ajax caching globally
Supposedly in jQuery Mobile disabled ajax caching of pages in 1.1.0. However, I was still having issue with the pages being cached so this was making development a real pain. Luckily you can disable ajax caching altogether by doing:
<script>
$.ajaxSetup ({
// Disable caching of AJAX responses
cache: false
});
</script>
Just put that in your head section on your index.html page and you should be golden.
3) Multiple events firing
This was a HUGE pain in the ass. You normally see this problem when submitting a form from one page to another. On the calling page, you might have some javascript that is bound to an event (like pageshow) that generates some dynamic content after doing an ajax call. If you look in your Net tab in firebug, you’ll notice that the ajax call will increment with each visit. So on the first visit it fires once, the second visit it fires twice and so on. The reason for this is because, again, of the way jQuery Mobile pulls in pages via ajax. Because it will pull the page in for each visit, it will continually add the code you want to run to the event stack on each visit.
Now I’ve seen people try to solve this by placing the code in the `pageinit` event since that only fires the first time the page in pulled via ajax, but this doesn’t work when you’re having to create dynamic content based on a search string.
The solution is quite simple once you think about it, just put your code on the index.html and delegate using the on() method. so for instance, if you have page with an id of `search` and you want to run an ajax request to get the results, you would do:
$(document).on(‘pageshow’, ‘#search’, function(){
// add code to get the search results via ajax here
});
Personally I would recommend that you put all the javascript code for your app in a js file and include that on your index.html page.
4) When inserting dynamic content into the DOM you must call trigger(‘create’) in order for the framework to apply the styling.
For my app, I have a function that automatically add pagination buttons (previous and next) to the footer. In my template the footer is just defined plainly:
<div data-role=”footer”></div>
In my javascript code, I add the pagination by calling the html() method on the footer object (code is summarized):
var loc = {};
loc.self = $(this);
loc.footer = $(‘[data-role="footer"]‘, loc.self);
loc.footer.html(pagination(loc.params.page, loc.results.PAGES));
The issue was that none of the styling was taking affect on the footer and the prev and next button were showing up as just links. I found in the jQuery Mobile form that you should call page() on the object after altering it, but this really didn’t work. After some more search I found that what I really need to do was call trigger(‘create’) on the object instead. the nice thing is that you can chain this after the html() call and it still works:
loc.footer.html(pagination(loc.params.page, loc.results.PAGES)).trigger(‘create’);
5) When creating a dynamic listview and inserting content into it, you need to call listview() and then listview(‘refresh’) to reapply the styling.
This is basically the same problem as #4 only this time we’re dynamically creating a listview an inserting content into it. In my app, I use Liquid as a templating language as it’s just making life soooo much easier then concatenating javascript strings. So to create my list view, I have it defined in my Liquid template like so:
<script type=”text/liquid” id=”arrestSearchResults-markup”>
{% if RESULTS.size %}
<ul id=”arrestSearchResults-listview” data-role=”listview”>
{% for item in RESULTS %}
<li>
<a href=’{{LINK}}&jms_number={{item.JMS_NUMBER}}’ class=’arrestSearch-details’>
<img src=’{{item.PHOTO_THUMB}}’ />
<h3>{{item.LAST_NAME}}, {{item.FIRST_NAME}} {{item.MIDDLE_NAME}}</h3>
<p>{{item.JAIL}}</p>
</a>
</li>
{% endfor %}
</ul>
{% else %}
<h3>No records found</h3>
{% endif %}
</script>
The target content div is defined plainly, just like my footer is in #4:
<div data-role=”content”></div>
to compile the template and insert it into the content div, I do the following in my code (code is summarized):
var loc = {};
loc.self = $(this);
loc.markup = $(“#arrestSearchResults-markup”).html();
loc.target = $(‘[data-role="content"]‘, loc.self);
// render the markup to the listview
loc.target.html(Liquid.Template.parse(loc.markup).render(assigns));
// refresh the listview
loc.target.find(‘ul’).listview();
loc.target.find(‘ul’).listview(‘refresh’);
Basically what I’m doing is getting the template markup and the content div and putting them into a variables. I then compile the Liquid template and pass in the assigns object that contains the information to render the template.
The key to all of this is the next two lines which finds the unsorted list (‘ul’) which contains the listview a just injected into the content div and calls listview() on it, this tell jQuery Mobile to treat the ul as a listview object. I then call listview(‘refresh’) to have the framework apply the styling to it.
6) When performing validation on a form, the form will still submit.
Here is the setup. You have a form and you’re trying to perform some sort of validation on it when the form is submitted and show the visitor some errors. You tie your validation to the form’s submit event using submit() and include event.preventDefault() good measure when any error occur. However, the form still submits even though errors are through, the event.preventDefault() does prevent the form from not submitting. Heck, you even throw in `return false` hoping the form won’t submit, but it still does.
The issue is that the form is being submitting via ajax and you can’t stop the ajax submission from happening through standard means. The only thing you can do is turn off ajax and submit the form yourself. Now in older versions of the framework, you could turn off ajax for form submissions separately, however in the latest version (1.1.0) you can only turn off ajax globally by setting `ajaxEnabled` to false. This sucks as you most likely want all the ajax goodness, just not on form submission.
The way around the is to add `data-ajax=”false”` to the form:
<form id=”myform” action=”somepage.html” method=”get” data-ajax=”false”>
The will prevent the form from being submitted via ajax. Now the fun part if how in the world are you going to submit the form data to the action page using ajax so you get that nice ajax spinner thingy when you’ve turn ajax off? The answer is manually submit the form data by serializing it and appending it to form’s action attribute. Then use `$.mobile.changePage()` to submit the data via ajax. Below is a little helper function I wrote to do this:
submitForm = function(formid){
var form = $(“#” + formid);
var page = [];
page.push(form.attr(‘action’));
page.push(form.serialize());
$.mobile.changePage(page.join(‘?’));
}
To use, just call submitForm(‘your form id’) and it will handle the submission for you:
submitForm(“myform”);
7) Calling trigger(‘create’) on date-role=”header” has no effect
Though you need to call trigger(‘create’) on the data-role=”content” when adding dynamic content for it to style properly, this doesn’t hold true for data-role=”header”. The solution is to call trigger(‘pagecreate’) instead.
————————–
I will continue to add to this post as more issues come up. Please let me know if you have any tips in the comments below.
CFIMAGE Error: Numbers of source Raster bands and source color space components do not match
You might get this error when trying to manipulate a photo with cfimage (such as resizing). I got this when trying to do exactly that with a JPEG.
In order to get around this error, I opened up the photo in a photo editing program and saved the photo as a BMP. Then I opened up the BMP in the photo editor and saved it as a JPEG.
leave a comment