标题解释说,当我尝试在手机上运行我的应用程序时,eclipse 会给我一条关于类路径源的错误消息,请提供任何帮助
那是我的代码,它在 AVD 上完美运行即使我导出 apk 文件,它也可以在 android 虚拟设备上运行,但是当我将它安装在我的手机设备上时,应用程序不幸停止了
activity_main.xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".MainActivity" >
<TextView
android:id="@+id/textView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@+id/button1"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:layout_marginTop="23dp"
android:text="TextView" />
</RelativeLayout>
清单.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="application.android.news2"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="9"
android:targetSdkVersion="17" />
<uses-permission android:name="android.permission.INTERNET"/>
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="application.android.news2.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>
</manifest>
MainActivity.java
public class MainActivity extends Activity {
public void a(){
HttpClient client = new DefaultHttpClient();
HttpGet request = new HttpGet("http://test002.herobo.com/Index2.php");
HttpResponse response = null;
try {
response = client.execute(request);
} catch (ClientProtocolException e3) {
// TODO Auto-generated catch block
e3.printStackTrace();
} catch (IOException e3) {
// TODO Auto-generated catch block
e3.printStackTrace();
}
String html = "";
InputStream in = null;
try {
in = response.getEntity().getContent();
} catch (IllegalStateException e2) {
// TODO Auto-generated catch block
e2.printStackTrace();
} catch (IOException e2) {
// TODO Auto-generated catch block
e2.printStackTrace();
}
BufferedReader reader = new BufferedReader(new InputStreamReader(in));
StringBuilder str = new StringBuilder();
String line = null;
try {
while((line = reader.readLine()) != null)
{
str.append(line);
}
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
try {
in.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
html = str.toString();
String newStr = html;
newStr = newStr.replace("<", "");
newStr = newStr.replace("!", "");
newStr = newStr.replace("-", "");
newStr = newStr.replace(":", "");
newStr = newStr.replace("/", "");
newStr = newStr.replace(">", "");
newStr = newStr.replace(".", "");
newStr = newStr.replace("=", "");
String s='"'+"";
newStr = newStr.replace(s, "");
String delStr = "Hosting24 Analytics Code script typetextjavascript
srchttpstatshosting24comcountphpscript End Of Analytics Code";
newStr = newStr.replace(delStr, "");
TextView textView2 = (TextView)findViewById(R.id.textView);
textView2.setText(newStr);
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
a();
}
@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;
}
}