I think there's an error here. Help me.
E/libEGL: validate_display:99 error 3008 (EGL_BAD_DISPLAY)
This error also appears.
Tab1Fragments.java
public class Tab1Fragment extends Fragment {
private static String GOOGLE_YOUTUBE_API_KEY = "----------------------"; //
private static String CHANNEL_ID="UCyn-----------------";
private static String CHANNLE_GET_URL = "https://www.googleapis.com/youtube/v3/search?part=snippet&order=date&channelId=" + CHANNEL_ID + "&maxResults=20&key=" + GOOGLE_YOUTUBE_API_KEY + "";
private RecyclerView mList_videos = null;
private VideoPostAdapter adapter = null;
private ArrayList<YoutubeDataModel> mListData = new ArrayList<>();
public Tab1Fragment() {
// // Required empty public constructor
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// // Inflate the layout for this
View view = inflater.inflate(R.layout.fragment_tab1, container, false);
mList_videos=(RecyclerView) view.findViewById(R.id.mList_videos);
initList(mListData);
new RequstYoutubeAPI().execute();
return view;
}
private void initList(ArrayList<YoutubeDataModel> mListData) {
mList_videos.setLayoutManager(new LinearLayoutManager(getActivity()));
adapter = new VideoPostAdapter(getActivity(), mListData);
mList_videos.setAdapter(adapter);
}
//creat an AsyncTask to get all tha data form youtube
private class RequstYoutubeAPI extends AsyncTask<Void, String, String>{
@Override
protected void onPreExecute() {
super.onPreExecute();
}
@Override
protected String doInBackground(Void... params) {
HttpClient httpClient = new DefaultHttpClient();
HttpGet httpGet = new HttpGet(CHANNLE_GET_URL);
Log.e("URL", CHANNLE_GET_URL);
try {
HttpResponse response = httpClient.execute(httpGet);
HttpEntity httpEntity = response.getEntity();
String json = EntityUtils.toString(httpEntity);
return json;
} } catch (IOException e) {
e.printStackTrace();
}
return null;
}
@Override
protected void onPostExecute(String response) {
super.onPostExecute(response);
if (response != null) {
try {
JSONObject jsonObject = new JSONObject(response);
Log.e("response", jsonObject.toString());
mListData = parseVideoListFromResponse(jsonObject);
initList(mListData);
} } catch (JSONException e) {
e.printStackTrace();
}
}
}
}
private ArrayList<YoutubeDataModel> parseVideoListFromResponse(JSONObject jsonObject) {
ArrayList<YoutubeDataModel> mList = new ArrayList<>();
if (jsonObject.has("items")) {
try {
JSONArray jsonArray = jsonObject.getJSONArray("items");
for (int i = 0; i < jsonArray.length(); i++) {
JSONObject json = jsonArray.getJSONObject(i);
if (json.has("id")) {
JSONObject jsonID = json.getJSONObject("id");
if (jsonID.has("kind")) {
if (jsonID.getString("kind").equals("youtube#video")) {
//get the data from snippet
YoutubeDataModel youtubeObject = new YoutubeDataModel();
JSONObject jsonSnippet = json.getJSONObject("snippet");
String title = jsonSnippet.getString("title");
String description = jsonSnippet.getString("description");
String publishedAt = jsonSnippet.getString("publishedAt");
String thumbnail = jsonSnippet.getJSONObject("thumbnails").getJSONObject("high").getString("url");
youtubeObject.setTitle(title);
youtubeObject.setDescription(description);
youtubeObject.setPublishedAt(publishedAt);
youtubeObject.setThumbnail(thumbnail);
// // youtubeObject.setVideo_id(video_id);
mList.add(youtubeObject);
}
}
}
}
} } catch (JSONException e) {
e.printStackTrace();
}
}
return mList;
}
}
E/AndroidRuntime: FATAL EXCEPTION: AsyncTask #1
Process: com.app, PID: 19331
java.lang.RuntimeException: An error occurred while executing doInBackground()
at android.os.AsyncTask$3.done(AsyncTask.java:354)
at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:383)
at java.util.concurrent.FutureTask.setException(FutureTask.java:252)
at java.util.concurrent.FutureTask.run(FutureTask.java:271)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:245)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
at java.lang.Thread.run(Thread.java:764)
Caused by: java.lang.NoClassDefFoundError: Failed resolution of: Lorg/apache/commons/logging/LogFactory;
at org.apache.http.impl.client.AbstractHttpClient.<init>(AbstractHttpClient.java:182)
at org.apache.http.impl.client.DefaultHttpClient.<init>(DefaultHttpClient.java:150)
at com.app.fragments.Tab1Fragment$RequstYoutubeAPI.doInBackground(Tab1Fragment.java:83)
at com.app.fragments.Tab1Fragment$RequstYoutubeAPI.doInBackground(Tab1Fragment.java:73)
at android.os.AsyncTask$2.call(AsyncTask.java:333)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:245)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
at java.lang.Thread.run(Thread.java:764)
Caused by: java.lang.ClassNotFoundException: Didn't find class "org.apache.commons.logging.LogFactory" on path: DexPathList[[zip file "/data/app/com.app-33wbdaOQAv_7eyC_An1aAg==/base.apk"],nativeLibraryDirectories=[/data/app/com.app-33wbdaOQAv_7eyC_An1aAg==/lib/arm64, /system/lib64, /system/vendor/lib64]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:134)
at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
at org.apache.http.impl.client.AbstractHttpClient.<init>(AbstractHttpClient.java:182)
at org.apache.http.impl.client.DefaultHttpClient.<init>(DefaultHttpClient.java:150)
at com.app.fragments.Tab1Fragment$RequstYoutubeAPI.doInBackground(Tab1Fragment.java:83)
at com.app.fragments.Tab1Fragment$RequstYoutubeAPI.doInBackground(Tab1Fragment.java:73)
at android.os.AsyncTask$2.call(AsyncTask.java:333)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:245)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
at java.lang.Thread.run(Thread.java:764)
This is an error log.
com.app.fragments.Tab1Fragment$RequstYoutubeAPI.doInBackground(Tab1Fragment.java:83)
at com.app.fragments.Tab1Fragment$RequstYoutubeAPI.doInBackground(Tab1Fragment.java:73)
I think this is the problem I'd appreciate your help.
I managed to solve it worked out.
You can put it in the application in the manifesto
© 2024 OneMinuteCode. All rights reserved.