2012-04-16 6 views
0

지금까지이 앱의 유일한 작업은 화면을 가로로 스 와이프하여 슬라이드하는 것입니다. 난 내 안드로이드 가상 머신에서 실행 때 이러한 오류 :ViewPager에서 애플리케이션 강제 종료?

다음
04-14 16:14:17.822: D/ddm-heap(196): Got feature list request 
04-14 16:14:18.193: D/AndroidRuntime(196): Shutting down VM 
04-14 16:14:18.193: W/dalvikvm(196): threadid=3: thread exiting with uncaught exception (group=0x4001b188) 
04-14 16:14:18.193: E/AndroidRuntime(196): Uncaught handler: thread main exiting due to uncaught exception 
04-14 16:14:18.313: E/AndroidRuntime(196): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{stc1.hello.here/stc1.hello.here.Stc1Activity}: java.lang.ClassNotFoundException: stc1.hello.here.Stc1Activity in loader [email protected] 
04-14 16:14:18.313: E/AndroidRuntime(196): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2417) 
04-14 16:14:18.313: E/AndroidRuntime(196): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2512) 
04-14 16:14:18.313: E/AndroidRuntime(196): at android.app.ActivityThread.access$2200(ActivityThread.java:119) 
04-14 16:14:18.313: E/AndroidRuntime(196): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1863) 
04-14 16:14:18.313: E/AndroidRuntime(196): at android.os.Handler.dispatchMessage(Handler.java:99) 
04-14 16:14:18.313: E/AndroidRuntime(196): at android.os.Looper.loop(Looper.java:123) 
04-14 16:14:18.313: E/AndroidRuntime(196): at android.app.ActivityThread.main(ActivityThread.java:4363) 
04-14 16:14:18.313: E/AndroidRuntime(196): at java.lang.reflect.Method.invokeNative(Native Method) 
04-14 16:14:18.313: E/AndroidRuntime(196): at java.lang.reflect.Method.invoke(Method.java:521) 
04-14 16:14:18.313: E/AndroidRuntime(196): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860) 
04-14 16:14:18.313: E/AndroidRuntime(196): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618) 
04-14 16:14:18.313: E/AndroidRuntime(196): at dalvik.system.NativeStart.main(Native Method) 
04-14 16:14:18.313: E/AndroidRuntime(196): Caused by: java.lang.ClassNotFoundException: stc1.hello.here.Stc1Activity in loader dalvik.sy[email protected] 
04-14 16:14:18.313: E/AndroidRuntime(196): at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:243) 
04-14 16:14:18.313: E/AndroidRuntime(196): at java.lang.ClassLoader.loadClass(ClassLoader.java:573) 
04-14 16:14:18.313: E/AndroidRuntime(196): at java.lang.ClassLoader.loadClass(ClassLoader.java:532) 
04-14 16:14:18.313: E/AndroidRuntime(196): at android.app.Instrumentation.newActivity(Instrumentation.java:1021) 
04-14 16:14:18.313: E/AndroidRuntime(196): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2409) 
04-14 16:14:18.313: E/AndroidRuntime(196): ... 11 more 
04-14 16:14:18.403: I/dalvikvm(196): threadid=7: reacting to signal 3 
04-14 16:14:18.413: E/dalvikvm(196): Unable to open stack trace file '/data/anr/traces.txt': Permission denied 
04-14 16:14:35.972: D/AndroidRuntime(228): Shutting down VM 
04-14 16:14:36.052: W/dalvikvm(228): threadid=3: thread exiting with uncaught exception (group=0x4001b188) 
04-14 16:14:36.052: E/AndroidRuntime(228): Uncaught handler: thread main exiting due to uncaught exception 
04-14 16:14:36.112: E/AndroidRuntime(228): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{stc1.hello.here/stc1.hello.here.Stc1Activity}: java.lang.ClassNotFoundException: stc1.hello.here.Stc1Activity in loader [email protected] 
04-14 16:14:36.112: E/AndroidRuntime(228): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2417) 
04-14 16:14:36.112: E/AndroidRuntime(228): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2512) 
04-14 16:14:36.112: E/AndroidRuntime(228): at android.app.ActivityThread.access$2200(ActivityThread.java:119) 
04-14 16:14:36.112: E/AndroidRuntime(228): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1863) 
04-14 16:14:36.112: E/AndroidRuntime(228): at android.os.Handler.dispatchMessage(Handler.java:99) 
04-14 16:14:36.112: E/AndroidRuntime(228): at android.os.Looper.loop(Looper.java:123) 
04-14 16:14:36.112: E/AndroidRuntime(228): at android.app.ActivityThread.main(ActivityThread.java:4363) 
04-14 16:14:36.112: E/AndroidRuntime(228): at java.lang.reflect.Method.invokeNative(Native Method) 
04-14 16:14:36.112: E/AndroidRuntime(228): at java.lang.reflect.Method.invoke(Method.java:521) 
04-14 16:14:36.112: E/AndroidRuntime(228): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860) 
04-14 16:14:36.112: E/AndroidRuntime(228): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618) 
04-14 16:14:36.112: E/AndroidRuntime(228): at dalvik.system.NativeStart.main(Native Method) 
04-14 16:14:36.112: E/AndroidRuntime(228): Caused by: java.lang.ClassNotFoundException: stc1.hello.here.Stc1Activity in loader [email protected] 
04-14 16:14:36.112: E/AndroidRuntime(228): at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:243) 
04-14 16:14:36.112: E/AndroidRuntime(228): at java.lang.ClassLoader.loadClass(ClassLoader.java:573) 
04-14 16:14:36.112: E/AndroidRuntime(228): at java.lang.ClassLoader.loadClass(ClassLoader.java:532) 
04-14 16:14:36.112: E/AndroidRuntime(228): at android.app.Instrumentation.newActivity(Instrumentation.java:1021) 
04-14 16:14:36.112: E/AndroidRuntime(228): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2409) 
04-14 16:14:36.112: E/AndroidRuntime(228): ... 11 more 
04-14 16:14:36.174: I/dalvikvm(228): threadid=7: reacting to signal 3 
04-14 16:14:36.174: E/dalvikvm(228): Unable to open stack trace file '/data/anr/traces.txt': Permission denied 

