2012-06-21 8 views
0

나는 현재 메시지를 수신하는 프로젝트를 실행하고 있지만 내 애플리케이션을 실행하려고하면 치명적인 예외가 발생한다. & com.project.SMSresponder가 실행을 멈추었다.안드로이드 치명적인 예외

로그 고양이 :

06-21 11:57:24.188: D/AndroidRuntime(335): Shutting down VM 
06-21 11:57:24.188: W/dalvikvm(335): threadid=1: thread exiting with uncaught exception (group=0x40015560) 
06-21 11:57:24.208: E/AndroidRuntime(335): FATAL EXCEPTION: main 
06-21 11:57:24.208: E/AndroidRuntime(335): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.project.smsresponder/com.project.SMSresponderActivity}: java.lang.ClassNotFoundException: com.project.SMSresponderActivity in loader dalvik.system.PathClassLoader[/data/app/com.project.smsresponder-1.apk] 
06-21 11:57:24.208: E/AndroidRuntime(335): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1569) 
06-21 11:57:24.208: E/AndroidRuntime(335): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663) 
06-21 11:57:24.208: E/AndroidRuntime(335): at android.app.ActivityThread.access$1500(ActivityThread.java:117) 
06-21 11:57:24.208: E/AndroidRuntime(335): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931) 
06-21 11:57:24.208: E/AndroidRuntime(335): at android.os.Handler.dispatchMessage(Handler.java:99) 
06-21 11:57:24.208: E/AndroidRuntime(335): at android.os.Looper.loop(Looper.java:123) 
06-21 11:57:24.208: E/AndroidRuntime(335): at android.app.ActivityThread.main(ActivityThread.java:3683) 
06-21 11:57:24.208: E/AndroidRuntime(335): at java.lang.reflect.Method.invokeNative(Native Method) 
06-21 11:57:24.208: E/AndroidRuntime(335): at java.lang.reflect.Method.invoke(Method.java:507) 
06-21 11:57:24.208: E/AndroidRuntime(335): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839) 
06-21 11:57:24.208: E/AndroidRuntime(335): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597) 
06-21 11:57:24.208: E/AndroidRuntime(335): at dalvik.system.NativeStart.main(Native Method) 
06-21 11:57:24.208: E/AndroidRuntime(335): Caused by: java.lang.ClassNotFoundException: com.project.SMSresponderActivity in loader dalvik.system.PathClassLoader[/data/app/com.project.smsresponder-1.apk] 
06-21 11:57:24.208: E/AndroidRuntime(335): at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:240) 
06-21 11:57:24.208: E/AndroidRuntime(335): at java.lang.ClassLoader.loadClass(ClassLoader.java:551) 
06-21 11:57:24.208: E/AndroidRuntime(335): at java.lang.ClassLoader.loadClass(ClassLoader.java:511) 
06-21 11:57:24.208: E/AndroidRuntime(335): at android.app.Instrumentation.newActivity(Instrumentation.java:1021) 
06-21 11:57:24.208: E/AndroidRuntime(335): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1561) 
06-21 11:57:24.208: E/AndroidRuntime(335): ... 11 more 
06-21 11:57:34.199: I/Process(335): Sending signal. PID: 335 SIG: 9 

Maniseft.xml :

<?xml version="1.0" encoding="utf-8"?> 
<manifest xmlns:android="http://schemas.android.com/apk/res/android" 
    package="mydroidX.first" 
    android:versionCode="1" 
    android:versionName="1.0" > 

    <uses-sdk android:minSdkVersion="15" /> 

    <application 
     android:icon="@drawable/ic_launcher" 
     android:label="@string/app_name" > 
     <activity 
      android:name=".Starting_point" 
      android:label="@string/app_name" > 
      <intent-filter> 
       <action android:name="android.intent.action.MAIN" /> 

       <category android:name="android.intent.category.LAUNCHER" /> 
      </intent-filter> 
     </activity> 
    </application> 

