Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialdodders
Python Development Techdegree Graduate 38,679 PointsUnfortunately MasterDetailExample has stopped :(
SO I'm buildiing the project to target 4.2.2 and my emulator is 4.2.2 using the ARM image.
I've removed an reinstalled he environment 4 times over thinking I have something configured incorrectly but I cannot make this go away. Help!!
4 Answers
dodders
Python Development Techdegree Graduate 38,679 PointsSome more info:
07-01 21:49:18.397: E/Trace(768): error opening trace file: No such file or directory (2)
07-01 21:49:18.717: D/AndroidRuntime(768): Shutting down VM
07-01 21:49:18.717: W/dalvikvm(768): threadid=1: thread exiting with uncaught exception (group=0x40a71930)
07-01 21:49:18.727: E/AndroidRuntime(768): FATAL EXCEPTION: main
07-01 21:49:18.727: E/AndroidRuntime(768): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.example.masterdetailexample/com.example.masterdetailexample.BlogPostListActivity}: java.lang.ClassNotFoundException: Didn't find class "com.example.masterdetailexample.BlogPostListActivity" on path: /data/app/com.example.masterdetailexample-2.apk
07-01 21:49:18.727: E/AndroidRuntime(768): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2106)
07-01 21:49:18.727: E/AndroidRuntime(768): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
07-01 21:49:18.727: E/AndroidRuntime(768): at android.app.ActivityThread.access$600(ActivityThread.java:141)
07-01 21:49:18.727: E/AndroidRuntime(768): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
07-01 21:49:18.727: E/AndroidRuntime(768): at android.os.Handler.dispatchMessage(Handler.java:99)
07-01 21:49:18.727: E/AndroidRuntime(768): at android.os.Looper.loop(Looper.java:137)
07-01 21:49:18.727: E/AndroidRuntime(768): at android.app.ActivityThread.main(ActivityThread.java:5041)
07-01 21:49:18.727: E/AndroidRuntime(768): at java.lang.reflect.Method.invokeNative(Native Method)
07-01 21:49:18.727: E/AndroidRuntime(768): at java.lang.reflect.Method.invoke(Method.java:511)
07-01 21:49:18.727: E/AndroidRuntime(768): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
07-01 21:49:18.727: E/AndroidRuntime(768): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
07-01 21:49:18.727: E/AndroidRuntime(768): at dalvik.system.NativeStart.main(Native Method)
07-01 21:49:18.727: E/AndroidRuntime(768): Caused by: java.lang.ClassNotFoundException: Didn't find class "com.example.masterdetailexample.BlogPostListActivity" on path: /data/app/com.example.masterdetailexample-2.apk
07-01 21:49:18.727: E/AndroidRuntime(768): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:65)
07-01 21:49:18.727: E/AndroidRuntime(768): at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
07-01 21:49:18.727: E/AndroidRuntime(768): at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
07-01 21:49:18.727: E/AndroidRuntime(768): at android.app.Instrumentation.newActivity(Instrumentation.java:1054)
07-01 21:49:18.727: E/AndroidRuntime(768): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2097)
07-01 21:49:18.727: E/AndroidRuntime(768): ... 11 more
Ben Junya
12,365 PointsHey dude, here's what I'm noticing:
07-01 21:49:18.397: E/Trace(768): error opening trace file: No such file or directory (2) 07-01 21:49:18.717: D/AndroidRuntime(768): Shutting down VM 07-01 21:49:18.717: W/dalvikvm(768): threadid=1: thread exiting with uncaught exception (group=0x40a71930) 07-01 21:49:18.727: E/AndroidRuntime(768): FATAL EXCEPTION: main 07-01 21:49:18.727: E/AndroidRuntime(768): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.example.masterdetailexample/com.example.masterdetailexample.BlogPostListActivity}: java.lang.ClassNotFoundException: Didn't find class "com.example.masterdetailexample.BlogPostListActivity" on path: /data/app/com.example.masterdetailexample-2.apk
You've got a "ClassNotFoundException" Can you show me your code? It might be a typo in there that's throwing the exception, but without seeing the code, I have no way to help you out.
dodders
Python Development Techdegree Graduate 38,679 PointsThanks Ben, I haven't actually written any code, I've just created a project using the Wizard to add a default activity od Master Detail flow.
When I run it it crashes. Here is the code generated by the system:
package com.example.masterdetailexample;
import android.app.Activity;
import android.os.Bundle;
import android.support.v4.app.ListFragment;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import com.example.masterdetailexample.dummy.DummyContent;
/**
* A list fragment representing a list of BlogPosts. This fragment also supports
* tablet devices by allowing list items to be given an 'activated' state upon
* selection. This helps indicate which item is currently being viewed in a
* {@link BlogPostDetailFragment}.
* <p>
* Activities containing this fragment MUST implement the {@link Callbacks}
* interface.
*/
public class BlogPostListFragment extends ListFragment {
/**
* The serialization (saved instance state) Bundle key representing the
* activated item position. Only used on tablets.
*/
private static final String STATE_ACTIVATED_POSITION = "activated_position";
/**
* The fragment's current callback object, which is notified of list item
* clicks.
*/
private Callbacks mCallbacks = sDummyCallbacks;
/**
* The current activated item position. Only used on tablets.
*/
private int mActivatedPosition = ListView.INVALID_POSITION;
/**
* A callback interface that all activities containing this fragment must
* implement. This mechanism allows activities to be notified of item
* selections.
*/
public interface Callbacks {
/**
* Callback for when an item has been selected.
*/
public void onItemSelected(String id);
}
/**
* A dummy implementation of the {@link Callbacks} interface that does
* nothing. Used only when this fragment is not attached to an activity.
*/
private static Callbacks sDummyCallbacks = new Callbacks() {
@Override
public void onItemSelected(String id) {
}
};
/**
* Mandatory empty constructor for the fragment manager to instantiate the
* fragment (e.g. upon screen orientation changes).
*/
public BlogPostListFragment() {
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// TODO: replace with a real list adapter.
setListAdapter(new ArrayAdapter<DummyContent.DummyItem>(getActivity(),
android.R.layout.simple_list_item_activated_1,
android.R.id.text1, DummyContent.ITEMS));
}
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
// Restore the previously serialized activated item position.
if (savedInstanceState != null
&& savedInstanceState.containsKey(STATE_ACTIVATED_POSITION)) {
setActivatedPosition(savedInstanceState
.getInt(STATE_ACTIVATED_POSITION));
}
}
@Override
public void onAttach(Activity activity) {
super.onAttach(activity);
// Activities containing this fragment must implement its callbacks.
if (!(activity instanceof Callbacks)) {
throw new IllegalStateException(
"Activity must implement fragment's callbacks.");
}
mCallbacks = (Callbacks) activity;
}
@Override
public void onDetach() {
super.onDetach();
// Reset the active callbacks interface to the dummy implementation.
mCallbacks = sDummyCallbacks;
}
@Override
public void onListItemClick(ListView listView, View view, int position,
long id) {
super.onListItemClick(listView, view, position, id);
// Notify the active callbacks interface (the activity, if the
// fragment is attached to one) that an item has been selected.
mCallbacks.onItemSelected(DummyContent.ITEMS.get(position).id);
}
@Override
public void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
if (mActivatedPosition != ListView.INVALID_POSITION) {
// Serialize and persist the activated item position.
outState.putInt(STATE_ACTIVATED_POSITION, mActivatedPosition);
}
}
/**
* Turns on activate-on-click mode. When this mode is on, list items will be
* given the 'activated' state when touched.
*/
public void setActivateOnItemClick(boolean activateOnItemClick) {
// When setting CHOICE_MODE_SINGLE, ListView will automatically
// give items the 'activated' state when touched.
getListView().setChoiceMode(
activateOnItemClick ? ListView.CHOICE_MODE_SINGLE
: ListView.CHOICE_MODE_NONE);
}
private void setActivatedPosition(int position) {
if (position == ListView.INVALID_POSITION) {
getListView().setItemChecked(mActivatedPosition, false);
} else {
getListView().setItemChecked(position, true);
}
mActivatedPosition = position;
}
}
dodders
Python Development Techdegree Graduate 38,679 PointsMoved on a few videos and now know that 3 of the activity files were not created by the wizard (I only have the listfragment).
I think I'll just download the project files. But thanks anyway.
Ben Junya
12,365 PointsHey Paul,
I agree with you. Personally, I've been up and down with all of the Android projects. While they are all extremely well done, Android is constantly getting updated (I joined in March, and there was Kitkat released, and last week Android L + build-tools v23.0.2), and almost all the Treehouse projects use support libraries. Sad to say, but I've had to completely restart some of the Android projects because of an update or 2 that caused everything to fall out of sync.
Just my 2 cents in the future, for ALL Android Treehouse projects, just download the project files and import them into Eclipse or Android Studio. This will save you a lot of hassle, which will make learning how to program much easier and way more fun!