2013-11-15 45 views
0

lang.RuntimeException:無法實例活動ComponentInfo」了java.lang.RuntimeException:無法實例活動ComponentInfo {com.example.projectmobilecloud/com.example.projectmobilecloud.MainActivity}:

我正在尋找了很多同樣的情況,並試圖修復它,但它是真的很難解決這個問題,爲Android的初學者

我收到錯誤,如

11-14 23:42:20.624:E/AndroidRuntime( 1069):致命例外:主 11-14 23:42:20.624:E/Andro idRuntime(1069):java.lang.RuntimeException:無法實例化活動ComponentInfo {com.example.projectmobilecloud/com.example.projectmobilecloud.MainActivity}:java.lang.ClassNotFoundException:com.example.projectmobilecloud.MainActivity 11-14 23 :42:20.624:E/AndroidRuntime(1069):at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1983) 11-14 23:42:20.624:E/AndroidRuntime(1069):at android.app.ActivityThread .handleLaunchActivity(ActivityThread.java:2084) 11-14 23:42:20.624:E/AndroidRuntime(1069):at android.app.ActivityThread.access $ 600(ActivityThread.java:130) 11-14 23:42: 20.624:E/AndroidRuntime(1069):在android.app.ActivityThread $ H.handleMessage(ActivityThread.java:1195) 11-14 23:42:20.624:E/AndroidRuntime(1069):在android.os.Handler。 dispatchMessage(Handler.java:99) 11-14 23:42:20.624:E/AndroidRuntime(1069):at android.os.Looper.loop(Looper.java:137) 11-14 23:42:20.624:E/AndroidRuntime(1069):at android.app.ActivityThread.main(ActivityThread.java:4745) 11-14 23:42:20.624:E/AndroidRuntime(1069):at java.lang.reflect.Method.invokeNative(Native Method) 11-14 23 :42:20.624:E/AndroidRuntime(1069):在java.lang.reflect.Method.invoke(Method.java:511) 11-14 23:42:20.624:E/AndroidRuntime(1069):at com.android .internal.os.ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java:786) 11-14 23:42:20.624:E/AndroidRuntime(1069):at com.android.internal.os.ZygoteInit.main(ZygoteInit.java :553) 11-14 23:42:20.624:E/AndroidRuntime(1069):at dalvik.system.NativeStart.main(Native Method) 11-14 23:42:20.624:E/AndroidRuntime(1069)由:java.lang.ClassNotFoundException:com.example.projectmobilecloud.MainActivity 11-14 23:42:20.624:E/AndroidRuntime(1069):at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61) 11 -14 23:42:20.624:E/AndroidRuntime(1069):在java.lang.ClassLoader.loadClass(ClassLoader.java:501) 11-14 23:42:20.624:E/AndroidRuntime(1069):at java。 lang.ClassLoader.loadClass(ClassLoader.java:461) 11-14 23:42:20.624:E/AndroidRuntime(1069):at android.app.Instrumentation.newActivity(Instrumentation.java:1053) 11-14 23: 42:20.624:E/AndroidRuntime(1069):at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1974) 11-14 23:42:20.624:E/AndroidRuntime(1069):... 11更多

,並在MainActivity.java

public class MainActivity extends Activity { 

     public MainSelection_Tool mt = new MainSelection_Tool(); 
     private RadioGroup radioSexGroup; 
     private RadioGroup radioWorkGroup; 
     private RadioButton radioSexButton; 
     private Button btnDisplay; 
    @Override 
    protected void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.activity_main); 
     addListenerOnButton(); 

    } 

public boolean onCreateOptionsMenu(Menu menu) { 

     getMenuInflater().inflate(R.menu.activity_main, menu); 
     return true; 
    } 
     public void addListenerOnButton() { 

     radioSexGroup = (RadioGroup) findViewById(R.id.radioSex); 
     radioWorkGroup = (RadioGroup) findViewById(R.id.radioWorkFlow); 
     btnDisplay = (Button) findViewById(R.id.btnDisplay); 
     btnDisplay.setOnClickListener(new OnClickListener() { 

      public void onClick(View v) { 

        // get selected radio button from radioGroup 
       int selectedId = radioSexGroup.getCheckedRadioButtonId(); 
       int workflow_id = radioWorkGroup.getCheckedRadioButtonId(); 
       Intent GO_Control = new Intent(MainActivity.this,ControlActivity.class); 
       int wf = mt.Get_Option(workflow_id, 0); 
       int si = mt.Get_Option(selectedId, 1); 
       System.out.println("Sel " + si + " wf " + wf); 
       Log.d("WORK", String.valueOf(wf)); 
       Log.d("Select", String.valueOf(si)); 

       startActivity(GO_Control); 

      } 

     }); 

     } 

而且 AndroidManifest.xml文件我有...

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

    <uses-sdk 
     android:minSdkVersion="8" 
     android:targetSdkVersion="16" /> 

    <application 
     android:allowBackup="true" 
     android:icon="@drawable/ic_launcher" 
     android:label="@string/app_name" 
     android:theme="@style/AppTheme" > 
     <activity 
      android:name="com.example.projectmobilecloud.MainActivity" 
      android:label="@string/app_name" > 
      <intent-filter> 
       <action android:name="android.intent.action.MAIN" /> 
       <category android:name="android.intent.category.LAUNCHER" /> 
      </intent-filter> 
     </activity> 
     <activity android:name="ControlActivity" android:label="@string/app_name"></activity> 
    </application> 

</manifest> 

說實話,我真的不知道如何解決它。

我只是從谷歌代碼導入項目,我試圖運行它。

從我的隊友的筆記本電腦,它工作正常。

但是,當我檢出並試圖運行它。我沒有工作..

+0

清理你的項目並運行一次? –

+0

你在模擬器上測試應用程序嗎? – SathMK

+0

是的,我正在測試模擬器... –

回答

0

嘗試

工程 - 清潔 - >選擇您的項目,並進行清潔..

+0

我清理並再次運行它,但它仍然存在問題...是否有任何可能的原因? –

0
<application 
     android:name="com.example.projectmobilecloud" 
     android:allowBackup="true" 
     android:icon="@drawable/ic_launcher" 
     android:label="@string/app_name" 
     android:theme="@style/AppTheme" > 

JAST在AndroidManifest XML補充。希望它的工作

+0

我添加並重新運行它,但它仍然有問題,是這個問題?機器人:名稱= 「com.example.projectmobilecloud.MainActivity」 –

+0

<應用 \t \t機器人:名稱= 「com.example.projectmobilecloud」 機器人:allowBackup = 「真」 機器人:圖標= 「@繪製/ ic_launcher」 android:label =「@ string/app_name」 android:theme =「@ style/AppTheme」>

+0

0

如果你已經更新到ADTv17以上,老的ProGuard文件會這樣對你。創建一個新的空項目,並查看project.properties和proguard-properties並相應地修改當前項目。

+0

在AndroidManifest xml中,我發現沒有針對最新版本的Android;兼容模式 適用。考慮測試和更新這個版本。有關詳細信息,請參閱 android.os.Build.VERSION_CODES javadoc。是錯誤原因嗎? –

+0

不,這可能是因爲你的project.properties和progard屬性沒有正確創建。嘗試在eclipse中創建的項目中進行編輯 – SathMK

相關問題