我正在为家庭自动化创建一个应用程序。当应用程序在智能手机上运行时(os kitkat)我得到例外:
android.content.pm.PackageManager $的NameNotFoundException:
这是日志
09-21 17:55:25.299 2550-2550/amrita.edu.ha W/System.err: android.content.pm.PackageManager$NameNotFoundException:
09-21 17:55:25.300 2550-2550/amrita.edu.ha W/System.err: at android.app.ApplicationPackageManager.getApplicationInfo(ApplicationPackageManager.java:227)
09-21 17:55:25.300 2550-2550/amrita.edu.ha W/System.err: at android.app.ApplicationPackageManager.getResourcesForApplication(ApplicationPackageManager.java:786)
09-21 17:55:25.300 2550-2550/amrita.edu.ha W/System.err: at android.widget.TextView.<init>(TextView.java:1323)
09-21 17:55:25.300 2550-2550/amrita.edu.ha W/System.err: at android.widget.EditText.<init>(EditText.java:60)
09-21 17:55:25.300 2550-2550/amrita.edu.ha W/System.err: at android.support.v7.widget.AppCompatEditText.<init>(AppCompatEditText.java:60)
09-21 17:55:25.300 2550-2550/amrita.edu.ha W/System.err: at android.support.v7.widget.AppCompatEditText.<init>(AppCompatEditText.java:56)
09-21 17:55:25.300 2550-2550/amrita.edu.ha W/System.err: at android.support.v7.app.AppCompatViewInflater.createView(AppCompatViewInflater.java:112)
09-21 17:55:25.300 2550-2550/amrita.edu.ha W/System.err: at android.support.v7.app.AppCompatDelegateImplV7.createView(AppCompatDelegateImplV7.java:980)
09-21 17:55:25.300 2550-2550/amrita.edu.ha W/System.err: at android.support.v7.app.AppCompatDelegateImplV7.onCreateView(AppCompatDelegateImplV7.java:1039)
09-21 17:55:25.300 2550-2550/amrita.edu.ha W/System.err: at android.support.v4.view.LayoutInflaterCompatHC$FactoryWrapperHC.onCreateView(LayoutInflaterCompatHC.java:44)
09-21 17:55:25.301 2550-2550/amrita.edu.ha W/System.err: at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:684)
09-21 17:55:25.301 2550-2550/amrita.edu.ha W/System.err: at android.view.LayoutInflater.rInflate(LayoutInflater.java:755)
09-21 17:55:25.301 2550-2550/amrita.edu.ha W/System.err: at android.view.LayoutInflater.rInflate(LayoutInflater.java:758)
09-21 17:55:25.301 2550-2550/amrita.edu.ha W/System.err: at android.view.LayoutInflater.rInflate(LayoutInflater.java:758)
09-21 17:55:25.301 2550-2550/amrita.edu.ha W/System.err: at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
09-21 17:55:25.301 2550-2550/amrita.edu.ha W/System.err: at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
09-21 17:55:25.301 2550-2550/amrita.edu.ha W/System.err: at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
09-21 17:55:25.301 2550-2550/amrita.edu.ha W/System.err: at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:280)
09-21 17:55:25.301 2550-2550/amrita.edu.ha W/System.err: at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)
09-21 17:55:25.301 2550-2550/amrita.edu.ha W/System.err: at amrita.edu.ha.AddUser.onCreate(AddUser.java:55)
09-21 17:55:25.301 2550-2550/amrita.edu.ha W/System.err: at android.app.Activity.performCreate(Activity.java:5292)
09-21 17:55:25.301 2550-2550/amrita.edu.ha W/System.err: at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1088)
09-21 17:55:25.301 2550-2550/amrita.edu.ha W/System.err: at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2302)
09-21 17:55:25.302 2550-2550/amrita.edu.ha W/System.err: at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2390)
09-21 17:55:25.302 2550-2550/amrita.edu.ha W/System.err: at android.app.ActivityThread.access$800(ActivityThread.java:151)
09-21 17:55:25.302 2550-2550/amrita.edu.ha W/System.err: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1321)
09-21 17:55:25.302 2550-2550/amrita.edu.ha W/System.err: at android.os.Handler.dispatchMessage(Handler.java:110)
09-21 17:55:25.302 2550-2550/amrita.edu.ha W/System.err: at android.os.Looper.loop(Looper.java:193)
09-21 17:55:25.302 2550-2550/amrita.edu.ha W/System.err: at android.app.ActivityThread.main(ActivityThread.java:5292)
09-21 17:55:25.302 2550-2550/amrita.edu.ha W/System.err: at java.lang.reflect.Method.invokeNative(Native Method)
09-21 17:55:25.302 2550-2550/amrita.edu.ha W/System.err: at java.lang.reflect.Method.invoke(Method.java:515)
09-21 17:55:25.302 2550-2550/amrita.edu.ha W/System.err: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:824)
09-21 17:55:25.302 2550-2550/amrita.edu.ha W/System.err: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:640)
09-21 17:55:25.302 2550-2550/amrita.edu.ha W/System.err: at dalvik.system.NativeStart.main(Native Method)
代码在
之下public class AddUser extends AppCompatActivity { //implements MultiSelectionSpinner.OnMultipleItemsSelectedListener
private EditText et,et1,et2,et3,et4;
private Button btn;
private Spinner spinner;
private ImageButton imgtbn;
int i=0;
List<String> list = new ArrayList<>();
List<String> mylist=new ArrayList<>();
List<Integer>nlist=new ArrayList<>();
Integer myIntArray;
HashMap<String,Integer> map=new HashMap<String, Integer>();
Object objh="";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
**setContentView(R.layout.adduser);**
ClientResource clientResource=new ClientResource("http://10.30.9.208:8080/api/users/view_group");
clientResource.setChallengeResponse(ChallengeScheme.HTTP_BASIC,
"admin", "admin");
clientResource.get();
Response response= clientResource.getResponse();
System.out.println("Response from server is ----> "+response.getEntityAsText());
JSONObject obj= null;
try {
obj = new JSONObject(response.getEntityAsText());
String strMessage = (String) obj.get("message");
JSONArray jarray = new JSONArray(strMessage);
for (int i = 0; i < jarray.length(); i++) {
JSONObject obj1 = jarray.getJSONObject(i);
list.add((String) obj1.get("group_name"));
map.put((String)obj1.get("group_name"),(Integer)obj1.get("group_id"));
}
}catch(JSONException e){
e.printStackTrace();
}
例外情况指向两颗星中的声明。