Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

java.lang.RuntimeException: An error occured while executing doInBackground() #1006

Closed
TerrenceYY opened this issue Nov 20, 2018 · 5 comments

Comments

@TerrenceYY
Copy link

java.lang.RuntimeException: An error occured while executing doInBackground()

at android.os.AsyncTask$3.done(AsyncTask.java:300)

at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:355)

at java.util.concurrent.FutureTask.setException(FutureTask.java:222)

at java.util.concurrent.FutureTask.run(FutureTask.java:242)

at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)

at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)

at java.lang.Thread.run(Thread.java:848)

Caused by: java.lang.OutOfMemoryError

at java.lang.String.<init>(String.java:255)

at java.lang.String.<init>(String.java:228)

at com.airbnb.lottie.LottieComposition$Factory.fromInputStream(LottieComposition.java:161)

at com.airbnb.lottie.FileCompositionLoader.doInBackground(FileCompositionLoader.java:17)

at com.airbnb.lottie.FileCompositionLoader.doInBackground(FileCompositionLoader.java:7)

at android.os.AsyncTask$2.call(AsyncTask.java:288)

at java.util.concurrent.FutureTask.run(FutureTask.java:237)

... 3 more

java.lang.OutOfMemoryError

at java.lang.String.<init>(String.java:255)

at java.lang.String.<init>(String.java:228)

at com.airbnb.lottie.LottieComposition$Factory.fromInputStream(LottieComposition.java:161)

at com.airbnb.lottie.FileCompositionLoader.doInBackground(FileCompositionLoader.java:17)

at com.airbnb.lottie.FileCompositionLoader.doInBackground(FileCompositionLoader.java:7)

at android.os.AsyncTask$2.call(AsyncTask.java:288)

at java.util.concurrent.FutureTask.run(FutureTask.java:237)

at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)

at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)

at java.lang.Thread.run(Thread.java:848)
@gpeal
Copy link
Collaborator

gpeal commented Nov 22, 2018

This isn't Lottie related. Your app was running out of memory and Lottie happened to be the one thing that put it over the edge.

@gpeal gpeal closed this as completed Nov 22, 2018
@AnkitKadam567
Copy link

My Code:
`package com.example.ankitkadam.map;

import android.os.AsyncTask;
import android.util.Log;

import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.model.BitmapDescriptorFactory;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.MarkerOptions;

import java.io.IOException;
import java.util.HashMap;
import java.util.List;

/**

  • Created by Ankit Kadam on 17-02-2019.
    */

class GetNearbyPlacesData extends AsyncTask<Object, String, String> {

private String googlePlacesData;
private GoogleMap mMap;
String url;

@Override
protected String doInBackground(Object... objects){
    mMap = (GoogleMap)objects[0];
    url = (String)objects[1];

    DownloadURL downloadURL = new DownloadURL();
    try {
        googlePlacesData = downloadURL.readUrl(url);
    } catch (IOException e) {
        e.printStackTrace();
    }

    return googlePlacesData;
}

@Override
protected void onPostExecute(String s){

    List<HashMap<String, String>> nearbyPlaceList;
    DataParser parser = new DataParser();
    nearbyPlaceList = parser.parse(s);
    Log.d("nearbyplacesdata","called parse method");
    showNearbyPlaces(nearbyPlaceList);
}

private void showNearbyPlaces(List<HashMap<String, String>> nearbyPlaceList)
{
    for(int i = 0; i < nearbyPlaceList.size(); i++)
    {
        MarkerOptions markerOptions = new MarkerOptions();
        HashMap<String, String> googlePlace = nearbyPlaceList.get(i);

        String placeName = googlePlace.get("place_name");
        String vicinity = googlePlace.get("vicinity");
        double lat = Double.parseDouble( googlePlace.get("lat"));
        double lng = Double.parseDouble( googlePlace.get("lng"));

        LatLng latLng = new LatLng( lat, lng);
        markerOptions.position(latLng);
        markerOptions.title(placeName + " : "+ vicinity);
        markerOptions.icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_BLUE));

        mMap.addMarker(markerOptions);
        mMap.moveCamera(CameraUpdateFactory.newLatLng(latLng));
        mMap.animateCamera(CameraUpdateFactory.zoomTo(11));
    }
}

}
ERROR:02-19 09:40:26.303 3147-3270/com.example.ankitkadam.map E/AndroidRuntime: FATAL EXCEPTION: AsyncTask #1
Process: com.example.ankitkadam.map, PID: 3147
java.lang.RuntimeException: An error occured while executing doInBackground()
at android.os.AsyncTask$3.done(AsyncTask.java:304)
at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:355)
at java.util.concurrent.FutureTask.setException(FutureTask.java:222)
at java.util.concurrent.FutureTask.run(FutureTask.java:242)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at java.lang.Thread.run(Thread.java:818)
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void java.io.InputStream.close()' on a null object reference
at com.example.ankitkadam.map.DownloadURL.readUrl(DownloadURL.java:49)
at com.example.ankitkadam.map.GetNearbyPlacesData.doInBackground(GetNearByPlacesData.java:33)
at com.example.ankitkadam.map.GetNearbyPlacesData.doInBackground(GetNearByPlacesData.java:20)
at android.os.AsyncTask$2.call(AsyncTask.java:292)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231) 
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112) 
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587) 
at java.lang.Thread.run(Thread.java:818) `

@gpeal
Copy link
Collaborator

gpeal commented Feb 19, 2019

@AnkitKadam567 that is also unrelated to Lottie.

@AnkitKadam567
Copy link

what is the reason behind this? Why am I getting this error?

@ameetpawar00
Copy link

found any solution yet???

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants