错误引发。我不明白究竟是什么问题提出请帮助解决
11-11 05:53:17.314: ERROR/AndroidRuntime(839): Uncaught handler: thread main exiting due to uncaught exception
11-11 05:53:17.344: ERROR/AndroidRuntime(839): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.SaxParser2/com.SaxParser2.Login}: android.view.InflateException: Binary XML file line #31: Error inflating class java.lang.reflect.Constructor
11-11 05:53:17.344: ERROR/AndroidRuntime(839): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2268)
11-11 05:53:17.344: ERROR/AndroidRuntime(839): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2284)
11-11 05:53:17.344: ERROR/AndroidRuntime(839): at android.app.ActivityThread.access$1800(ActivityThread.java:112)
11-11 05:53:17.344: ERROR/AndroidRuntime(839): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1692)
11-11 05:53:17.344: ERROR/AndroidRuntime(839): at android.os.Handler.dispatchMessage(Handler.java:99)
11-11 05:53:17.344: ERROR/AndroidRuntime(839): at android.os.Looper.loop(Looper.java:123)
11-11 05:53:17.344: ERROR/AndroidRuntime(839): at android.app.ActivityThread.main(ActivityThread.java:3948)
11-11 05:53:17.344: ERROR/AndroidRuntime(839): at java.lang.reflect.Method.invokeNative(Native Method)
11-11 05:53:17.344: ERROR/AndroidRuntime(839): at java.lang.reflect.Method.invoke(Method.java:521)
11-11 05:53:17.344: ERROR/AndroidRuntime(839): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:782)
11-11 05:53:17.344: ERROR/AndroidRuntime(839): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:540)
11-11 05:53:17.344: ERROR/AndroidRuntime(839): at dalvik.system.NativeStart.main(Native Method)
11-11 05:53:17.344: ERROR/AndroidRuntime(839): Caused by: android.view.InflateException: Binary XML file line #31: Error inflating class java.lang.reflect.Constructor
11-11 05:53:17.344: ERROR/AndroidRuntime(839): at android.view.LayoutInflater.createView(LayoutInflater.java:512)
11-11 05:53:17.344: ERROR/AndroidRuntime(839): at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
11-11 05:53:17.344: ERROR/AndroidRuntime(839): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:562)
11-11 05:53:17.344: ERROR/AndroidRuntime(839): at android.view.LayoutInflater.rInflate(LayoutInflater.java:617)
11-11 05:53:17.344: ERROR/AndroidRuntime(839): at android.view.LayoutInflater.rInflate(LayoutInflater.java:620)
11-11 05:53:17.344: ERROR/AndroidRuntime(839): at android.view.LayoutInflater.inflate(LayoutInflater.java:407)
11-11 05:53:17.344: ERROR/AndroidRuntime(839): at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
11-11 05:53:17.344: ERROR/AndroidRuntime(839): at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
11-11 05:53:17.344: ERROR/AndroidRuntime(839): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:309)
11-11 05:53:17.344: ERROR/AndroidRuntime(839): at android.app.Activity.setContentView(Activity.java:1626)
11-11 05:53:17.344: ERROR/AndroidRuntime(839): at com.SaxParser2.Login.onCreate(Login.java:55)
11-11 05:53:17.344: ERROR/AndroidRuntime(839): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1123)
11-11 05:53:17.344: ERROR/AndroidRuntime(839): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2231)
11-11 05:53:17.344: ERROR/AndroidRuntime(839): ... 11 more
11-11 05:53:17.344: ERROR/AndroidRuntime(839): Caused by: java.lang.reflect.InvocationTargetException
11-11 05:53:17.344: ERROR/AndroidRuntime(839): at android.widget.Button.<init>(Button.java:65)
11-11 05:53:17.344: ERROR/AndroidRuntime(839): at java.lang.reflect.Constructor.constructNative(Native Method)
11-11 05:53:17.344: ERROR/AndroidRuntime(839): at java.lang.reflect.Constructor.newInstance(Constructor.java:446)
11-11 05:53:17.344: ERROR/AndroidRuntime(839): at android.view.LayoutInflater.createView(LayoutInflater.java:499)
11-11 05:53:17.344: ERROR/AndroidRuntime(839): ... 23 more
11-11 05:53:17.344: ERROR/AndroidRuntime(839): Caused by: android.content.res.Resources$NotFoundException: File res/color/primary_text_light.xml from drawable resource ID #0x7f020003
11-11 05:53:17.344: ERROR/AndroidRuntime(839): at android.content.res.Resources.loadDrawable(Resources.java:1625)
11-11 05:53:17.344: ERROR/AndroidRuntime(839): at android.content.res.TypedArray.getDrawable(TypedArray.java:548)
11-11 05:53:17.344: ERROR/AndroidRuntime(839): at android.view.View.<init>(View.java:1725)
11-11 05:53:17.344: ERROR/AndroidRuntime(839): at android.widget.TextView.<init>(TextView.java:314)
11-11 05:53:17.344: ERROR/AndroidRuntime(839): at android.widget.Button.<init>(Button.java:69)
11-11 05:53:17.344: ERROR/AndroidRuntime(839): ... 27 more
11-11 05:53:17.344: ERROR/AndroidRuntime(839): Caused by: android.content.res.Resources$NotFoundException: File res/color/primary_text_light.xml from xml type drawable resource ID #0x7f020003
11-11 05:53:17.344: ERROR/AndroidRuntime(839): at android.content.res.Resources.loadXmlResourceParser(Resources.java:1843)
11-11 05:53:17.344: ERROR/AndroidRuntime(839): at android.content.res.Resources.loadDrawable(Resources.java:1620)
11-11 05:53:17.344: ERROR/AndroidRuntime(839): ... 31 more
11-11 05:53:17.344: ERROR/AndroidRuntime(839): Caused by: java.io.FileNotFoundException: res/color/primary_text_light.xml
11-11 05:53:17.344: ERROR/AndroidRuntime(839): at android.content.res.AssetManager.openXmlAssetNative(Native Method)
11-11 05:53:17.344: ERROR/AndroidRuntime(839): at android.content.res.AssetManager.openXmlBlockAsset(AssetManager.java:471)
11-11 05:53:17.344: ERROR/AndroidRuntime(839): at android.content.res.Resources.loadXmlResourceParser(Resources.java:1825)
11-11 05:53:17.344: ERROR/AndroidRuntime(839): ... 32 more
我的mainClass ::
package com.SaxParser2;
import java.net.URL;
import java.util.ArrayList;
import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;
import org.xml.sax.InputSource;
import org.xml.sax.XMLReader;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ListView;
import android.widget.Toast;
public class Login extends Activity implements OnItemClickListener {
/** Called when the activity is first created. */
String RequestID;
String Status;
String URL1;
String ActivityName;
String AudioScript;
ListView lview;
String[] Sturb1;
String[] Arr_value;
public static String str_getValue;
String[] Stitle1 ;
ArrayList<String> al_value;
ListView list1;
ListViewAdapter lviewAdapter;
Intent i;
String Username;
String Password;
EditText username,password;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.login);
username = (EditText)findViewById(R.id.username);
password = (EditText)findViewById(R.id.password);
i = new Intent(this, Request.class);
Button button1 = (Button) findViewById(R.id.login1);
button1.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
Username = username.getText().toString();
Password = password.getText().toString();
if(Username.length()==0)
{
Toast.makeText(getBaseContext(), "Please Fill Username ", Toast.LENGTH_LONG).show();
}
else if(Password.length()==0)
{
Toast.makeText(getBaseContext(), "Please Fill Password ", Toast.LENGTH_LONG).show();
}
else
{
System.out.println("Username is "+Username);
System.out.println("Password is "+Password);
SaxParser(Username,Password);
i.putExtra("value", str_getValue);
startActivity(i);
}
}
});
}
public void SaxParser(String UserName,String Password) {
try {
System.out.println("Username is :: --- >>> "+UserName);
System.out.println("Password is :: ------ >>> "+Password);
//String url = "http://192.168.1.20/WebServices/Service.asmx/CheckAuthentication?Id="+UserName+"%20&Password="+Password+"";
String url = "http://203.109.115.55/WebServices/Service.asmx/CheckAuthentication?Id="+UserName+"%20&Password="+Password+"";
URL sourceUrl = new URL(url);
SAXParserFactory spf = SAXParserFactory.newInstance();
SAXParser sp = spf.newSAXParser();
XMLReader xr = sp.getXMLReader();
AuthHandler dataHandler = new AuthHandler();
xr.setContentHandler(dataHandler);
xr.parse(new InputSource(sourceUrl.openStream()));
AuthDataset dataset = dataHandler.getParsednewJobdtl_DataSet();
System.out.println("dataset.getint1();"+dataset.getint1());
str_getValue= dataset.getint1();
/*System.out.println(RequestID);*/
/* -------------- Activity name ------------- */
/*Arr_value = new String[al_value.size()];
Arr_value = al_value.toArray(Arr_value);
System.out.println("Arr_value"+ Arr_value);*/
} catch (Exception e) {
e.printStackTrace();
}
}
@Override
public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
// TODO Auto-generated method stub
}
}
答案 0 :(得分:2)
我有完全相同的错误跟踪(从InflateException
到FileNotFoundException: res/color/primary_text_light.xml
),并解决了这个问题:
res/drawable-hdpi
的内容与res/drawable
res/drawable-hdpi
复制到res/drawable
所以我想说:确保每个res/drawable*
文件夹包含相同数量的图像,文件名相同。
注意:这很奇怪,因为我从未使用过,也没有添加任何名为primary_text_light.xml
的文件,所以我不知道为什么Android首先抱怨它。无论如何,我希望这会有所帮助: - )