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>
說實話,我真的不知道如何解決它。
我只是從谷歌代碼導入項目,我試圖運行它。
從我的隊友的筆記本電腦,它工作正常。
但是,當我檢出並試圖運行它。我沒有工作..
清理你的項目並運行一次? –
你在模擬器上測試應用程序嗎? – SathMK
是的,我正在測試模擬器... –