이 FragmentActivity.java입니다 함께 팝업 로그 캣 :

package stc1.hello.here; 

import android.app.Activity; 
import android.content.Context; 
import android.graphics.Color; 
import android.os.Bundle; 
import android.os.Parcelable; 
import android.support.v4.view.PagerAdapter; 
import android.support.v4.view.ViewPager; 
import android.view.View; 
import android.widget.TextView; 

public class FragmentActivity extends Activity { 
    //We declare how many pages we want here. 
    private ViewPager awesomePager; 
    private static int NUM_AWESOME_VIEWS = 20; 
    private Context cxt; 
    private AwesomePagerAdapter awesomeAdapter; 

    /** Called when the activity is first created. */ 

    @Override 
    public void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.main1); 
     cxt = this; 

     awesomeAdapter = new AwesomePagerAdapter(); 
     awesomePager = (ViewPager) findViewById(R.layout.main1); 
     awesomePager.setAdapter(awesomeAdapter); 
    } 

    private class AwesomePagerAdapter extends PagerAdapter{ 

     @Override 
     public int getCount() { 
      return NUM_AWESOME_VIEWS; 
     } 

     /** 
     * Create the page for the given position. The adapter is responsible 
     * for adding the view to the container given here, although it only 
     * must ensure this is done by the time it returns from 
     * {@link #finishUpdate()}. 
     * 
     * @param container The containing View in which the page will be shown. 
     * @param position The page position to be instantiated. 
     * @return Returns an Object representing the new page. This does not 
     * need to be a View, but can be some other container of the page. 
     */ 
     @Override 
     public Object instantiateItem(View collection, int position) { 
      TextView tv = new TextView(cxt); 
      tv.setText("Bonjour PAUG " + position); 
      tv.setTextColor(Color.WHITE); 
      tv.setTextSize(30); 
      ((ViewPager) collection).addView(tv,0); 
      return tv; 
     } 

     /** 
     * Remove a page for the given position. The adapter is responsible 
     * for removing the view from its container, although it only must ensure 
     * this is done by the time it returns from {@link #finishUpdate()}. 
     * 
     * @param container The containing View from which the page will be removed. 
     * @param position The page position to be removed. 
     * @param object The same object that was returned by 
     * {@link #instantiateItem(View, int)}. 
     */ 
     @Override 
     public void destroyItem(View collection, int position, Object view) { 
      ((ViewPager) collection).removeView((TextView) view); 
     } 

     @Override 
     public boolean isViewFromObject(View view, Object object) { 
      return view==((TextView)object); 
     } 

     /** 
     * Called when the a change in the shown pages has been completed. At this 
     * point you must ensure that all of the pages have actually been added or 
     * removed from the container as appropriate. 
     * @param container The containing View which is displaying this adapter's 
     * page views. 
     */ 
     @Override 
     public void finishUpdate(View arg0) {} 


     @Override 
     public void restoreState(Parcelable arg0, ClassLoader arg1) {} 

     @Override 
     public Parcelable saveState() { 
      return null; 
     } 

     @Override 
     public void startUpdate(View arg0) {} 
    } 
} 
여기

입니다 main1.xml :

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:orientation="vertical" 
    > 
    <android.support.v4.view.ViewPager 
    android:id="@+android:id/viewpager" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    /> 
</LinearLayout> 

답변

0

귀하의 활동 이름이 오류에 제공된 활동 이름과 일치하지 않습니다 :

Caused by: java.lang.ClassNotFoundException: stc1.hello.here.Stc1Activity 

매니페스트를 올바른 이름으로 업데이트해야 할 수 있습니다.