- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我在 android 中开发一个项目,该项目使用 json 从 web 服务获取数据并显示在 ListView 中。
我解析了数据,并在模拟器中运行应用程序时强制关闭。
我做错了什么?更正将不胜感激。
这是我的完整代码
public class AndroidJSONParsingActivity extends ListActivity {
// url to make request
private static String url = "http://example.com/";
// JSON Node names
private static final String TAG_PRODUCT = "Product";
private static final String TAG_ID = "shop_prdt_id";
private static final String TAG_CATID="shop_cat_id";
private static final String TAG_SCATID="shop_scat_id";
private static final String TAG_PRODCODE="shop_prdt_code";
private static final String TAG_TITLE="shop_prdt_title";
private static final String TAG_LISTPRICE = "shop_prdt_listprice";
private static final String TAG_OURPRICE = "shop_prdt_ourprice";
private static final String TAG_YOU = "shop_prdt_yousave";
private static final String TAG_STOCK = "shop_prdt_stock";
private static final String TAG_WEIGHT = "shop_prdt_weight";
private static final String TAG_WEIGHTMEASURE = "shop_prdt_weight_measurement";
private static final String TAG_PRODCOLOR = "shop_prdt_color";
private static final String TAG_SIZE = "shop_prdt_size";
private static final String TAG_SPLDESC = "shop_prdt_spl_description";
private static final String TAG_DESC = "shop_prdt_description";
private static final String TAG_FEATURE="shop_prdt_featured";
private static final String TAG_SEOTITLE="shop_prdt_seo_title";
private static final String TAG_SEODESC="shop_prdt_seo_desc";
private static final String TAG_SEOKEYWORDS="shop_prdt_seo_keywords";
private static final String TAG_IMAGES="shop_prdt_images";
private static final String TAG_CLICKS="shop_prdt_clicks";
private static final String TAG_CREATEDATE="shop_prdt_createdon";
private static final String TAG_UPDATEDATE="shop_prdt_updatedon";
private static final String TAG_STATUS="shop_prdt_status";
// contacts JSONArray
JSONArray product = null;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
// Hashmap for ListView
ArrayList<HashMap<String, String>> contactList = new ArrayList<HashMap<String, String>>();
// Creating JSON Parser instance
JSONParser jParser = new JSONParser();
// getting JSON string from URL
JSONObject json = jParser.getJSONFromUrl(url);
try {
// Getting Array of Contacts
product = json.getJSONArray(TAG_PRODUCT);
// looping through All product
for(int i = 0; i < product.length(); i++){
JSONObject c = product.getJSONObject(i);
// Storing each json item in variable
String id = c.getString(TAG_ID);
String catid = c.getString(TAG_CATID);
String Subcatid=c.getString(TAG_SCATID);
String prcode =c.getString(TAG_PRODCODE);
String title = c.getString(TAG_TITLE);
String listprice =c.getString(TAG_LISTPRICE);
String ourprice = c.getString(TAG_OURPRICE);
String you=c.getString(TAG_YOU);
String stock =c.getString(TAG_STOCK);
String weight =c.getString(TAG_WEIGHT);
String weightmes =c.getString(TAG_WEIGHTMEASURE);
String color =c.getString(TAG_PRODCOLOR);
String size =c.getString(TAG_SIZE);
String spldesc =c.getString(TAG_SPLDESC);
String desc =c.getString(TAG_DESC);
String feature =c.getString(TAG_FEATURE);
String seotitle=c.getString(TAG_SEOTITLE);
String seodesc =c.getString(TAG_SEODESC);
String seokeywords =c.getString(TAG_SEOKEYWORDS);
String images =c.getString(TAG_IMAGES);
String clicks =c.getString(TAG_CLICKS);
String createdate =c.getString(TAG_CREATEDATE);
String updatedate =c.getString(TAG_UPDATEDATE);
String status =c.getString(TAG_STATUS);
// creating new HashMap
HashMap<String, String> map = new HashMap<String, String>();
// adding each child node to HashMap key => value
map.put(TAG_ID, id);
map.put(TAG_TITLE, title);
map.put(TAG_OURPRICE, ourprice);
map.put(TAG_YOU, you);
// adding HashList to ArrayList
contactList.add(map);
}
} catch (JSONException e) {
e.printStackTrace();
}
/**
* Updating parsed JSON data into ListView
* */
ListAdapter adapter = new SimpleAdapter(this, contactList,
R.layout.list_item,
new String[] { TAG_TITLE, TAG_OURPRICE, TAG_YOU }, new int[] {
R.id.name, R.id.email, R.id.mobile });
setListAdapter(adapter);
// selecting single ListView item
ListView lv = getListView();
// Launching new screen on Selecting Single ListItem
lv.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view,
int position, long id) {
// getting values from selected ListItem
String name1 = ((TextView) view.findViewById(R.id.name)).getText().toString();
String ourprice1 = ((TextView) view.findViewById(R.id.email)).getText().toString();
String you1 = ((TextView) view.findViewById(R.id.mobile)).getText().toString();
// Starting new intent
Intent in = new Intent(getApplicationContext(), SingleMenuItemActivity.class);
in.putExtra(TAG_TITLE, name1);
in.putExtra(TAG_OURPRICE, ourprice1);
in.putExtra(TAG_YOU, you1);
startActivity(in);
}
});
}
}
我的json文件
{
"Product": [
{
"shop_prdt_id": "11",
"shop_cat_id": "3",
"shop_scat_id": "0",
"shop_prdt_code": "06PTPL-01PK",
"shop_prdt_title": "Party Wear Anarkkali Suits",
"shop_prdt_listprice": "44",
"shop_prdt_ourprice": "40",
"shop_prdt_yousave": "4",
"shop_prdt_stock": "20",
"shop_prdt_weight": "17.67",
"shop_prdt_weight_measurement": "GRM",
"shop_prdt_color": "3,4,7,8,12,13,14",
"shop_prdt_size": "3,5,11,13",
"shop_prdt_spl_description": "",
"shop_prdt_description": "<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur bibendum ornare dolor, quis ullamcorper ligula sodales at. Nulla tellus elit, varius non commodo eget, mattis vel eros. In sed ornare nulla.</p>\r\n\r\n<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur bibendum ornare dolor, quis ullamcorper ligula sodales at. Nulla tellus elit, varius non commodo eget, mattis vel eros. In sed ornare nulla.</p>\r\n",
"shop_prdt_featured": "1",
"shop_prdt_seo_title": "Party Wear Anarkkali Suits",
"shop_prdt_seo_desc": "Party Wear Anarkkali Suits",
"shop_prdt_seo_keywords": "Anarkkali Suits",
"shop_prdt_images": "1",
"shop_prdt_clicks": "13",
"shop_prdt_createdon": "2013-10-29 02:26:08",
"shop_prdt_updatedon": "2013-11-17 17:27:37",
"shop_prdt_status": "1"
},
{
"shop_prdt_id": "8",
"shop_cat_id": "2",
"shop_scat_id": "0",
"shop_prdt_code": "SKCT-28",
"shop_prdt_title": "Pure Silk Cotton",
"shop_prdt_listprice": "150",
"shop_prdt_ourprice": "120",
"shop_prdt_yousave": "30",
"shop_prdt_stock": "30",
"shop_prdt_weight": "35",
"shop_prdt_weight_measurement": "GRM",
"shop_prdt_color": "25",
"shop_prdt_size": "",
"shop_prdt_spl_description": "<p><span class="fbPhotosPhotoCaption" data-ft="{&quot;type&quot;:45,&quot;tn&quot;:&quot;*G&quot;}" id="fbPhotoSnowliftCaption" tabindex="0"><span class="hasCaption">Women and pink ? Perfect combination ! Beautiful bright pink with vibrant coloured threadwork design on it, for a truly classy feel. For the woman who quietly walks into the room and takes everyone&#39;s breath away</span></span></p>\r\n",
"shop_prdt_description": "<p>Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of &quot;de Finibus Bonorum et Malorum&quot; (The Extremes of Good and Evil) by Cicero, written in 45 BC. This book is a treatise on the theory of ethics, very popular during the Renaissance. The first line of Lorem Ipsum, &quot;Lorem ipsum dolor sit amet..&quot;, comes from a line in section 1.10.32.</p>\r\n\r\n<p>The standard chunk of Lorem Ipsum used since the 1500s is reproduced below for those interested. Sections 1.10.32 and 1.10.33 from &quot;de Finibus Bonorum et Malorum&quot; by Cicero are also reproduced in their exact original form, accompanied by English versions from the 1914 translation by H. Rackham.</p>\r\n",
"shop_prdt_featured": "1",
"shop_prdt_seo_title": "Pure Silk Cotton",
"shop_prdt_seo_desc": "For the woman who quietly walks into the room and takes everyone's breath away.",
"shop_prdt_seo_keywords": "Pure Silk Cotton, Cotton, Sharani Designs",
"shop_prdt_images": "1",
"shop_prdt_clicks": "13",
"shop_prdt_createdon": "2013-10-09 22:15:05",
"shop_prdt_updatedon": "",
"shop_prdt_status": "1"
},
{
"shop_prdt_id": "7",
"shop_cat_id": "1",
"shop_scat_id": "3",
"shop_prdt_code": "PTD-08GR",
"shop_prdt_title": "House Wears with simple colors",
"shop_prdt_listprice": "15",
"shop_prdt_ourprice": "13.90",
"shop_prdt_yousave": "1.1",
"shop_prdt_stock": "25",
"shop_prdt_weight": "11",
"shop_prdt_weight_measurement": "GRM",
"shop_prdt_color": "3,8,10",
"shop_prdt_size": "1,2,3,5,7,9,11",
"shop_prdt_spl_description": "<p>&nbsp;If you are going to use a passage of Lorem Ipsum, you need to be sure there isn&#39;t anything embarrassing hidden in the middle of text. All the Lorem Ipsum generators on the Internet tend to repeat predefined chunks as necessary, making this the first true generator on the Internet.</p>\r\n",
"shop_prdt_description": "<p>There are many variations of passages of Lorem Ipsum available, but the majority have suffered alteration in some form, by injected humour, or randomised words which don&#39;t look even slightly believable. If you are going to use a passage of Lorem Ipsum, you need to be sure there isn&#39;t anything embarrassing hidden in the middle of text. All the Lorem Ipsum generators on the Internet tend to repeat predefined chunks as necessary, making this the first true generator on the Internet. It uses a dictionary of over 200 Latin words, combined with a handful of model sentence structures, to generate Lorem Ipsum which looks reasonable. The generated Lorem Ipsum is therefore always free from repetition, injected humour, or non-characteristic words etc.</p>\r\n\r\n<p>Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of &quot;de Finibus Bonorum et Malorum&quot; (The Extremes of Good and Evil) by Cicero, written in 45 BC. This book is a treatise on the theory of ethics, very popular during the Renaissance. The first line of Lorem Ipsum, &quot;Lorem ipsum dolor sit amet..&quot;, comes from a line in section 1.10.32.</p>\r\n\r\n<p>The standard chunk of Lorem Ipsum used since the 1500s is reproduced below for those interested. Sections 1.10.32 and 1.10.33 from &quot;de Finibus Bonorum et Malorum&quot; by Cicero are also reproduced in their exact original form, accompanied by English versions from the 1914 translation by H. Rackham.</p>\r\n",
"shop_prdt_featured": "1",
"shop_prdt_seo_title": "House Wears with simple colors",
"shop_prdt_seo_desc": "This book is a treatise on the theory of ethics, very popular during the Renaissance",
"shop_prdt_seo_keywords": "Sharani Designs",
"shop_prdt_images": "1",
"shop_prdt_clicks": "39",
"shop_prdt_createdon": "2013-10-09 21:48:51",
"shop_prdt_updatedon": "2013-11-16 23:58:07",
"shop_prdt_status": "1"
}
]
}
02-05 05:11:37.413: D/dalvikvm(2110): GC_FOR_ALLOC freed 217K, 9% free 2968K/3260K, paused 26ms, total 28ms
02-05 05:11:37.533: E/JSON Parser(2110): Error parsing data org.json.JSONException: Unterminated object at character 8276 of {
02-05 05:11:37.533: E/JSON Parser(2110): "Product":[
02-05 05:11:37.533: E/JSON Parser(2110): {
02-05 05:11:37.533: E/JSON Parser(2110): "shop_prdt_id":"11",
02-05 05:11:37.533: E/JSON Parser(2110): "shop_cat_id":"3",
02-05 05:11:37.533: E/JSON Parser(2110): "shop_scat_id":"0",
02-05 05:11:37.533: E/JSON Parser(2110): "shop_prdt_code":"06PTPL-01PK",
02-05 05:11:37.533: E/JSON Parser(2110): "shop_prdt_title":"Party Wear Anarkkali Suits",
02-05 05:11:37.533: E/JSON Parser(2110): "shop_prdt_listprice":"44",
02-05 05:11:37.533: E/JSON Parser(2110): "shop_prdt_ourprice":"40",
02-05 05:11:37.533: E/JSON Parser(2110): "shop_prdt_yousave":"4",
02-05 05:11:37.533: E/JSON Parser(2110): "shop_prdt_stock":"20",
02-05 05:11:37.533: E/JSON Parser(2110): "shop_prdt_weight":"17.67",
02-05 05:11:37.533: E/JSON Parser(2110): "shop_prdt_weight_measurement":"GRM",
02-05 05:11:37.533: E/JSON Parser(2110): "shop_prdt_color":"3,4,7,8,12,13,14",
02-05 05:11:37.533: E/JSON Parser(2110): "shop_prdt_size":"3,5,11,13",
02-05 05:11:37.533: E/JSON Parser(2110): "shop_prdt_spl_description":"",
02-05 05:11:37.533: E/JSON Parser(2110): "shop_prdt_description":"<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur bibendum ornare dolor, quis ullamcorper ligula sodales at. Nulla tellus elit, varius non commodo eget, mattis vel eros. In sed ornare nulla.<\/p>\r\n\r\n<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur bibendum ornare dolor, quis ullamcorper ligula sodales at. Nulla tellus elit, varius non commodo eget, mattis vel eros. In sed ornare nulla.<\/p>\r\n",
02-05 05:11:37.533: E/JSON Parser(2110): "shop_prdt_featured":"1",
02-05 05:11:37.533: E/JSON Parser(2110): "shop_prdt_seo_title":"Party Wear Anarkkali Suits",
02-05 05:11:37.533: E/JSON Parser(2110): "shop_prdt_seo_desc":"Party Wear Anarkkali Suits",
02-05 05:11:37.533: E/JSON Parser(2110): "shop_prdt_seo_keywords":"Anarkkali Suits",
02-05 05:11:37.533: E/JSON Parser(2110): "shop_prdt_images":"1",
02-05 05:11:37.533: E/JSON Parser(2110): "shop_prdt_clicks":"13",
02-05 05:11:37.533: E/JSON Parser(2110): "shop_prdt_createdon":"2013-10-29 02:26:08",
02-05 05:11:37.533: E/JSON Parser(2110): "shop_prdt_updatedon":"2013-11-17 17:27:37",
02-05 05:11:37.533: E/JSON Parser(2110): "shop_prdt_status":"1"
02-05 05:11:37.533: E/JSON Parser(2110): },
02-05 05:11:37.533: E/JSON Parser(2110): {
02-05 05:11:37.533: E/JSON Parser(2110): "shop_prdt_id":"10",
02-05 05:11:37.533: E/JSON Parser(2110): "shop_cat_id":"4",
02-05 05:11:37.533: E/JSON Parser(2110): "shop_scat_id":"0",
02-05 05:11:37.533: E/JSON Parser(2110): "shop_prdt_code":"LEGG-GR01",
02-05 05:11:37.533: E/JSON Parser(2110): "shop_prdt_title":"Premium Cotton Leggins",
02-05 05:11:37.533: E/JSON Parser(2110): "shop_prdt_listprice":"15",
02-05 05:11:37.533: E/JSON Parser(2110): "shop_prdt_ourprice":"13.90",
02-05 05:11:37.533: E/JSON Parser(2110): "shop_prdt_yousave":"1.1",
02-05 05:11:37.533: E/JSON Parser(2110): "shop_prdt_stock":"75",
02-05 05:11:37.533: E/JSON Parser(2110): "shop_prdt_weight":"11",
02-05 05:11:37.533: E/JSON Parser(2110): "shop_prdt_weight_measurement":"GRM",
02-05 05:11:37.533: E/JSON Parser(2110): "shop_prdt_color":"9,12,23,26,27,28,29,36",
02-05 05:11:37.533: E/JSON Parser(2110): "shop_prdt_size":"",
02-05 05:11:37.533: E/JSON Parser(2110): "shop_prdt_spl_description":"<p><span class="fbPhotosPhotoCaption" data-ft="{&quot;type&quot;:45,&quot;tn&quot;:&quot;*G&quot;}" id="fbPhotoSnowliftCaption" tabindex="0"><span class="hasCaption">SLIGHT COLOUR VARIATIONS POSSIBLE DUE TO PHOTOGRAPHIC LIMITATIONS.<\/span><\/span><\/p>\r\n",
02-05 05:11:37.533: E/JSON Parser(2110): "shop_prdt_description":"<p>Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of &quot;de Finibus Bonorum et Malorum&quot; (The Extremes of Good and Evil) by Cicero, written in 45 BC. This book is a treatise on the theory of ethics, very popular during the Renaissance. The first line of Lorem Ipsum, &quot;Lorem ipsum dolor sit amet..&quot;, comes from a line in section 1.10.32.<\/p>\r\n\r\n<p>The standard chunk of Lorem Ipsum used since the 1500s is reproduced below for those interested. Sections 1.10.32 and 1.10.33 from &quot;de Finibus Bonorum et Malorum&quot; by Cicero are also reproduced in their exact original form, accompanied by English versions from the 1914 translation by H. Rackham.<\/p>\r\n",
02-05 05:11:37.533: E/JSON Parser(2110): "shop_prdt_featured":"1",
02-05 05:11:37.533: E/JSON Parser(2110): "shop_prdt_seo_title":"Premium Cotton Leggins",
02-05 05:11:37.533: E/JSON Parser(2110): "shop_prdt_seo_desc":"96% Premium Cotton and 4% Spandex",
02-05 05:11:37.533: E/JSON Parser(2110): "shop_prdt_seo_keywords":"Premium Cotton Leggins, cotton, sharani designs",
02-05 05:11:37.533: E/JSON Parser(2110): "shop_prdt_images":"1",
02-05 05:11:37.533: E/JSON Parser(2110): "shop_prdt_clicks":"84",
02-05 05:11:37.533: E/JSON Parser(2110): "shop_prdt_createdon":"2013-10-09 22:23:56",
02-05 05:11:37.533: E/JSON Parser(2110): "shop_prdt_updatedon":"",
02-05 05:11:37.533: E/JSON Parser(2110): "shop_prdt_status":"1"
02-05 05:11:37.533: E/JSON Parser(2110): },
02-05 05:11:37.533: E/JSON Parser(2110): {
02-05 05:11:37.533: E/JSON Parser(2110): "shop_prdt_id":"9",
02-05 05:11:37.533: E/JSON Parser(2110): "shop_cat_id":"2",
02-05 05:11:37.533: E/JSON Parser(2110): "shop_scat_id":"0",
02-05 05:11:37.533: E/JSON Parser(2110): "shop_prdt_code":"SKCT-38",
02-05 05:11:37.533: E/JSON Parser(2110): "shop_prdt_title":"Pure Silk Cotton",
02-05 05:11:37.533: E/JSON Parser(2110): "shop_prdt_listprice":"195",
02-05 05:11:37.533: E/JSON Parser(2110): "shop_prdt_ourprice":"150",
02-05 05:11:37.533: E/JSON Parser(2110): "shop_prdt_yousave":"45",
02-05 05:11:37.533: E/JSON Parser(2110): "shop_prdt_stock":"34",
02-05 05:11:37.533: E/JSON Parser(2110): "shop_prdt_weight":"110",
02-05 05:11:37.533: E/JSON Parser(2110): "shop_prdt_weight
02-05 05:11:37.543: D/AndroidRuntime(2110): Shutting down VM
02-05 05:11:37.543: W/dalvikvm(2110): threadid=1: thread exiting with uncaught exception (group=0xb4a4ab90)
02-05 05:11:37.573: E/AndroidRuntime(2110): FATAL EXCEPTION: main
02-05 05:11:37.573: E/AndroidRuntime(2110): Process: com.androidhive.jsonparsing, PID: 2110
02-05 05:11:37.573: E/AndroidRuntime(2110): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.androidhive.jsonparsing/com.androidhive.jsonparsing.AndroidJSONParsingActivity}: java.lang.NullPointerException
02-05 05:11:37.573: E/AndroidRuntime(2110): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2176)
02-05 05:11:37.573: E/AndroidRuntime(2110): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2226)
02-05 05:11:37.573: E/AndroidRuntime(2110): at android.app.ActivityThread.access$700(ActivityThread.java:135)
02-05 05:11:37.573: E/AndroidRuntime(2110): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1397)
02-05 05:11:37.573: E/AndroidRuntime(2110): at android.os.Handler.dispatchMessage(Handler.java:102)
02-05 05:11:37.573: E/AndroidRuntime(2110): at android.os.Looper.loop(Looper.java:137)
02-05 05:11:37.573: E/AndroidRuntime(2110): at android.app.ActivityThread.main(ActivityThread.java:4998)
02-05 05:11:37.573: E/AndroidRuntime(2110): at java.lang.reflect.Method.invokeNative(Native Method)
02-05 05:11:37.573: E/AndroidRuntime(2110): at java.lang.reflect.Method.invoke(Method.java:515)
02-05 05:11:37.573: E/AndroidRuntime(2110): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:777)
02-05 05:11:37.573: E/AndroidRuntime(2110): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:593)
02-05 05:11:37.573: E/AndroidRuntime(2110): at dalvik.system.NativeStart.main(Native Method)
02-05 05:11:37.573: E/AndroidRuntime(2110): Caused by: java.lang.NullPointerException
02-05 05:11:37.573: E/AndroidRuntime(2110): at com.androidhive.jsonparsing.AndroidJSONParsingActivity.onCreate(AndroidJSONParsingActivity.java:73)
02-05 05:11:37.573: E/AndroidRuntime(2110): at android.app.Activity.performCreate(Activity.java:5243)
02-05 05:11:37.573: E/AndroidRuntime(2110): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
02-05 05:11:37.573: E/AndroidRuntime(2110): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2140)
02-05 05:11:37.573: E/AndroidRuntime(2110): ... 11 more
02-05 05:11:39.853: I/Process(2110): Sending signal. PID: 2110 SIG: 9
02-05 05:35:06.173: D/AndroidRuntime(2165): Shutting down VM
02-05 05:35:06.173: W/dalvikvm(2165): threadid=1: thread exiting with uncaught exception (group=0xb4a4ab90)
02-05 05:35:06.183: E/AndroidRuntime(2165): FATAL EXCEPTION: main
02-05 05:35:06.183: E/AndroidRuntime(2165): Process: com.androidhive.jsonparsing, PID: 2165
02-05 05:35:06.183: E/AndroidRuntime(2165): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.androidhive.jsonparsing/com.androidhive.jsonparsing.AndroidJSONParsingActivity}: java.lang.IllegalArgumentException: Host name may not be null
02-05 05:35:06.183: E/AndroidRuntime(2165): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2176)
02-05 05:35:06.183: E/AndroidRuntime(2165): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2226)
02-05 05:35:06.183: E/AndroidRuntime(2165): at android.app.ActivityThread.access$700(ActivityThread.java:135)
02-05 05:35:06.183: E/AndroidRuntime(2165): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1397)
02-05 05:35:06.183: E/AndroidRuntime(2165): at android.os.Handler.dispatchMessage(Handler.java:102)
02-05 05:35:06.183: E/AndroidRuntime(2165): at android.os.Looper.loop(Looper.java:137)
02-05 05:35:06.183: E/AndroidRuntime(2165): at android.app.ActivityThread.main(ActivityThread.java:4998)
02-05 05:35:06.183: E/AndroidRuntime(2165): at java.lang.reflect.Method.invokeNative(Native Method)
02-05 05:35:06.183: E/AndroidRuntime(2165): at java.lang.reflect.Method.invoke(Method.java:515)
02-05 05:35:06.183: E/AndroidRuntime(2165): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:777)
02-05 05:35:06.183: E/AndroidRuntime(2165): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:593)
02-05 05:35:06.183: E/AndroidRuntime(2165): at dalvik.system.NativeStart.main(Native Method)
02-05 05:35:06.183: E/AndroidRuntime(2165): Caused by: java.lang.IllegalArgumentException: Host name may not be null
02-05 05:35:06.183: E/AndroidRuntime(2165): at org.apache.http.HttpHost.<init>(HttpHost.java:83)
02-05 05:35:06.183: E/AndroidRuntime(2165): at org.apache.http.impl.client.AbstractHttpClient.determineTarget(AbstractHttpClient.java:497)
02-05 05:35:06.183: E/AndroidRuntime(2165): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:487)
02-05 05:35:06.183: E/AndroidRuntime(2165): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:465)
02-05 05:35:06.183: E/AndroidRuntime(2165): at com.androidhive.jsonparsing.JSONParser.getJSONFromUrl(JSONParser.java:38)
02-05 05:35:06.183: E/AndroidRuntime(2165): at com.androidhive.jsonparsing.AndroidJSONParsingActivity.onCreate(AndroidJSONParsingActivity.java:69)
02-05 05:35:06.183: E/AndroidRuntime(2165): at android.app.Activity.performCreate(Activity.java:5243)
02-05 05:35:06.183: E/AndroidRuntime(2165): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
02-05 05:35:06.183: E/AndroidRuntime(2165): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2140)
02-05 05:35:06.183: E/AndroidRuntime(2165): ... 11 more
02-05 05:35:07.913: I/Process(2165): Sending signal. PID: 2165 SIG: 9
最佳答案
您的 JSON 文件附近有错误
"shop_prdt_images": "1""shop_prdt_clicks": "13",
应该是
"shop_prdt_images": "1",
"shop_prdt_clicks": "13",
关于android - 我的项目中的 Json 解析错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21574177/
我已经使用 vue-cli 两个星期了,直到今天一切正常。我在本地建立这个项目。 https://drive.google.com/open?id=0BwGw1zyyKjW7S3RYWXRaX24tQ
您好,我正在尝试使用 python 库 pytesseract 从图像中提取文本。请找到代码: from PIL import Image from pytesseract import image_
我的错误 /usr/bin/ld: errno: TLS definition in /lib/libc.so.6 section .tbss mismatches non-TLS reference
我已经训练了一个模型,我正在尝试使用 predict函数但它返回以下错误。 Error in contrasts<-(*tmp*, value = contr.funs[1 + isOF[nn]])
根据Microsoft DataConnectors的信息我想通过 this ODBC driver 创建一个从 PowerBi 到 PostgreSQL 的连接器使用直接查询。我重用了 Micros
我已经为 SoundManagement 创建了一个包,其中有一个扩展 MediaPlayer 的类。我希望全局控制这个变量。这是我的代码: package soundmanagement; impo
我在Heroku上部署了一个应用程序。我正在使用免费服务。 我经常收到以下错误消息。 PG::Error: ERROR: out of memory 如果刷新浏览器,就可以了。但是随后,它又随机发生
我正在运行 LAMP 服务器,这个 .htaccess 给我一个 500 错误。其作用是过滤关键字并重定向到相应的域名。 Options +FollowSymLinks RewriteEngine
我有两个驱动器 A 和 B。使用 python 脚本,我在“A”驱动器中创建一些文件,并运行 powerscript,该脚本以 1 秒的间隔将驱动器 A 中的所有文件复制到驱动器 B。 我在 powe
下面的函数一直返回这个错误信息。我认为可能是 double_precision 字段类型导致了这种情况,我尝试使用 CAST,但要么不是这样,要么我没有做对...帮助? 这是错误: ERROR: i
这个问题已经有答案了: Syntax error due to using a reserved word as a table or column name in MySQL (1 个回答) 已关闭
我的数据库有这个小问题。 我创建了一个表“articoli”,其中包含商品的品牌、型号和价格。 每篇文章都由一个 id (ID_ARTICOLO)` 定义,它是一个自动递增字段。 好吧,现在当我尝试插
我是新来的。我目前正在 DeVry 在线学习中级 C++ 编程。我们正在使用 C++ Primer Plus 这本书,到目前为止我一直做得很好。我的老师最近向我们扔了一个曲线球。我目前的任务是这样的:
这个问题在这里已经有了答案: What is an undefined reference/unresolved external symbol error and how do I fix it?
我的网站中有一段代码有问题;此错误仅发生在 Internet Explorer 7 中。 我没有在这里发布我所有的 HTML/CSS 标记,而是发布了网站的一个版本 here . 如您所见,我在列中有
如果尝试在 USB 设备上构建 node.js 应用程序时在我的树莓派上使用 npm 时遇到一些问题。 package.json 看起来像这样: { "name" : "node-todo",
在 Python 中,您有 None单例,在某些情况下表现得很奇怪: >>> a = None >>> type(a) >>> isinstance(a,None) Traceback (most
这是我的 build.gradle (Module:app) 文件: apply plugin: 'com.android.application' android { compileSdkV
我是 android 的新手,我的项目刚才编译和运行正常,但在我尝试实现抽屉导航后,它给了我这个错误 FAILURE: Build failed with an exception. What wen
谁能解释一下?我想我正在做一些非常愚蠢的事情,并且急切地等待着启蒙。 我得到这个输出: phpversion() == 7.2.25-1+0~20191128.32+debian8~1.gbp108
我是一名优秀的程序员,十分优秀!