1
我正在嘗試在我的android項目中使用RoboGuice2.0。 我工作的機器人工作室,並有包含在我的類路徑吉斯-3.0-no_aop.jar,javax.inject.jar,jsr305-1.3.9.jar和roboguice-2.0.jar。擴展RoboActivity給出ClassNotFoundException
我的代碼是:
public class MainActivity extends RoboActivity {
// @InjectView(R.id.textView) TextView tv;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
TextView tv = (TextView)findViewById(R.id.textView);
Log.d("Text View value ",tv.getText().toString());
}
@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 boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
/**
* A placeholder fragment containing a simple view.
*/
public static class PlaceholderFragment extends Fragment {
public PlaceholderFragment() {
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.activity_main, container, false);
return rootView;
}
}
}
當我在我的模擬器運行這個,我得到異常以下:
Caused by: java.lang.ClassNotFoundException: Didn't find
class "com.example.app.MainActivity" on path: /data/app/com.example.app-2.apk
我Menifest文件是:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.app"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="7"
android:targetSdkVersion="19" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.example.app.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>
</application>
我在這裏失蹤了什麼?什麼可能是錯誤的原因?我一直在尋找互聯網,但無法對時間來解決問題
解決了嗎?我也在努力 –