java扩展RoboActivity产生ClassNotFoundException
我正在尝试使用机器人向导2。0与我的安卓项目。 我在安卓工作室工作,拥有guice-3.0-no_aop。jar,javax。注射jar,jsr305-1.3.9。jar和roboguice-2.0。jar包含在我的类路径中
我的代码是:
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;
}
}
}
在emulator上运行时,出现以下异常:
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:安卓="http://schemas.安卓.com/apk/res/安卓"
package="com.example.app"
安卓:versionCode="1"
安卓:versionName="1.0" >
<uses-sdk
安卓:minSdkVersion="7"
安卓:targetSdkVersion="19" />
<application
安卓:allowBackup="true"
安卓:icon="@drawable/ic_launcher"
安卓:label="@string/app_name"
安卓:theme="@style/AppTheme" >
<activity
安卓:name="com.example.app.MainActivity"
安卓:label="@string/app_name" >
<intent-filter>
<action 安卓:name="安卓.intent.action.MAIN" />
<category 安卓:name="安卓.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
我错过了什么?错误的原因可能是什么?我在互联网上搜索了几个小时,但无法解决问题
# 1 楼答案
在AndroidManifest中。xml:
添加它以解决此异常