2013-11-26 2 views
0

충돌 보고서를 수신하고 있지만 이해가되지 않습니다. 텍스트는 null이 아닐 수 있습니다. 그것은 내가 테스트 한 모든 장치에서 작동하지만 어떻게 든 그것은 소수의 사람들에게 충돌합니다. Galaxy Indulge (SCH-R910)를 사용하여보고 된 최신 사례. 다음은 보고서Google Play에서 오류 보고서를 암호화합니다.

java.lang.RuntimeException: An error occured while executing doInBackground() 
at android.os.AsyncTask$3.done(AsyncTask.java:200) 
at java.util.concurrent.FutureTask$Sync.innerSetException(FutureTask.java:273) 
at java.util.concurrent.FutureTask.setException(FutureTask.java:124) 
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:307) 
at java.util.concurrent.FutureTask.run(FutureTask.java:137) 
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1068) 
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:561) 
at java.lang.Thread.run(Thread.java:1096) 
Caused by: java.lang.IllegalArgumentException: Text may not be null 
at org.apache.http.entity.mime.content.StringBody.<init>(StringBody.java:94) 
at org.apache.http.entity.mime.content.StringBody.<init>(StringBody.java:113) 
at com.pff.photosfromfriends.UploadPicture$uploadthephoto.doInBackground(UploadPicture.java:313) 
at com.pff.photosfromfriends.UploadPicture$uploadthephoto.doInBackground(UploadPicture.java:1) 
at android.os.AsyncTask$2.call(AsyncTask.java:185) 
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305) 
... 4 more 

그리고 여기가 업로드

class uploadthephoto extends AsyncTask<String, String, String> { 

    @Override 
    protected void onPreExecute() { 
     super.onPreExecute(); 
     pDialog = new ProgressDialog(UploadPicture.this); 
     pDialog.setMessage("Uploading Picture"); 
     pDialog.setIndeterminate(false); 
     pDialog.setCancelable(true); 
     pDialog.show(); 

    } 

    @Override 
    protected String doInBackground(String... args) { 

     HttpClient client = new DefaultHttpClient(); 
     HttpPost post = new HttpPost(POST_COMMNT_URL); 

     try { 

      MultipartEntity entity = new MultipartEntity(
        HttpMultipartMode.BROWSER_COMPATIBLE); 
      File file = new File(theimagepath); 
      cbFile = new FileBody(file, "image/jpeg"); 
      entity.addPart("username", new StringBody(username, 
        Charset.forName("UTF-8"))); 
      entity.addPart("name", new StringBody(name, 
        Charset.forName("UTF-8"))); 
      entity.addPart("album", new StringBody(spinselected, Charset.forName("UTF-8"))); 
      entity.addPart("picture", cbFile); 
      post.setEntity(entity); 


      HttpResponse response1 = client.execute(post); 
      HttpEntity resEntity = response1.getEntity(); 
      String Response = EntityUtils.toString(resEntity); 
      Log.d("Response", Response); 

      json = new JSONObject(Response); 
      success_number = json.getInt("success"); 

      if (success_number == 1) { // picture added! 
       return json.getString("message"); 

      } else { 
       Log.d("Login Failure!", json.getString(message)); 
       return json.getString("message"); 

      } 

     } catch (IOException e) { 
      Log.e("asdf", e.getMessage(), e); 

     } catch (JSONException e) { 
      // TODO Auto-generated catch block 
      e.printStackTrace(); 
     } 
     return null; 

    } 

    protected void onPostExecute(String file_url) { 
     pDialog.dismiss(); 
     if (file_url != null) { 
      Toast.makeText(UploadPicture.this, file_url, Toast.LENGTH_LONG) 
        .show(); 
     } 

    } 
} 

// Username is from SharedPreferences 
// Name is from SharedPreferences 
// Album is from a Spinner 
// Picture is chosen from their gallery 

는 일부 장치에 오류가 발생하는 이유 어떤 생각에 대한 내 코드입니다? 고맙습니다.

+1

313 행은 무엇입니까? –

+0

entity.addPart ("album", new StringBody (spinselected, Charset.forName ("UTF-8")))); – JeffK

+0

이 @Override \t onItemSelected 공공 무효 (어댑터 뷰 AdapterView 는 arg0,보기 ARG1, INT 위치, \t \t \t 긴에서 arg3) { \t \t // TODO 자동 생성 방법 스텁 \t \t spinselected = (문자열) upSpinner에서 온다 .getItemAtPosition (position); \t \t Log.d ("스핀 선택", 스핀 선택); \t} – JeffK

답변

1

그것은이 라인이다 :

entity.addPart("album", new StringBody(spinselected, Charset.forName("UTF-8")));

은 분명히 spinselected가 null이 null 파라미터로 구성되어있는 경우 StringBody 오류가 발생합니다.

Caused by: java.lang.IllegalArgumentException: Text may not be null 
at org.apache.http.entity.mime.content.StringBody.<init>(StringBody.java:94) 
+0

일부 장치에서는 괜찮습니까? 다른 장치에서는 null이 될 수있는 단서가 있습니까? oncreate 동안 스피너는 데이터베이스에서 채워집니다. – JeffK

+0

나는 그것에 대해 너무 확신하지 못합니다. 이 시점에서 약간의 붕대가 있지만 적어도 충돌이 발생하지 않도록 널 체크를 추가 할 것입니다. –

관련 문제