当我尝试在手机上运行我的应用时出现此问题
02-22 23:19:43.967: E/AndroidRuntime(29211): FATAL EXCEPTION: main
02-22 23:19:43.967: E/AndroidRuntime(29211): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.example.flirck/com.example.flirck.MainActivity}: java.lang.ClassNotFoundException: com.example.flirck.MainActivity in loader dalvik.system.PathClassLoader[/mnt/asec/com.example.flirck-1/pkg.apk]
02-22 23:19:43.967: E/AndroidRuntime(29211): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1651)
02-22 23:19:43.967: E/AndroidRuntime(29211): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1753)
02-22 23:19:43.967: E/AndroidRuntime(29211): at android.app.ActivityThread.access$1500(ActivityThread.java:155)
02-22 23:19:43.967: E/AndroidRuntime(29211): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:999)
02-22 23:19:43.967: E/AndroidRuntime(29211): at android.os.Handler.dispatchMessage(Handler.java:130)
02-22 23:19:43.967: E/AndroidRuntime(29211): at android.os.Looper.loop(SourceFile:351)
02-22 23:19:43.967: E/AndroidRuntime(29211): at android.app.ActivityThread.main(ActivityThread.java:3820)
02-22 23:19:43.967: E/AndroidRuntime(29211): at java.lang.reflect.Method.invokeNative(Native Method)
02-22 23:19:43.967: E/AndroidRuntime(29211): at java.lang.reflect.Method.invoke(Method.java:538)
02-22 23:19:43.967: E/AndroidRuntime(29211): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:969)
02-22 23:19:43.967: E/AndroidRuntime(29211): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:727)
02-22 23:19:43.967: E/AndroidRuntime(29211): at dalvik.system.NativeStart.main(Native Method)
02-22 23:19:43.967: E/AndroidRuntime(29211): Caused by: java.lang.ClassNotFoundException: com.example.flirck.MainActivity in loader dalvik.system.PathClassLoader[/mnt/asec/com.example.flirck-1/pkg.apk]
02-22 23:19:43.967: E/AndroidRuntime(29211): at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:271)
02-22 23:19:43.967: E/AndroidRuntime(29211): at java.lang.ClassLoader.loadClass(ClassLoader.java:582)
02-22 23:19:43.967: E/AndroidRuntime(29211): at java.lang.ClassLoader.loadClass(ClassLoader.java:542)
02-22 23:19:43.967: E/AndroidRuntime(29211): at android.app.Instrumentation.newActivity(Instrumentation.java:1056)
02-22 23:19:43.967: E/AndroidRuntime(29211): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1643)
02-22 23:19:43.967: E/AndroidRuntime(29211): ... 11 more
我实际上添加了支持库,它不起作用
任何想法?
public class MainActivity extends FragmentActivity implements android.app.ActionBar.TabListener {
private ViewPager viewPager;
private TabsPagerAdapter mAdapter;
private ActionBar actionBar;
// Tab titles
private String[] tabs = { "Top Rated", "Recent Places" };
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// Initilization
viewPager = (ViewPager) findViewById(R.id.pager);
actionBar = getActionBar();
mAdapter = new TabsPagerAdapter(getSupportFragmentManager());
viewPager.setAdapter(mAdapter);
actionBar.setHomeButtonEnabled(false);
actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
// Adding Tabs
for (String tab_name : tabs) {
actionBar.addTab(actionBar.newTab().setText(tab_name)
.setTabListener(this));
}
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
@Override
public void onTabReselected(Tab arg0, FragmentTransaction arg1) {
// TODO Auto-generated method stub
}
@Override
public void onTabSelected(Tab arg0, FragmentTransaction arg1) {
// TODO Auto-generated method stub
}
@Override
public void onTabUnselected(Tab arg0, FragmentTransaction arg1) {
// TODO Auto-generated method stub
}
}
答案 0 :(得分:0)
您需要将活动添加到AndroidManifest.xml