</manifest> 

자바 파일 :

,451,515,
public class Recieve extends BroadcastReceiver 
{ 

     String lsms; 
     /* package */ static final String ACTION = 
       "android.provider.Telephony.SMS_RECEIVED"; 

     private static final String TAG = "SMSBroadcastReceiver"; 
     private static final int MAX_SMS_MESSAGE_LENGTH = 0; 


      @Override 
      public void onReceive(Context context, Intent intent) { 
       //---get the SMS message passed in---  
       Log.i(TAG, "Intent recieved: " + intent.getAction()); 

       if (intent.getAction().equals(ACTION)) { 

       Bundle bundle = intent.getExtras();    
       SmsMessage[] msgs = null;   
       String str = "";      
       if (bundle != null)  {   
        //---retrieve the SMS message received---    
        Object[] pdus = (Object[]) bundle.get("pdus");    
        msgs = new SmsMessage[pdus.length];       
        for (int i=0; i<msgs.length; i++){     
         msgs[i] = SmsMessage.createFromPdu((byte[])pdus[i]);         
         str += "SMS from " + msgs[i].getOriginatingAddress();          
         str += " :";     
         str += msgs[i].getMessageBody().toString();     
         str += "\n";      
         }    
        //---display the new SMS message---    
        Toast.makeText(context, str, 
         Toast.LENGTH_SHORT).show();   
        } 
      } 

      } 
    } 

및 SECOND ONE :

 public class Stat extends Activity{ 

      Button btstat; 

      @Override 
      protected void onCreate(Bundle savedInstanceState) { 
       // TODO Auto-generated method stub 
       super.onCreate(savedInstanceState); 
       setContentView(R.layout.rtlayout); 

       btstat = (Button) findViewById(R.id.button1); 

        btstat.setOnClickListener(new View.OnClickListener() 
        { 

         public void onClick(View v) 
         { 
          // TODO Auto-generated method stub 

          Intent intent = new Intent(Stat.this,Recieve.class);      
         startActivity(intent); 
        } 
       }); 
     } 
    } 
+1

레이아웃을 조금 수정했지만 파일을 편집하여 들여 쓰기가 가능하도록 수정하십시오. – Nanne

답변

3
Caused by: java.lang.ClassNotFoundException: com.project.SMSresponderActivity 

당신은 매니페스트에 com.project.SMSresponderActivity가 누락되었습니다.

<activity 
    android:name=".SMSresponderActivity" 
    android:label="@string/smsResponder_name" > 
</activity> 

리시버뿐 아니라 매니페스트의 모든 활동을 지정해야합니다. @imran khan이 말한 것처럼 당신도 그걸 가지고 있지 않다. 매니페스트 파일에

<receiver android:name=".Recieve" android:exported="true" > 
<intent-filter android:priority="999"> 
<action android:name="android.provider.Telephony.SMS_RECEIVED" /> 
</intent-filter> 
</receiver> 

<activity 
    android:name=".Stat" /> 
<activity 
android:name=".SMSresponderActivity" /> 

사용-허가 :

1

매니페스트로에 Recieve BroadcastReciver 및 Stat.java 활동을 등록

<uses-permission android:name="android.permission.RECEIVE_SMS"></uses-permission> 

편집 : 마지막으로 큰 오류가 받으십시오이되지 않는 것입니다 활동 그것은 방송 수신기 또는 당신은 활동으로 시작 그래서 새로운 SMS가 reciver 때 bez 변경 자동 화재 위로 최대

public void onClick(View v) 
       { 
        // TODO Auto-generated method stub 

        //Intent intent = new Intent(Stat.this,Recieve.class); 
      Intent intent = new Intent(Stat.this,YOUR_NEXT_ACTIVITY.class); //you are passing Recieve here  
         startActivity(intent); 
        } 
+0

죄송 합니다만 내 매니페스트 파일은 –

+0

입니다. 매니페스트 파일의 위치는 어디입니까? –

관련 문제