I recently uploaded an update of my app to Google Play. When trying it out, I get an error when clicking on a manually added banner (e.g. not AdMob or anything like that). The click is setting of an AsyncTask that sends data to a php-script using POST. I use ProGuard so when I send the error report to myself I am only able to see the method in which the error is caused: doInBackground. I am also able to see that it is a NullPointerException. The strange thing is, when I run the app on my device from my computer using Eclipse, the error doesn't occur, so I can't really find what line is causing the NullPointerException. It has worked perfectly in previous versions of my app, and I haven't made any changes to this code. And when I look through the method doInBackground, I can't find any place where a NullPointerException might occur.
Here is the error message from my developers console, this is proguarded though:
java.lang.RuntimeException: An error occured while executing doInBackground()
at android.os.AsyncTask$3.done(AsyncTask.java:278)
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 android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:208)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
at java.lang.Thread.run(Thread.java:856)
Caused by: java.lang.NullPointerException
at se.nollekollen.main.d.a(Unknown Source)
at se.nollekollen.main.d.doInBackground(Unknown Source)
at android.os.AsyncTask$2.call(AsyncTask.java:264)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
... 5 more
And here is my doInBackground:
#Override
protected String doInBackground(String... arg0) {
String url_stats = "http://xxxxx.xx/statistik/sendStatistics_click.php";
List<NameValuePair> params = new ArrayList<NameValuePair>();
params.add(new BasicNameValuePair("activity", getClass().getEnclosingClass().getName().substring(20)));
params.add(new BasicNameValuePair("section", SECTION));
DefaultHttpClient httpClient = new DefaultHttpClient();
HttpPost httpPost = new HttpPost(url_stats);
try {
httpPost.setEntity(new UrlEncodedFormEntity(params));
} catch (UnsupportedEncodingException e1) {
e1.printStackTrace();
}
try {
httpClient.execute(httpPost);
} catch (ClientProtocolException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return null;
}
The only thing that could be null here is actually "SECTION", but that wouldn't cause a NullPointerException since the value can be null when creating a new BasicNameValuePair(key, value).
Can anyone find what could cause the NullPointerException? And how is it possible that this ONLY occurs when the app is downloaded from Google Play, and not when run from the computer?
Related
In my android app I've used a async task to handle my internet request. I achieved that by using the okhttp library, which makes it easy to make internet requests. I have a lot of the code surrounded my try/catch statements, but they somehow do not trigger when there is an unhandled exception so the app crashes. That only happens when the internet is disconnected or is slow in areas.
I've looked for similar posts, but found out that people who had the same problems didn't try/catch, so the exceptions weren't handled
I've also tried to make a checker for the internet accessibility, but that didn't work out too well, because i would much rather do it with clean try-catching.
private class prenesi extends AsyncTask<String, Void, String>
{
String odgovor = null;
protected String doInBackground(String... params)
{
OkHttpClient client = new OkHttpClient();
RequestBody vsebina = new FormEncodingBuilder()
.add("kraj", params[0])
.build();
Request request = new Request.Builder()
.url("http://mypage.com/login.php")
.post(vsebina)
.build();
Response response = null;
try
{
response = client.newCall(request).execute();
}
catch (IOException e)
{
e.printStackTrace();
}
if (!response.isSuccessful())
{
odgovor = "Napaka.";
}
else
try
{
odgovor = response.body().string();
}
catch (IOException e)
{
e.printStackTrace();
}
return odgovor;
}
}
The devconsole says the problem is in the doInBackground() and i guess it caused because the null pointer exception, though I'm not entirely sure what that means:
java.lang.RuntimeException: An error occured while executing doInBackground()
at android.os.AsyncTask$3.done(AsyncTask.java:299)
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 android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:230)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
at java.lang.Thread.run(Thread.java:856)
Caused by: java.lang.NullPointerException
Could somebody point me towards the flaw please. I'm stuck with this.
All the help will be very appreciated, hope to solve this problem soon.
Thanks for contributing.
It seems that you forgot to initialize your String value. Run it by first setting String odgovor=""; instead of String odgovor= null;
Try modifying the code to this
String odgovor="";
try{
response = client.newCall(request).execute();
if (!response.isSuccessful()) {
odgovor = "Napaka.";
} else{
odgovor = response.body().string();
}} catch (IOException e) {
e.printStackTrace();
}
Seems the problem in the end was with the isSuccessul method, which was a bit cheesy, idk why, but instead of it i used if(response == null).
How do you handle the RuntimeException when AsyncTask couldn't connect to server since server is "down" for some reason?
What do I try is a bunch of catch blocks (doesn't help):
try {
// Create Request to server and get response
HttpGet httpget = new HttpGet(activity.getString(R.string.get_channels_lang_host));
ResponseHandler<String> responseHandler = new BasicResponseHandler();
downloadedString = httpclient.execute(httpget, responseHandler);
}catch (MalformedURLException e) {
Log.e("URL:","is a malformed URL");
e.printStackTrace();
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
Log.e("URL:"," UnsupportedEncodingException");
} catch (ClientProtocolException e) {
e.printStackTrace();
Log.e("URL:"," ClientProtocolException");
} catch (SocketTimeoutException e) {
e.printStackTrace();
Log.e("URL:"," SocketTimeoutException");
} catch (ConnectTimeoutException e) {
e.printStackTrace();
Log.e("URL:"," ConnectTimeoutException");
} catch (IOException e) {
Log.e("URL:","IOException");
e.printStackTrace();
}
if (downloadedString != null) {
//parse request to object
dataChannelsLangArrayList = JsonParser.getDataChannelsLang(downloadedString);
} else {
Toast.makeText(ActivityLoading.this, "Failed to load data. Restarting...", Toast.LENGTH_LONG).show();
Global.restartApp(ActivityLoading.this);
}
i'm still getting the runtime error:
04-09 11:31:29.610 3696-3719/tenkol.design.com.imbrecords E/AndroidRuntime﹕ FATAL EXCEPTION: AsyncTask #1
java.lang.RuntimeException: An error occured while executing doInBackground()
at android.os.AsyncTask$3.done(AsyncTask.java:299)
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 android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:230)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
at java.lang.Thread.run(Thread.java:864)
Caused by: java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.prepare()
at android.os.Handler.<init>(Handler.java:121)
at android.widget.Toast$TN.<init>(Toast.java:322)
at android.widget.Toast.<init>(Toast.java:91)
at android.widget.Toast.makeText(Toast.java:238)
at tenkol.design.com.imbrecords.Global.restartApp(Global.java:115)
at tenkol.design.com.imbrecords.ActivityLoading$LoadingAsyncTask.getChannelsLang(ActivityLoading.java:249)
at tenkol.design.com.imbrecords.ActivityLoading$LoadingAsyncTask.doInBackground(ActivityLoading.java:157)
at tenkol.design.com.imbrecords.ActivityLoading$LoadingAsyncTask.doInBackground(ActivityLoading.java:141)
at android.os.AsyncTask$2.call(AsyncTask.java:287)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
at java.util.concurrent.FutureTask.run(FutureTask.java:137)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:230)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
at java.lang.Thread.run(Thread.java:864)
I'm mostly interested in two cases:
When server doesn't respond at all;
When the time spend for request is too big (i.e. with slow Internet).
What is the proper way to handle those?
Can't create handler inside thread that has not called Looper.prepare()
Well, you have created a Handler, but the thread it is linked to doesn't have any message queue to post stuff on.
Try new Handler(Looper.getMainLooper()) for a handler linked to main thread.
Then you can post a Runnable on it which shows a toast.
But seriously, why not collect exception and result both and handle it all in onPostExecute() ?
Public class Result<T>{
public T data;
public Exception exception;
public String message;
}
Im trying to create an app that gets a json object from a url.
This is proving to be unnecessarily frustrating as it keeps crashing on the activity that is supposed to load and parse the json object. It just pops up the message "Unfortunately, (AppName) has stopped." and then exits the application. The data from the JSON is never shown on the screen. Here is the code with the activity and the JSON parsing
package com.example.Accomplist;
import android.app.Activity;
import android.os.AsyncTask;
import android.os.Bundle;
import android.os.RemoteException;
import android.widget.TextView;
import android.widget.Toast;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.util.EntityUtils;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import java.io.IOException;
/**
* Created with IntelliJ IDEA.
* User: DESAI_628IL
* Date: 3/1/13
* Time: 7:34 PM
* To change this template use File | Settings | File Templates.
*/
public class MainScreen extends Activity{
TextView myTextView;
// HttpClient client;
// url to make request
final static String url = "http://accomplist.herokuapp.com/api/v1/sharedevent/2/?format=json";
private static final String TAG_EVENT="event"; //A JSON object within the JSON object that will be returned by JSONParse()
private static final String TAG_DESCRIPTION="description"; //A JSON tag within the JSON object EVENT
private static String eventString="Yo";
static JSONObject json;
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main_screen);
new JSONParse().execute(url);
}
private class JSONParse extends AsyncTask<String, String, String> {
HttpClient client;
JSONObject jsonObj= null;
#Override
protected String doInBackground(String... jsonurl) {
StringBuilder url= new StringBuilder(String.valueOf(jsonurl));
HttpGet get= new HttpGet(url.toString());
HttpResponse r= null;
try {
r = client.execute(get);
} catch (IOException e) {
e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
}
int status= r.getStatusLine().getStatusCode();
if (status==200){
HttpEntity e=r.getEntity();
String data= null;
try {
data = EntityUtils.toString(e);
} catch (IOException e1) {
e1.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
}
try {
jsonObj = new JSONObject(data);
} catch (JSONException e1) {
e1.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
}
try {
JSONObject eventJson= jsonObj.getJSONObject(TAG_EVENT);
eventString= eventJson.getString(TAG_DESCRIPTION);
}
catch (JSONException e1) {
eventString="Couldn't Parse Data";
}
return eventString;
}
else{
return eventString;
}
}
protected void onProgressUpdate(String... progress) {
Toast loadingToast= Toast.makeText(getApplicationContext(), "Loading", Toast.LENGTH_LONG);
loadingToast.show();
}
protected void onPostExecute(String result) {
eventString=result;
myTextView = (TextView)findViewById(R.id.textView1);
myTextView.setText(eventString);
}
}
}
I hope someone can help. Ive been stuck on this for the longest time. Ive tried many things. Ive tried different ways of getting the JSON object from the url, putting the parsing code in a different class, and lots of other small things. Any help would be appreciated. Here is the LogCat error report
02-26 12:18:46.691: ERROR/ThrottleService(324): problem during onPollAlarm: java.lang.IllegalStateException: problem parsing stats: java.io.FileNotFoundException: /proc/net/xt_qtaguid/iface_stat_all: open failed: ENOENT (No such file or directory)
02-26 12:19:53.601: WARN/dalvikvm(4073): threadid=11: thread exiting with uncaught exception (group=0x40a71930)
02-26 12:19:55.121: WARN/dalvikvm(4073): threadid=12: thread exiting with uncaught exception (group=0x40a71930)
02-26 12:19:57.632: WARN/InputMethodManagerService(324): Got RemoteException sending setActive(false) notification to pid 4073 uid 10048
02-26 12:20:03.452: WARN/dalvikvm(4094): threadid=11: thread exiting with uncaught exception (group=0x40a71930)
02-26 12:20:04.744: ERROR/AndroidRuntime(4094): FATAL EXCEPTION: AsyncTask #1
java.lang.RuntimeException: An error occured while executing doInBackground()
at android.os.AsyncTask$3.done(AsyncTask.java:299)
at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:352)
at java.util.concurrent.FutureTask.setException(FutureTask.java:219)
at java.util.concurrent.FutureTask.run(FutureTask.java:239)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:230)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
at java.lang.Thread.run(Thread.java:856)
Caused by: java.lang.IllegalArgumentException: Illegal character in path at index 0: [Ljava.lang.String;#40d12070
at java.net.URI.create(URI.java:727)
at org.apache.http.client.methods.HttpGet.<init>(HttpGet.java:75)
at com.example.Accomplist.MainScreen$JSONParse.doInBackground(MainScreen.java:84)
at com.example.Accomplist.MainScreen$JSONParse.doInBackground(MainScreen.java:78)
at android.os.AsyncTask$2.call(AsyncTask.java:287)
at java.util.concurrent.FutureTask.run(FutureTask.java:234)
... 4 more
02-26 12:20:10.512: WARN/InputMethodManagerService(324): Got RemoteException sending setActive(false) notification to pid 4094 uid 10048
02-26 12:20:24.401: WARN/dalvikvm(4111): threadid=11: thread exiting with uncaught exception (group=0x40a71930)
02-26 12:20:24.441: ERROR/AndroidRuntime(4111): FATAL EXCEPTION: AsyncTask #1
java.lang.RuntimeException: An error occured while executing doInBackground()
at android.os.AsyncTask$3.done(AsyncTask.java:299)
at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:352)
at java.util.concurrent.FutureTask.setException(FutureTask.java:219)
at java.util.concurrent.FutureTask.run(FutureTask.java:239)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:230)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
at java.lang.Thread.run(Thread.java:856)
Caused by: java.lang.IllegalArgumentException: Illegal character in path at index 0: [Ljava.lang.String;#40d12038
at java.net.URI.create(URI.java:727)
at org.apache.http.client.methods.HttpGet.<init>(HttpGet.java:75)
at com.example.Accomplist.MainScreen$JSONParse.doInBackground(MainScreen.java:84)
at com.example.Accomplist.MainScreen$JSONParse.doInBackground(MainScreen.java:78)
at android.os.AsyncTask$2.call(AsyncTask.java:287)
at java.util.concurrent.FutureTask.run(FutureTask.java:234)
... 4 more
02-26 12:20:29.411: WARN/InputMethodManagerService(324): Got RemoteException sending setActive(false) notification to pid 4111 uid 10048
try something like this..
HttpClient client = new DefaultHttpClient();
// Perform a GET request for a JSON list
HttpUriRequest request = new HttpGet("https://somejson.json");
// Get the response that sends back
HttpResponse response = null;
try {
response = client.execute(request);
} catch (ClientProtocolException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
Try with this
new JSONParse().execute("");
instead of
new JSONParse().execute(url);
can u paste your logcat message so that i can help u more accurately.
The parameter in the doInbackgroud() is work like an array so that you can pass multiple argument to this method while calling the execute method on AsyncTask. The first passed parameter would be stored on the 0th position and so on. Since you are only passing one parameter to the execute method, that parameter would be stored on the 0th position... So you need to get the URL from jsonurl[0]
Try with
StringBuilder url= new StringBuilder(String.valueOf(jsonurl[0]));
Change your doInBackground method as :
#Override
protected String doInBackground(String... jsonurl) {
StringBuilder url= new StringBuilder(String.valueOf(jsonurl[0]));
HttpGet get= new HttpGet(url.toString());
HttpResponse r= null;
currently you are passing wrong url to get data form web service. see following to known move how we get value from varargs inside doInBackground method
What does the "..." mean in a parameter list? doInBackground(String... params)
You Haven't get your Http client
set
HttpClient httpClient = new DefaultHttpClient(); in your doInBackGround()
You have 2 mistakes
1. StringBuilder url= new StringBuilder(String.valueOf(jsonurl[0]));
// jsonurl[0]
2. client = new DefaultHttpClient();
// Add this line too
I am working with reverse geocoding in Android. My code successfully worked until yesterday, but now it stopped working on my Android device (samsung S2). But it works in the emulator. When I compile on the device it shows the following errors in logcat:
02-28 12:56:22.800: W/System.err(9048): java.io.IOException: Service not Available
02-28 12:56:22.815: W/System.err(9048): at android.location.Geocoder.getFromLocation(Geocoder.java:136)
02-28 12:56:22.815: W/System.err(9048): at in.wptrafficanalyzer.locationreversegeocoding.MainActivity$ReverseGeocodingTask.doInBackground(MainActivity.java:154)
02-28 12:56:22.830: W/System.err(9048): at in.wptrafficanalyzer.locationreversegeocoding.MainActivity$ReverseGeocodingTask.doInBackground(MainActivity.java:1)
02-28 12:56:22.830: W/System.err(9048): at android.os.AsyncTask$2.call(AsyncTask.java:264)
02-28 12:56:22.830: W/System.err(9048): at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
02-28 12:56:22.835: W/System.err(9048): at java.util.concurrent.FutureTask.run(FutureTask.java:137)
02-28 12:56:22.835: W/System.err(9048): at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:208)
02-28 12:56:22.835: W/System.err(9048): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
02-28 12:56:22.845: W/System.err(9048): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
02-28 12:56:22.845: W/System.err(9048): at java.lang.Thread.run(Thread.java:856)
This is a known issue. A possible workaround is that you have to reboot the device. I was told that I works then again.
It happens caused by multiple reasons. I've had some devices that always did it, while the same code worked fine in others.
A nice workaround is catching the IOException and firing the google maps web api instead;
public static JSONObject getLocationInfo(String address) {
HttpGet httpGet = new HttpGet("http://maps.google.com/maps/api/geocode/json?address="
+ address + "&ka&sensor=false");
HttpClient client = new DefaultHttpClient();
HttpResponse response;
StringBuilder stringBuilder = new StringBuilder();
try {
response = client.execute(httpGet);
HttpEntity entity = response.getEntity();
InputStream stream = entity.getContent();
int b;
while ((b = stream.read()) != -1) {
stringBuilder.append((char) b);
}
} catch (ClientProtocolException e) {
} catch (IOException e) {
}
JSONObject jsonObject = new JSONObject();
try {
jsonObject = new JSONObject(stringBuilder.toString());
} catch (JSONException e) {
e.printStackTrace();
}
return jsonObject;
}
The returned value you can extract like this;
lon = ((JSONArray) jsonObject.get("results")).getJSONObject(0)
.getJSONObject("geometry").getJSONObject("location").getDouble("lng");
lat = ((JSONArray) jsonObject.get("results")).getJSONObject(0)
.getJSONObject("geometry").getJSONObject("location").getDouble("lat");
it is working now........... use this trick.
simply edit the project.properties
# Project target
target=Google Inc.:Google APIs:16
The reason is that the Geocoder class is present in the core Android framework, but depends on code contributed by the Google APIs to function properly. Even if your AVD includes the Google APIs, your project still needs to be built against that specific build target.
I am reading the youtube response in Stream and converting it to String. using the below code:
URL: http://gdata.youtube.com/feeds/api/users/cnn/uploads?&v=2&max-results=25&alt=json
private String convertStreamToString(InputStream is) {
BufferedReader reader = new BufferedReader(new InputStreamReader(is));
StringBuilder sb = new StringBuilder();
String line = null;
try {
while ((line = reader.readLine()) != null) {
sb.append(line + "\n");
}
} catch (IOException e) {
e.printStackTrace();
} finally {
try {
is.close();
} catch (IOException e) {
e.printStackTrace();
}
}
return sb.toString();
}
This code is working in fine in all devices except Android 4.0 devices. I am getting the below logcat:
java.lang.RuntimeException: An error occured while executing doInBackground()
at android.os.AsyncTask$3.done(AsyncTask.java:278)
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 android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:208)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
at java.lang.Thread.run(Thread.java:856)
Caused by: java.lang.OutOfMemoryError
at java.lang.AbstractStringBuilder.enlargeBuffer(AbstractStringBuilder.java:94)
at java.lang.AbstractStringBuilder.append0(AbstractStringBuilder.java:145)
at java.lang.StringBuilder.append(StringBuilder.java:216)
at com.android.mypack.MyApplications.convertStreamToString(MyApplications.java:959)
at com.android.mypack.MyApplications.access$61(MyApplications.java:951)
at com.android.mypack.MyApplications$YoutubeTask.doInBackground(MyApplications.java:2303)
at com.android.mypack.MyApplications$YoutubeTask.doInBackground(MyApplications.java:1)
at android.os.AsyncTask$2.call(AsyncTask.java:264)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
... 5 more
java.lang.OutOfMemoryError
at java.lang.AbstractStringBuilder.enlargeBuffer(AbstractStringBuilder.java:94)
at java.lang.AbstractStringBuilder.append0(AbstractStringBuilder.java:145)
at java.lang.StringBuilder.append(StringBuilder.java:216)
at com.android.mypack.MyApplications.convertStreamToString(MyApplications.java:959)
at com.android.mypack.MyApplications.access$61(MyApplications.java:951)
at com.android.mypack.MyApplications$YoutubeTask.doInBackground(MyApplications.java:2303)
at com.android.mypack.MyApplications$YoutubeTask.doInBackground(MyApplications.java:1)
at android.os.AsyncTask$2.call(AsyncTask.java:264)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
at java.util.concurrent.FutureTask.run(FutureTask.java:137)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:208)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
at java.lang.Thread.run(Thread.java:856)
Please help me to overcome this error.
Thanks in Advance.
Well, OutOfMemoryErrors are coming obviously when the virtual machine runs out of memory. The important point here is that the exact stack trace might not be informative, because it could happen that another thread uses all of the memory. Or something memory-consuming happened on this thread before this code, and this code was only the "last straw". This URL certainly does not contain too many bytes, I think the problem is in another place.
You could try a memory analyzer:
Android ==> Memory Analysing ==> Eclipse memory analyzer?