Cannot Connect to Weather API - java

I need some help. Here are my codes and my errors. I am a beginner and using weather.org for API.
I have searched all over the internet but all of them have the same answer. It's the
android:usesCleartextTraffic="true"
and
android:networkSecurityConfig="#xml/network_security_config"
My XML application tag has:
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
<application
...
android:usesCleartextTraffic="true"
android:networkSecurityConfig="#xml/network_security_config"
...>
<uses-library android:name="org.apache.http.legacy"
android:required="false"/>
</application>
And my MainActivity is:
public void getData(){
final String url = "http://api.openweathermap.org/data/2.5/weather?q=Manila&appid=1fef2628db7b44791ee1029f1999137a&units=imperial";
JsonObjectRequest req = new JsonObjectRequest(Request.Method.GET, url, null,
new Response.Listener<JSONObject>() {
#SuppressLint("SetTextI18n")
#Override
public void onResponse(JSONObject response) {
try {
JSONObject main_object = response.getJSONObject("main");
JSONArray array = response.getJSONArray("weather");
String temp = String.valueOf(main_object.getDouble("temp"));
String city = response.getString("name");
JSONObject country_object = response.getJSONObject("sys");
String country = country_object.getString("country");
Toast.makeText(MainActivity.this, "Try. Catch3", Toast.LENGTH_LONG).show();
txtTemp.setText(temp + "°C");
txtMyLocation.setText(city + "\n" + country);
} catch (JSONException e) {
e.printStackTrace();
}
}
}, new Response.ErrorListener() {
#Override
public void onErrorResponse(VolleyError error) {
Toast.makeText(MainActivity.this, "Error", Toast.LENGTH_LONG).show();
//I made this toast to make sure that the error goes here and I was right. The toast shows up.
error.printStackTrace();
}
}
);
queue = Volley.newRequestQueue(this);
queue.add(req);
}
My build.gradle has:
implementation 'com.android.volley:volley:1.1.0'
My netword_security_config.xml is:
<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
<domain-config cleartextTrafficPermitted="true">
<domain includeSubdomains="true">http://api.openweathermap.org</domain>
</domain-config>
</network-security-config>
Then here's my error:
2020-04-30 07:46:08.094 24706-24706/com.example.demo W/BugManager: ##### register,mFd=49
2020-04-30 07:46:08.111 24706-24706/com.example.demo W/System.err: com.android.volley.NoConnectionError: java.io.IOException: Cleartext HTTP traffic to api.openweathermap.org not permitted
2020-04-30 07:46:08.111 24706-24706/com.example.demo W/System.err: at com.android.volley.toolbox.BasicNetwork.performRequest(BasicNetwork.java:177)
2020-04-30 07:46:08.111 24706-24706/com.example.demo W/System.err: at com.android.volley.NetworkDispatcher.processRequest(NetworkDispatcher.java:120)
2020-04-30 07:46:08.111 24706-24706/com.example.demo W/System.err: at com.android.volley.NetworkDispatcher.run(NetworkDispatcher.java:87)
2020-04-30 07:46:08.111 24706-24706/com.example.demo W/System.err: Caused by: java.io.IOException: Cleartext HTTP traffic to api.openweathermap.org not permitted
2020-04-30 07:46:08.111 24706-24706/com.example.demo W/System.err: at com.android.okhttp.HttpHandler$CleartextURLFilter.checkURLPermitted(HttpHandler.java:115)
2020-04-30 07:46:08.111 24706-24706/com.example.demo W/System.err: at com.android.okhttp.internal.huc.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:458)
2020-04-30 07:46:08.111 24706-24706/com.example.demo W/System.err: at com.android.okhttp.internal.huc.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl.java:407)
2020-04-30 07:46:08.111 24706-24706/com.example.demo W/System.err: at com.android.okhttp.internal.huc.HttpURLConnectionImpl.getResponseCode(HttpURLConnectionImpl.java:538)
2020-04-30 07:46:08.111 24706-24706/com.example.demo W/System.err: at com.android.volley.toolbox.HurlStack.executeRequest(HurlStack.java:99)
2020-04-30 07:46:08.111 24706-24706/com.example.demo W/System.err: at com.android.volley.toolbox.BasicNetwork.performRequest(BasicNetwork.java:131)
2020-04-30 07:46:08.111 24706-24706/com.example.demo W/System.err: ... 2 more
When I edit the http to https in both MainActivity.java and network_security_config.xml, I got this error:
2020-04-30 08:06:27.309 24975-24975/? I/om.example.dem: Late-enabling -Xcheck:jni
2020-04-30 08:06:27.404 24975-24975/com.example.demo I/om.example.dem: The ClassLoaderContext is a special shared library.
2020-04-30 08:06:27.486 24975-24975/com.example.demo I/Perf: Connecting to perf service.
2020-04-30 08:06:27.542 24975-24975/com.example.demo W/om.example.dem: Accessing hidden method Landroid/graphics/drawable/Drawable;->getOpticalInsets()Landroid/graphics/Insets; (light greylist, linking)
2020-04-30 08:06:27.542 24975-24975/com.example.demo W/om.example.dem: Accessing hidden field Landroid/graphics/Insets;->left:I (light greylist, linking)
2020-04-30 08:06:27.542 24975-24975/com.example.demo W/om.example.dem: Accessing hidden field Landroid/graphics/Insets;->right:I (light greylist, linking)
2020-04-30 08:06:27.542 24975-24975/com.example.demo W/om.example.dem: Accessing hidden field Landroid/graphics/Insets;->top:I (light greylist, linking)
2020-04-30 08:06:27.542 24975-24975/com.example.demo W/om.example.dem: Accessing hidden field Landroid/graphics/Insets;->bottom:I (light greylist, linking)
2020-04-30 08:06:27.587 24975-24975/com.example.demo W/om.example.dem: Accessing hidden method Landroid/view/View;->computeFitSystemWindows(Landroid/graphics/Rect;Landroid/graphics/Rect;)Z (light greylist, reflection)
2020-04-30 08:06:27.587 24975-24975/com.example.demo W/om.example.dem: Accessing hidden method Landroid/view/ViewGroup;->makeOptionalFitsSystemWindows()V (light greylist, reflection)
2020-04-30 08:06:27.621 24975-24975/com.example.demo W/om.example.dem: Accessing hidden method Landroid/widget/TextView;->getTextDirectionHeuristic()Landroid/text/TextDirectionHeuristic; (light greylist, linking)
2020-04-30 08:06:27.625 24975-24975/com.example.demo W/om.example.dem: Accessing hidden method Landroid/graphics/FontFamily;-><init>()V (light greylist, reflection)
2020-04-30 08:06:27.625 24975-24975/com.example.demo W/om.example.dem: Accessing hidden method Landroid/graphics/FontFamily;->addFontFromAssetManager(Landroid/content/res/AssetManager;Ljava/lang/String;IZIII[Landroid/graphics/fonts/FontVariationAxis;)Z (light greylist, reflection)
2020-04-30 08:06:27.625 24975-24975/com.example.demo W/om.example.dem: Accessing hidden method Landroid/graphics/FontFamily;->addFontFromBuffer(Ljava/nio/ByteBuffer;I[Landroid/graphics/fonts/FontVariationAxis;II)Z (light greylist, reflection)
2020-04-30 08:06:27.625 24975-24975/com.example.demo W/om.example.dem: Accessing hidden method Landroid/graphics/FontFamily;->freeze()Z (light greylist, reflection)
2020-04-30 08:06:27.625 24975-24975/com.example.demo W/om.example.dem: Accessing hidden method Landroid/graphics/FontFamily;->abortCreation()V (light greylist, reflection)
2020-04-30 08:06:27.625 24975-24975/com.example.demo W/om.example.dem: Accessing hidden method Landroid/graphics/Typeface;->createFromFamiliesWithDefault([Landroid/graphics/FontFamily;Ljava/lang/String;II)Landroid/graphics/Typeface; (light greylist, reflection)
2020-04-30 08:06:27.653 24975-25019/com.example.demo I/DpmTcmClient: RegisterTcmMonitor from: $Proxy0
2020-04-30 08:06:27.656 24975-24975/com.example.demo D/OpenGLRenderer: Skia GL Pipeline
2020-04-30 08:06:27.659 24975-25019/com.example.demo D/NetworkSecurityConfig: Using Network Security Config from resource network_security_config debugBuild: true
2020-04-30 08:06:27.659 24975-24975/com.example.demo W/BugManager: ##### register,mFd=48
2020-04-30 08:06:27.676 24975-24975/com.example.demo W/System.err: com.android.volley.NoConnectionError: java.io.IOException: Cleartext HTTP traffic to api.openweathermap.org not permitted
2020-04-30 08:06:27.676 24975-24975/com.example.demo W/System.err: at com.android.volley.toolbox.BasicNetwork.performRequest(BasicNetwork.java:177)
2020-04-30 08:06:27.676 24975-24975/com.example.demo W/System.err: at com.android.volley.NetworkDispatcher.processRequest(NetworkDispatcher.java:120)
2020-04-30 08:06:27.676 24975-24975/com.example.demo W/System.err: at com.android.volley.NetworkDispatcher.run(NetworkDispatcher.java:87)
2020-04-30 08:06:27.676 24975-24975/com.example.demo W/System.err: Caused by: java.io.IOException: Cleartext HTTP traffic to api.openweathermap.org not permitted
2020-04-30 08:06:27.676 24975-24975/com.example.demo W/System.err: at com.android.okhttp.HttpHandler$CleartextURLFilter.checkURLPermitted(HttpHandler.java:115)
2020-04-30 08:06:27.676 24975-24975/com.example.demo W/System.err: at com.android.okhttp.internal.huc.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:458)
2020-04-30 08:06:27.676 24975-24975/com.example.demo W/System.err: at com.android.okhttp.internal.huc.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl.java:407)
2020-04-30 08:06:27.677 24975-24975/com.example.demo W/System.err: at com.android.okhttp.internal.huc.HttpURLConnectionImpl.getResponseCode(HttpURLConnectionImpl.java:538)
2020-04-30 08:06:27.677 24975-24975/com.example.demo W/System.err: at com.android.volley.toolbox.HurlStack.executeRequest(HurlStack.java:99)
2020-04-30 08:06:27.677 24975-24975/com.example.demo W/System.err: at com.android.volley.toolbox.BasicNetwork.performRequest(BasicNetwork.java:131)
2020-04-30 08:06:27.677 24975-24975/com.example.demo W/System.err: ... 2 more
2020-04-30 08:06:27.699 24975-25024/com.example.demo I/Adreno: QUALCOMM build : eb3073a, I21de9e011e
Build Date : 05/14/19
OpenGL ES Shader Compiler Version: EV031.25.19.01
Local Branch :
Remote Branch : refs/tags/AU_LINUX_ANDROID_LA.UM.7.1.R1.09.00.00.461.091
Remote Branch : NONE
Reconstruct Branch : NOTHING
2020-04-30 08:06:27.699 24975-25024/com.example.demo I/Adreno: Build Config : S P 6.0.9 AArch64
2020-04-30 08:06:27.706 24975-25024/com.example.demo I/Adreno: PFP: 0x016ee180, ME: 0x00000000
2020-04-30 08:06:27.709 24975-25024/com.example.demo I/ConfigStore: android::hardware::configstore::V1_0::ISurfaceFlingerConfigs::hasWideColorDisplay retrieved: 1
2020-04-30 08:06:27.709 24975-25024/com.example.demo I/ConfigStore: android::hardware::configstore::V1_0::ISurfaceFlingerConfigs::hasHDRDisplay retrieved: 1
2020-04-30 08:06:27.710 24975-25024/com.example.demo I/OpenGLRenderer: Initialized EGL, version 1.4
2020-04-30 08:06:27.710 24975-25024/com.example.demo D/OpenGLRenderer: Swap behavior 2
2020-04-30 08:06:27.722 24975-24975/com.example.demo V/BugManager_JNI: bug message start: fd=48,tag =0X01004801
2020-04-30 08:06:27.722 24975-24975/com.example.demo V/BugManager_JNI: bug message copy: fd=48,msgid =6703,len=72,msg={"activity":"com.example.demo/com.example.demo.MainActivity","frames":2}
2020-04-30 08:06:27.722 24975-24975/com.example.demo V/BugManager_JNI: bug message stop: fd =48,msgid =6703
2020-04-30 08:06:27.807 24975-24975/com.example.demo V/BugManager_JNI: bug message start: fd=48,tag =0X01004801
2020-04-30 08:06:27.807 24975-24975/com.example.demo V/BugManager_JNI: bug message copy: fd=48,msgid =6705,len=72,msg={"activity":"com.example.demo/com.example.demo.MainActivity","frames":4}
2020-04-30 08:06:27.807 24975-24975/com.example.demo V/BugManager_JNI: bug message stop: fd =48,msgid =6705
2020-04-30 08:06:31.210 24975-24975/com.example.demo V/BugManager_JNI: bug message start: fd=48,tag =0X01004801
2020-04-30 08:06:31.211 24975-24975/com.example.demo V/BugManager_JNI: bug message copy: fd=48,msgid =6706,len=72,msg={"activity":"com.example.demo/com.example.demo.MainActivity","frames":1}
2020-04-30 08:06:31.211 24975-24975/com.example.demo V/BugManager_JNI: bug message stop: fd =48,msgid =6706

Just may not serve the purpose, but I was using OkHttp instead of Volley and it was coming. Again I stopped working Volley long time ago.
Anyway, a simple example,
OkHttpUtilAsync.class
private final static String URL = "http://api.openweathermap.org/data/2.5/weather?q=Manila&appid=1fef2628db7b44791ee1029f1999137a&units=imperial/posts/1"; //1 object
private final static String TAG = OkHttpUtilAsync.class.getSimpleName();
private OkHttpClient okHttpClient;
private Request request;
private String result = "";
private ResponseBody responseBody;
private MediaType mediaType;
OkHttpUtilAsync() {
setUpClientAndRequest();
}
void fetchNetwork() {
Log.d(TAG, "fetchNetwork()");
okHttpClient.newCall(request).enqueue(new Callback() {
#Override
public void onFailure(Call call, IOException e) {
Log.i(TAG, "onFailure()");
call.cancel();
}
#Override
public void onResponse(Call call, Response response) throws IOException {
Log.i(TAG, "onResponse()");
processResponse(response);
}
});
}
private void setUpClientAndRequest() {
Log.w(TAG, "setUpClientAndRequest()");
okHttpClient = new OkHttpClient();
request = new Request.Builder().url(URL).build();
}
private void processResponse(Response response) {
Log.i(TAG, "processResponse()");
if (response != null) {
Log.w(TAG, "Response not Null");
if (response.isSuccessful()) {
Log.wtf(TAG, "Response is Successful : " + response.isSuccessful());
// responseBody = response.body(); has the RESULT
Log.v(TAG, " result = " + response.body());
} else {
Log.wtf(TAG, "Response is not Successful : " + response.isSuccessful());
}
//close the Response
response.close();
} else {
Log.w(TAG, "Response ==== Null");
}
}
and call it from MainActivity
OkHttpUtilAsync okHttpUtilAsync=new OkHttpUtilAsync();
okHttpUtilAsync.fetchNetwork();
No need to set any clear text, and remove all those network security config from xml.
gradle implementation 'com.squareup.okhttp3:okhttp:3.10.0'

Related

CameraX returning error when taking picture with AutoFlash

So I'm able to capture and save image using cameraX in android java. But when I turn ON the flash I'm not able to capture and save the image. This is the code
void Cameracapture() {
SimpleDateFormat mDateFormat = new SimpleDateFormat("yyyyMMddHHmmss", Locale.US);
//File photofile = new File(getBatchDirectoryName(), mDateFormat.format(new Date())+ ".jpg");
//camera.getCameraControl().enableTorch(true);
long timestamp = System.currentTimeMillis();
ContentValues contentValues = new ContentValues();
contentValues.put(MediaStore.MediaColumns.DISPLAY_NAME, timestamp);
contentValues.put(MediaStore.MediaColumns.MIME_TYPE, "image/jpeg");
ImageCapture.OutputFileOptions outputFileOptions = new ImageCapture.OutputFileOptions.Builder(
getActivity().getContentResolver(),
MediaStore.Images.Media.EXTERNAL_CONTENT_URI,
contentValues).build();
imageCapture.setFlashMode(ImageCapture.FLASH_MODE_AUTO);
imageCapture.takePicture(outputFileOptions, getExecutor(), new ImageCapture.OnImageSavedCallback() {
#Override
public void onImageSaved(#NonNull ImageCapture.OutputFileResults outputFileResults) {
//new Handler(Looper.getMainLooper()).post(new Runnable() {
// #Override
//public void run() {
//camera.getCameraControl().enableTorch(false);
Toast.makeText(getActivity(), "Image Saved successfully", Toast.LENGTH_SHORT).show();
//imageCapture.setFlashMode(ImageCapture.FLASH_MODE_OFF);
//}
///});
}
#Override
public void onError(#NonNull ImageCaptureException error) {
error.printStackTrace();
Toast.makeText(getActivity(), String.valueOf(error), Toast.LENGTH_SHORT).show();
Log.d(TAG, String.valueOf(error));
}
});
}
2022-08-25 11:55:08.643 2730-2730/com.example.camera I/ViewRootImpl#2e226e9[MainActivity]: ViewPostIme pointer 1
2022-08-25 11:55:08.643 2730-2730/com.example.camera I/MSHandlerLifeCycle: isMultiSplitHandlerRequested: windowingMode=1 isFullscreen=true isPopOver=false isHidden=false skipActivityType=false isHandlerType=true this: DecorView#7b317d1[MainActivity]
2022-08-25 11:55:08.653 2730-2730/com.example.camera D/CameraOrientationUtil: getRelativeImageRotation: destRotationDegrees=0, sourceRotationDegrees=90, isOppositeFacing=true, result=90
2022-08-25 11:55:08.653 2730-2730/com.example.camera D/CameraOrientationUtil: getRelativeImageRotation: destRotationDegrees=0, sourceRotationDegrees=90, isOppositeFacing=true, result=90
2022-08-25 11:55:08.654 2730-2773/com.example.camera D/UseCaseAttachState: Active and attached use case: [androidx.camera.core.ImageCapture-fd93a12b-974a-4c2d-8ce8-66c82525716c34966062, androidx.camera.core.VideoCapture-3aa58447-94ff-4666-94f7-94b77a743acc14289359, androidx.camera.core.Preview-89b6d439-4a7d-41cc-b016-5bad89e8cd1b67986601] for camera: 0
2022-08-25 11:55:08.654 2730-2730/com.example.camera D/ImageCapture: Send image capture request [current, pending] = [0, 1]
2022-08-25 11:55:08.655 2730-2730/com.example.camera D/ImageCapture: issueTakePicture
2022-08-25 11:55:08.662 2730-2773/com.example.camera D/CaptureSession: Attempting to submit CaptureRequest after setting
2022-08-25 11:55:08.663 2730-2773/com.example.camera D/CaptureSession: Issuing request for session.
2022-08-25 11:55:08.665 2730-2773/com.example.camera D/Camera2CaptureRequestBuilder: createCaptureRequest
2022-08-25 11:55:08.979 2730-2771/com.example.camera D/Camera2CameraImpl: {Camera#6ceeda3[id=0]} Issue capture request
2022-08-25 11:55:08.980 2730-2771/com.example.camera D/CaptureSession: Issuing capture request.
2022-08-25 11:55:08.987 2730-2771/com.example.camera D/Camera2CaptureRequestBuilder: createCaptureRequest
2022-08-25 11:55:09.516 2730-2730/com.example.camera D/CompatibilityChangeReporter: Compat change id reported: 147798919; UID 10404; state: ENABLED
2022-08-25 11:55:11.330 2730-2747/com.example.camera W/System: A resource failed to call close.
2022-08-25 11:55:38.405 2730-2730/com.example.camera I/ViewRootImpl#2e226e9[MainActivity]: ViewPostIme pointer 0
2022-08-25 11:55:38.406 2730-2730/com.example.camera I/MSHandlerLifeCycle: isMultiSplitHandlerRequested: windowingMode=1 isFullscreen=true isPopOver=false isHidden=false skipActivityType=false isHandlerType=true this: DecorView#7b317d1[MainActivity]
2022-08-25 11:55:38.415 2730-2730/com.example.camera I/MSHandlerLifeCycle: isMultiSplitHandlerRequested: windowingMode=1 isFullscreen=true isPopOver=false isHidden=false skipActivityType=false isHandlerType=true this: DecorView#7b317d1[MainActivity]
2022-08-25 11:55:38.433 2730-2730/com.example.camera I/MSHandlerLifeCycle: isMultiSplitHandlerRequested: windowingMode=1 isFullscreen=true isPopOver=false isHidden=false skipActivityType=false isHandlerType=true this: DecorView#7b317d1[MainActivity]
2022-08-25 11:55:38.567 2730-2730/com.example.camera I/MSHandlerLifeCycle: isMultiSplitHandlerRequested: windowingMode=1 isFullscreen=true isPopOver=false isHidden=false skipActivityType=false isHandlerType=true this: DecorView#7b317d1[MainActivity]
2022-08-25 11:55:38.586 2730-2730/com.example.camera I/MSHandlerLifeCycle: isMultiSplitHandlerRequested: windowingMode=1 isFullscreen=true isPopOver=false isHidden=false skipActivityType=false isHandlerType=true this: DecorView#7b317d1[MainActivity]
2022-08-25 11:55:38.595 2730-2730/com.example.camera I/ViewRootImpl#2e226e9[MainActivity]: ViewPostIme pointer 1
2022-08-25 11:55:38.595 2730-2730/com.example.camera I/MSHandlerLifeCycle: isMultiSplitHandlerRequested: windowingMode=1 isFullscreen=true isPopOver=false isHidden=false skipActivityType=false isHandlerType=true this: DecorView#7b317d1[MainActivity]
2022-08-25 11:55:38.603 2730-2730/com.example.camera D/CameraOrientationUtil: getRelativeImageRotation: destRotationDegrees=0, sourceRotationDegrees=90, isOppositeFacing=true, result=90
2022-08-25 11:55:38.604 2730-2730/com.example.camera D/CameraOrientationUtil: getRelativeImageRotation: destRotationDegrees=0, sourceRotationDegrees=90, isOppositeFacing=true, result=90
2022-08-25 11:55:38.605 2730-2730/com.example.camera D/ImageCapture: Send image capture request [current, pending] = [0, 1]
2022-08-25 11:55:38.606 2730-2730/com.example.camera D/ImageCapture: issueTakePicture
2022-08-25 11:55:38.606 2730-2773/com.example.camera D/UseCaseAttachState: Active and attached use case: [androidx.camera.core.ImageCapture-fd93a12b-974a-4c2d-8ce8-66c82525716c34966062, androidx.camera.core.VideoCapture-3aa58447-94ff-4666-94f7-94b77a743acc14289359, androidx.camera.core.Preview-89b6d439-4a7d-41cc-b016-5bad89e8cd1b67986601] for camera: 0
2022-08-25 11:55:38.615 2730-2773/com.example.camera D/CaptureSession: Attempting to submit CaptureRequest after setting
2022-08-25 11:55:38.615 2730-2773/com.example.camera D/CaptureSession: Issuing request for session.
2022-08-25 11:55:38.617 2730-2773/com.example.camera D/Camera2CaptureRequestBuilder: createCaptureRequest
2022-08-25 11:55:38.927 2730-2771/com.example.camera D/Camera2CapturePipeline: Turn on torch
2022-08-25 11:55:38.932 2730-2771/com.example.camera D/UseCaseAttachState: Active and attached use case: [androidx.camera.core.ImageCapture-fd93a12b-974a-4c2d-8ce8-66c82525716c34966062, androidx.camera.core.VideoCapture-3aa58447-94ff-4666-94f7-94b77a743acc14289359, androidx.camera.core.Preview-89b6d439-4a7d-41cc-b016-5bad89e8cd1b67986601] for camera: 0
2022-08-25 11:55:38.935 2730-2771/com.example.camera D/CaptureSession: Attempting to submit CaptureRequest after setting
2022-08-25 11:55:38.935 2730-2771/com.example.camera D/CaptureSession: Issuing request for session.
2022-08-25 11:55:38.935 2730-2771/com.example.camera D/Camera2CaptureRequestBuilder: createCaptureRequest
2022-08-25 11:55:39.261 2730-2771/com.example.camera D/Camera2CapturePipeline: checkCaptureResult, AE=CONVERGED AF =PASSIVE_NOT_FOCUSED AWB=CONVERGED
2022-08-25 11:55:39.263 2730-2771/com.example.camera D/Camera2CameraImpl: {Camera#6ceeda3[id=0]} Issue capture request
2022-08-25 11:55:39.263 2730-2771/com.example.camera D/CaptureSession: Issuing capture request.
2022-08-25 11:55:39.267 2730-2771/com.example.camera D/Camera2CaptureRequestBuilder: createCaptureRequest
2022-08-25 11:55:51.555 2730-2730/com.example.camera W/System.err: androidx.camera.core.ImageCaptureException: Capture request failed with reason ERROR
2022-08-25 11:55:51.556 2730-2730/com.example.camera W/System.err: at androidx.camera.core.ImageCapture$ImageCaptureRequest.lambda$notifyCallbackError$1$androidx-camera-core-ImageCapture$ImageCaptureRequest(ImageCapture.java:2375)
2022-08-25 11:55:51.556 2730-2772/com.example.camera D/Camera2CameraImpl: {Camera#6ceeda3[id=0]} Issue capture request
2022-08-25 11:55:51.556 2730-2730/com.example.camera W/System.err: at androidx.camera.core.ImageCapture$ImageCaptureRequest$$ExternalSyntheticLambda0.run(Unknown Source:8)
2022-08-25 11:55:51.556 2730-2772/com.example.camera D/CaptureSession: Issuing capture request.
2022-08-25 11:55:51.556 2730-2730/com.example.camera W/System.err: at android.os.Handler.handleCallback(Handler.java:938)
2022-08-25 11:55:51.556 2730-2730/com.example.camera W/System.err: at android.os.Handler.dispatchMessage(Handler.java:99)
2022-08-25 11:55:51.556 2730-2730/com.example.camera W/System.err: at android.os.Looper.loopOnce(Looper.java:226)
2022-08-25 11:55:51.557 2730-2730/com.example.camera W/System.err: at android.os.Looper.loop(Looper.java:313)
2022-08-25 11:55:51.557 2730-2730/com.example.camera W/System.err: at android.app.ActivityThread.main(ActivityThread.java:8669)
2022-08-25 11:55:51.557 2730-2730/com.example.camera W/System.err: at java.lang.reflect.Method.invoke(Native Method)
2022-08-25 11:55:51.557 2730-2730/com.example.camera W/System.err: at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:571)
2022-08-25 11:55:51.557 2730-2730/com.example.camera W/System.err: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1135)
2022-08-25 11:55:51.558 2730-2730/com.example.camera W/System.err: Caused by: androidx.camera.core.ImageCaptureException: Capture request failed with reason ERROR
2022-08-25 11:55:51.558 2730-2730/com.example.camera W/System.err: at androidx.camera.camera2.internal.Camera2CapturePipeline$Pipeline$2.onCaptureFailed(Camera2CapturePipeline.java:359)
2022-08-25 11:55:51.558 2730-2730/com.example.camera W/System.err: at androidx.camera.camera2.internal.CaptureCallbackAdapter.onCaptureFailed(CaptureCallbackAdapter.java:81)
2022-08-25 11:55:51.558 2730-2730/com.example.camera W/System.err: at androidx.camera.camera2.internal.CameraBurstCaptureCallback.onCaptureFailed(CameraBurstCaptureCallback.java:75)
2022-08-25 11:55:51.558 2730-2730/com.example.camera W/System.err: at android.hardware.camera2.impl.CameraCaptureSessionImpl$1.lambda$onCaptureFailed$4$CameraCaptureSessionImpl$1(CameraCaptureSessionImpl.java:707)
2022-08-25 11:55:51.559 2730-2730/com.example.camera W/System.err: at android.hardware.camera2.impl.CameraCaptureSessionImpl$1$$ExternalSyntheticLambda3.run(Unknown Source:8)
2022-08-25 11:55:51.559 2730-2730/com.example.camera W/System.err: at androidx.camera.core.impl.utils.executor.SequentialExecutor$QueueWorker.workOnQueue(SequentialExecutor.java:231)
2022-08-25 11:55:51.559 2730-2730/com.example.camera W/System.err: at androidx.camera.core.impl.utils.executor.SequentialExecutor$QueueWorker.run(SequentialExecutor.java:173)
2022-08-25 11:55:51.559 2730-2730/com.example.camera W/System.err: at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1137)
2022-08-25 11:55:51.560 2730-2730/com.example.camera W/System.err: at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:637)
2022-08-25 11:55:51.560 2730-2730/com.example.camera W/System.err: at java.lang.Thread.run(Thread.java:1012)
2022-08-25 11:55:51.561 2730-2772/com.example.camera D/Camera2CaptureRequestBuilder: createCaptureRequest
2022-08-25 11:55:51.567 2730-2772/com.example.camera D/UseCaseAttachState: Active and attached use case: [androidx.camera.core.ImageCapture-fd93a12b-974a-4c2d-8ce8-66c82525716c34966062, androidx.camera.core.VideoCapture-3aa58447-94ff-4666-94f7-94b77a743acc14289359, androidx.camera.core.Preview-89b6d439-4a7d-41cc-b016-5bad89e8cd1b67986601] for camera: 0
2022-08-25 11:55:51.571 2730-2772/com.example.camera D/CaptureSession: Attempting to submit CaptureRequest after setting
2022-08-25 11:55:51.571 2730-2772/com.example.camera D/CaptureSession: Issuing request for session.
2022-08-25 11:55:51.572 2730-2772/com.example.camera D/Camera2CaptureRequestBuilder: createCaptureRequest
2022-08-25 11:55:51.577 2730-2772/com.example.camera D/Camera2CapturePipeline: Turn off torch
2022-08-25 11:55:51.585 2730-2730/com.example.camera D/Camera fragment: androidx.camera.core.ImageCaptureException: Capture request failed with reason ERROR
This is the error I'm getting
D/Camera fragment: androidx.camera.core.ImageCaptureException: Capture request failed with reason ERROR

Permission denied for Android Studio

I have a permission denied problem when I run the app in my android studio. Before that, I need to declare that my group mates can run the code and pop out the data but me, we all use the same code and version but I use a mac that they use the win system.
Below is the logcat info:
Late-enabling -Xcheck:jni
E/ample.inclass0: Unknown bits set in runtime_flags: 0x8000
W/ample.inclass0: Unexpected CPU variant for X86 using defaults: x86
D/libEGL: Emulator has host GPU support, qemu.gles is set to 1.
W/RenderThread: type=1400 audit(0.0:660): avc: denied { write } for name="property_service" dev="tmpfs" ino=857 scontext=u:r:untrusted_app:s0:c151,c256,c512,c768 tcontext=u:object_r:property_socket:s0 tclass=sock_file permissive=0
W/libc: Unable to set property "qemu.gles" to "1": connection failed; errno=13 (Permission denied)
D/libEGL: loaded /vendor/lib/egl/libEGL_emulation.so
D/libEGL: loaded /vendor/lib/egl/libGLESv1_CM_emulation.so
D/libEGL: loaded /vendor/lib/egl/libGLESv2_emulation.so
W/ample.inclass0: Accessing hidden method Landroid/view/View;->computeFitSystemWindows(Landroid/graphics/Rect;Landroid/graphics/Rect;)Z (greylist, reflection, allowed)
W/ample.inclass0: Accessing hidden method Landroid/view/ViewGroup;->makeOptionalFitsSystemWindows()V (greylist, reflection, allowed)
D/NetworkSecurityConfig: No Network Security Config specified, using platform default
W/System.err: java.net.SocketException: socket failed: EPERM (Operation not permitted)
W/System.err: at java.net.Socket.createImpl(Socket.java:492)
W/System.err: at java.net.Socket.getImpl(Socket.java:552)
W/System.err: at java.net.Socket.setSoTimeout(Socket.java:1180)
W/System.err: at okhttp3.internal.connection.RealConnection.connectSocket(RealConnection.kt:293)
W/System.err: at okhttp3.internal.connection.RealConnection.connect(RealConnection.kt:207)
W/System.err: at okhttp3.internal.connection.ExchangeFinder.findConnection(ExchangeFinder.kt:226)
W/System.err: at okhttp3.internal.connection.ExchangeFinder.findHealthyConnection(ExchangeFinder.kt:106)
W/System.err: at okhttp3.internal.connection.ExchangeFinder.find(ExchangeFinder.kt:74)
W/System.err: at okhttp3.internal.connection.RealCall.initExchange$okhttp(RealCall.kt:255)
W/System.err: at okhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.kt:32)
W/System.err: at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
W/System.err: at okhttp3.internal.cache.CacheInterceptor.intercept(CacheInterceptor.kt:95)
W/System.err: at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
W/System.err: at okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.kt:83)
W/System.err: at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
W/System.err: at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.kt:76)
W/System.err: at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
W/System.err: at okhttp3.internal.connection.RealCall.getResponseWithInterceptorChain$okhttp(RealCall.kt:201)
W/System.err: at okhttp3.internal.connection.RealCall$AsyncCall.run(RealCall.kt:517)
W/System.err: at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
W/System.err: at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
W/System.err: at java.lang.Thread.run(Thread.java:919)
D/HostConnection: HostConnection::get() New Host Connection established 0xdb7e2040, tid 5252
D/HostConnection: HostComposition ext ANDROID_EMU_CHECKSUM_HELPER_v1 ANDROID_EMU_native_sync_v2 ANDROID_EMU_native_sync_v3 ANDROID_EMU_native_sync_v4 ANDROID_EMU_dma_v1 ANDROID_EMU_direct_mem ANDROID_EMU_host_composition_v1 ANDROID_EMU_host_composition_v2 ANDROID_EMU_YUV420_888_to_NV21 ANDROID_EMU_YUV_Cache ANDROID_EMU_sync_buffer_data GL_OES_EGL_image_external_essl3 GL_OES_vertex_array_object GL_KHR_texture_compression_astc_ldr ANDROID_EMU_host_side_tracing ANDROID_EMU_gles_max_version_3_0
W/OpenGLRenderer: Failed to choose config with EGL_SWAP_BEHAVIOR_PRESERVED, retrying without...
D/eglCodecCommon: setVertexArrayObject: set vao to 0 (0) 0 0
D/EGL_emulation: eglCreateContext: 0xf1f7e5c0: maj 3 min 0 rcv 3
D/EGL_emulation: eglMakeCurrent: 0xf1f7e5c0: ver 3 0 (tinfo 0xe6d24dd0)
W/Gralloc3: mapper 3.x is not supported
D/HostConnection: createUnique: call
D/HostConnection: HostConnection::get() New Host Connection established 0xdb7e3800, tid 5252
D/HostConnection: HostComposition ext ANDROID_EMU_CHECKSUM_HELPER_v1 ANDROID_EMU_native_sync_v2 ANDROID_EMU_native_sync_v3 ANDROID_EMU_native_sync_v4 ANDROID_EMU_dma_v1 ANDROID_EMU_direct_mem ANDROID_EMU_host_composition_v1 ANDROID_EMU_host_composition_v2 ANDROID_EMU_YUV420_888_to_NV21 ANDROID_EMU_YUV_Cache ANDROID_EMU_sync_buffer_data GL_OES_EGL_image_external_essl3 GL_OES_vertex_array_object GL_KHR_texture_compression_astc_ldr ANDROID_EMU_host_side_tracing ANDROID_EMU_gles_max_version_3_0
D/eglCodecCommon: allocate: Ask for block of size 0x1000
D/eglCodecCommon: allocate: ioctl allocate returned offset 0x3ff807000 size 0x2000
D/EGL_emulation: eglMakeCurrent: 0xf1f7e5c0: ver 3 0 (tinfo 0xe6d24dd0)
D/eglCodecCommon: setVertexArrayObject: set vao to 0 (0) 1 0
Below is the AndroidMainfest file:
For toolsLtargetApi="31" I tried to delete and run nothing changed
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.example.inclass07">
<uses-permission android:name="android.permission.INTERNET"></uses-permission>
<application
android:allowBackup="true"
android:dataExtractionRules="#xml/data_extraction_rules"
android:fullBackupContent="#xml/backup_rules"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:roundIcon="#mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="#style/Theme.InClass07"
tools:targetApi="31">
<activity
android:name=".MainActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
Could anyone give me some suggestions to solve the issue? Any help is appreciated.
I am not sure if this will work for everyone, but I solved my problem by changing the Emulator.
Previously, I used the Nexus 5X Q(API29), but now I switched to the Nexus 5X API33 and doing so solved my problem.
I also tried others with API33 and they work just fine.

java.net.ConnectException: Failed to connect to /10.191.20.97:8080

I have connect java REST on local my computer(10.191.20.97:8080) I am making a android login app that is connecting to Java server. from browser i have successful connection with server but with android studio is somethings wrong:
I/System.out: port:8080
W/System.err: java.net.ConnectException: Failed to connect to /10.191.20.97:8080
W/System.err: at com.android.okhttp.internal.io.RealConnection.connectSocket(RealConnection.java:143)
at com.android.okhttp.internal.io.RealConnection.connect(RealConnection.java:112)
at com.android.okhttp.internal.http.StreamAllocation.findConnection(StreamAllocation.java:184)
at com.android.okhttp.internal.http.StreamAllocation.findHealthyConnection(StreamAllocation.java:126)
W/System.err: at com.android.okhttp.internal.http.StreamAllocation.newStream(StreamAllocation.java:95)
at com.android.okhttp.internal.http.HttpEngine.connect(HttpEngine.java:299)
at com.android.okhttp.internal.http.HttpEngine.sendRequest(HttpEngine.java:237)
at com.android.okhttp.internal.huc.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:461)
W/System.err: at com.android.okhttp.internal.huc.HttpURLConnectionImpl.connect(HttpURLConnectionImpl.java:127)
W/System.err: at com.hpi.android.assetmanagement.ui.updateapk.MainCheckVersion$1GetDataJSON.doInBackground(MainCheckVersion.java:358)
W/System.err: at com.hpi.android.assetmanagement.ui.updateapk.MainCheckVersion$1GetDataJSON.doInBackground(MainCheckVersion.java:334)
W/System.err: at android.os.AsyncTask$2.call(AsyncTask.java:333)
W/System.err: 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:1162)
W/System.err: at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
at java.lang.Thread.run(Thread.java:764)
E/Internet: => false
D/WindowClient: Add to mViews: DecorView#d78cc18[], this = android.view.WindowManagerGlobal#3577954
D/ViewRootImpl[MainCheckVersion]: hardware acceleration = true , fakeHwAccelerated = false, sRendererDisabled = false, forceHwAccelerated = false, sSystemRendererDisabled = false
I/zygote: Do full code cache collection, code=252KB, data=207KB
I/zygote: After code cache collection, code=252KB, data=176KB
D/Surface: Surface::connect(this=0x8f824000,api=1)
D/Surface: Surface::allocateBuffers(this=0x8f824000)
D/Surface: Surface::disconnect(this=0x8f823000,api=1)
D/Surface: Surface::connect(this=0x8f823000,api=1)
D/Surface: Surface::disconnect(this=0x8f823000,api=1)
D/View: [Warning] assignParent to null: this = DecorView#67cfdda[]
D/WindowClient: Remove from mViews: DecorView#67cfdda[], this = android.view.WindowManagerGlobal#3577954

Can't get data from website in Android Studio

I can't get html code from this website "http://www.posh24.se/kandisar". But when I try to download data from "google.com" - it works? How i can fix it? Maybe i must add some permissions?
private static class DownloadContentStars extends AsyncTask<String, Void, String> {
#Override
protected String doInBackground(String... strings) {
URL url = null;
HttpURLConnection urlConnection = null;
StringBuilder result = new StringBuilder();
try {
url = new URL(strings[0]);
urlConnection = (HttpURLConnection) url.openConnection();
InputStream in = urlConnection.getInputStream();
InputStreamReader inputStreamReader = new InputStreamReader(in);
BufferedReader reader = new BufferedReader(inputStreamReader);
String line = reader.readLine();
while (line != null) {
result.append(line);
line = reader.readLine();
}
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} finally {
if (urlConnection != null) {
urlConnection.disconnect();
}
}
return result.toString();
}
}
Here you can see my logcast
I start programm on my Xiomi Redmi Note 7
I think i must add some permission but i don't know which
2019-08-22 20:46:51.827 8668-8668/com.example.guessstar I/ample.guesssta: Late-enabling -Xcheck:jni
2019-08-22 20:46:52.171 8668-8668/com.example.guessstar I/Perf: Connecting to perf service.
2019-08-22 20:46:52.412 8668-8668/com.example.guessstar W/ample.guesssta: Accessing hidden method Landroid/view/View;->computeFitSystemWindows(Landroid/graphics/Rect;Landroid/graphics/Rect;)Z (light greylist, reflection)
2019-08-22 20:46:52.414 8668-8668/com.example.guessstar W/ample.guesssta: Accessing hidden method Landroid/view/ViewGroup;->makeOptionalFitsSystemWindows()V (light greylist, reflection)
2019-08-22 20:46:52.543 8668-8746/com.example.guessstar I/DpmTcmClient: RegisterTcmMonitor from: com.android.okhttp.TcmIdleTimerMonitor
2019-08-22 20:46:52.552 8668-8746/com.example.guessstar D/NetworkSecurityConfig: No Network Security Config specified, using platform default
2019-08-22 20:46:52.555 8668-8746/com.example.guessstar W/System.err: java.io.IOException: Cleartext HTTP traffic to www.posh24.se not permitted
2019-08-22 20:46:52.555 8668-8746/com.example.guessstar W/System.err: at com.android.okhttp.HttpHandler$CleartextURLFilter.checkURLPermitted(HttpHandler.java:115)
2019-08-22 20:46:52.555 8668-8746/com.example.guessstar W/System.err: at com.android.okhttp.internal.huc.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:458)
2019-08-22 20:46:52.555 8668-8746/com.example.guessstar W/System.err: at com.android.okhttp.internal.huc.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl.java:407)
2019-08-22 20:46:52.555 8668-8746/com.example.guessstar W/System.err: at com.android.okhttp.internal.huc.HttpURLConnectionImpl.getInputStream(HttpURLConnectionImpl.java:244)
2019-08-22 20:46:52.556 8668-8746/com.example.guessstar W/System.err: at com.example.guessstar.MainActivity$DownloadContentStars.doInBackground(MainActivity.java:56)
2019-08-22 20:46:52.556 8668-8746/com.example.guessstar W/System.err: at com.example.guessstar.MainActivity$DownloadContentStars.doInBackground(MainActivity.java:46)
2019-08-22 20:46:52.556 8668-8746/com.example.guessstar W/System.err: at android.os.AsyncTask$2.call(AsyncTask.java:333)
2019-08-22 20:46:52.556 8668-8746/com.example.guessstar W/System.err: at java.util.concurrent.FutureTask.run(FutureTask.java:266)
2019-08-22 20:46:52.556 8668-8746/com.example.guessstar W/System.err: at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:245)
2019-08-22 20:46:52.556 8668-8746/com.example.guessstar W/System.err: at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
2019-08-22 20:46:52.556 8668-8746/com.example.guessstar W/System.err: at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
2019-08-22 20:46:52.556 8668-8746/com.example.guessstar W/System.err: at java.lang.Thread.run(Thread.java:764)
2019-08-22 20:46:52.641 8668-8749/com.example.guessstar I/Adreno: QUALCOMM build : cf57c9c, I1cb5c4d1cc
Build Date : 09/23/18
OpenGL ES Shader Compiler Version: EV031.25.03.01
Local Branch :
Remote Branch :
Remote Branch :
Reconstruct Branch :
2019-08-22 20:46:52.641 8668-8749/com.example.guessstar I/Adreno: Build Config : S L 6.0.7 AArch64
2019-08-22 20:46:52.646 8668-8749/com.example.guessstar I/Adreno: PFP: 0x005ff112, ME: 0x005ff066
2019-08-22 20:46:52.650 8668-8749/com.example.guessstar I/ConfigStore: android::hardware::configstore::V1_0::ISurfaceFlingerConfigs::hasWideColorDisplay retrieved: 0
2019-08-22 20:46:52.650 8668-8749/com.example.guessstar I/ConfigStore: android::hardware::configstore::V1_0::ISurfaceFlingerConfigs::hasHDRDisplay retrieved: 0
2019-08-22 20:46:52.651 8668-8749/com.example.guessstar I/OpenGLRenderer: Initialized EGL, version 1.4
2019-08-22 20:46:52.651 8668-8749/com.example.guessstar D/OpenGLRenderer: Swap behavior 2
2019-08-22 20:47:00.094 8668-8697/com.example.guessstar I/ample.guesssta: ProcessProfilingInfo new_methods=942 is saved saved_to_disk=1 resolve_classes_delay=8000
I find how to fix it: you should just add this line of code: android:usesCleartextTraffic="true"
to your AndroidManifest.xml
<application
...
android:usesCleartextTraffic="true"
...>
Hope this information will help someone in future.
that website is down now. it was bought by someone else.
you can still find list of celebrities' on any other site, like Forbes.

Android webview not loading for localhost server

I have created a node.js web application and running it on port 3000. I wanted an android app for the same and created a webview based android app.
While testing I was trying to give the localhost ip, the static server IP but the webview app is not loading in all of them.
Output:
Android logcat:
09-25 20:54:12.508 7589-7589/? I/.cloudassigmen: Not late-enabling -Xcheck:jni (already on)
09-25 20:54:13.288 7589-7589/? W/.cloudassigmen: Unexpected CPU variant for X86 using defaults: x86
09-25 20:54:15.410 7589-7589/com.example.smitsanghvi.cloudassigment W/.cloudassigmen: JIT profile information will not be recorded: profile file does not exits.
09-25 20:54:15.431 7589-7589/com.example.smitsanghvi.cloudassigment I/chatty: uid=10085(com.example.smitsanghvi.cloudassigment) identical 10 lines
09-25 20:54:15.432 7589-7589/com.example.smitsanghvi.cloudassigment W/.cloudassigmen: JIT profile information will not be recorded: profile file does not exits.
09-25 20:54:15.740 7589-7589/com.example.smitsanghvi.cloudassigment I/InstantRun: starting instant run server: is main process
09-25 20:54:17.026 7589-7589/com.example.smitsanghvi.cloudassigment W/.cloudassigmen: Accessing hidden method Landroid/view/View;->computeFitSystemWindows(Landroid/graphics/Rect;Landroid/graphics/Rect;)Z (light greylist, reflection)
09-25 20:54:17.033 7589-7589/com.example.smitsanghvi.cloudassigment W/.cloudassigmen: Accessing hidden method Landroid/view/ViewGroup;->makeOptionalFitsSystemWindows()V (light greylist, reflection)
09-25 20:54:17.108 7589-7589/com.example.smitsanghvi.cloudassigment I/WebViewFactory: Loading com.android.chrome version 69.0.3497.100 (code 349710012)
09-25 20:54:17.599 7589-7589/com.example.smitsanghvi.cloudassigment I/cr_LibraryLoader: Time to load native libraries: 25 ms (timestamps 6319-6344)
09-25 20:54:17.744 7589-7589/com.example.smitsanghvi.cloudassigment I/chromium: [INFO:library_loader_hooks.cc(36)] Chromium logging enabled: level = 0, default verbosity = 0
09-25 20:54:17.745 7589-7589/com.example.smitsanghvi.cloudassigment I/cr_LibraryLoader: Expected native library version number "69.0.3497.100", actual native library version number "69.0.3497.100"
09-25 20:54:17.758 7589-7615/com.example.smitsanghvi.cloudassigment E/cr_VariationsUtils: Failed reading seed file "/data/user/0/com.example.smitsanghvi.cloudassigment/app_webview/variations_seed": /data/user/0/com.example.smitsanghvi.cloudassigment/app_webview/variations_seed (No such file or directory)
09-25 20:54:17.788 7589-7616/com.example.smitsanghvi.cloudassigment W/cr_ChildProcLH: Create a new ChildConnectionAllocator with package name = com.android.chrome, sandboxed = true
09-25 20:54:17.856 7589-7589/com.example.smitsanghvi.cloudassigment I/cr_BrowserStartup: Initializing chromium process, singleProcess=false
09-25 20:54:18.541 7589-7589/com.example.smitsanghvi.cloudassigment W/.cloudassigmen: Accessing hidden method Landroid/view/textclassifier/logging/SmartSelectionEventTracker;-><init>(Landroid/content/Context;I)V (light greylist, reflection)
Accessing hidden method Landroid/view/textclassifier/logging/SmartSelectionEventTracker;->logEvent(Landroid/view/textclassifier/logging/SmartSelectionEventTracker$SelectionEvent;)V (light greylist, reflection)
09-25 20:54:18.542 7589-7589/com.example.smitsanghvi.cloudassigment W/.cloudassigmen: Accessing hidden method Landroid/view/textclassifier/logging/SmartSelectionEventTracker$SelectionEvent;->selectionStarted(I)Landroid/view/textclassifier/logging/SmartSelectionEventTracker$SelectionEvent; (light greylist, reflection)
Accessing hidden method Landroid/view/textclassifier/logging/SmartSelectionEventTracker$SelectionEvent;->selectionModified(II)Landroid/view/textclassifier/logging/SmartSelectionEventTracker$SelectionEvent; (light greylist, reflection)
Accessing hidden method Landroid/view/textclassifier/logging/SmartSelectionEventTracker$SelectionEvent;->selectionModified(IILandroid/view/textclassifier/TextClassification;)Landroid/view/textclassifier/logging/SmartSelectionEventTracker$SelectionEvent; (light greylist, reflection)
Accessing hidden method Landroid/view/textclassifier/logging/SmartSelectionEventTracker$SelectionEvent;->selectionModified(IILandroid/view/textclassifier/TextSelection;)Landroid/view/textclassifier/logging/SmartSelectionEventTracker$SelectionEvent; (light greylist, reflection)
Accessing hidden method Landroid/view/textclassifier/logging/SmartSelectionEventTracker$SelectionEvent;->selectionAction(III)Landroid/view/textclassifier/logging/SmartSelectionEventTracker$SelectionEvent; (light greylist, reflection)
Accessing hidden method Landroid/view/textclassifier/logging/SmartSelectionEventTracker$SelectionEvent;->selectionAction(IIILandroid/view/textclassifier/TextClassification;)Landroid/view/textclassifier/logging/SmartSelectionEventTracker$SelectionEvent; (light greylist, reflection)
09-25 20:54:18.720 7589-7638/com.example.smitsanghvi.cloudassigment W/cr_media: Requires BLUETOOTH permission
09-25 20:54:18.761 7589-7625/com.example.smitsanghvi.cloudassigment D/NetworkSecurityConfig: No Network Security Config specified, using platform default
09-25 20:54:18.806 7589-7589/com.example.smitsanghvi.cloudassigment D/OpenGLRenderer: Skia GL Pipeline
09-25 20:54:19.025 7589-7662/com.example.smitsanghvi.cloudassigment I/ConfigStore: android::hardware::configstore::V1_0::ISurfaceFlingerConfigs::hasWideColorDisplay retrieved: 0
09-25 20:54:19.027 7589-7662/com.example.smitsanghvi.cloudassigment I/ConfigStore: android::hardware::configstore::V1_0::ISurfaceFlingerConfigs::hasHDRDisplay retrieved: 0
09-25 20:54:19.038 7589-7662/com.example.smitsanghvi.cloudassigment D/EGL_emulation: eglCreateContext: 0xcf803840: maj 3 min 0 rcv 3
09-25 20:54:19.039 7589-7662/com.example.smitsanghvi.cloudassigment D/EGL_emulation: eglMakeCurrent: 0xcf803840: ver 3 0 (tinfo 0xcf708f90)
09-25 20:54:19.262 7589-7667/com.example.smitsanghvi.cloudassigment I/OpenGLRenderer: Initialized EGL, version 1.4
09-25 20:54:19.262 7589-7667/com.example.smitsanghvi.cloudassigment D/OpenGLRenderer: Swap behavior 1
09-25 20:54:19.265 7589-7667/com.example.smitsanghvi.cloudassigment W/OpenGLRenderer: Failed to choose config with EGL_SWAP_BEHAVIOR_PRESERVED, retrying without...
09-25 20:54:19.266 7589-7667/com.example.smitsanghvi.cloudassigment D/OpenGLRenderer: Swap behavior 0
09-25 20:54:19.273 7589-7667/com.example.smitsanghvi.cloudassigment D/EGL_emulation: eglCreateContext: 0xcf8035a0: maj 3 min 0 rcv 3
09-25 20:54:19.292 7589-7667/com.example.smitsanghvi.cloudassigment D/EGL_emulation: eglMakeCurrent: 0xcf8035a0: ver 3 0 (tinfo 0xcf74e2b0)
09-25 20:54:19.638 7589-7667/com.example.smitsanghvi.cloudassigment D/EGL_emulation: eglMakeCurrent: 0xcf8035a0: ver 3 0 (tinfo 0xcf74e2b0)
09-25 20:54:19.896 7589-7662/com.example.smitsanghvi.cloudassigment W/VideoCapabilities: Unrecognized profile 4 for video/hevc
09-25 20:54:20.048 7589-7662/com.example.smitsanghvi.cloudassigment I/VideoCapabilities: Unsupported profile 4 for video/mp4v-es
09-25 20:54:20.107 7589-7667/com.example.smitsanghvi.cloudassigment I/OpenGLRenderer: Davey! duration=900ms; Flags=0, IntendedVsync=2307946960898, Vsync=2308346960882, OldestInputEvent=9223372036854775807, NewestInputEvent=0, HandleInputStart=2308351487351, AnimationStart=2308351545351, PerformTraversalsStart=2308351596351, DrawStart=2308377901351, SyncQueued=2308383974351, SyncStart=2308389276351, IssueDrawCommandsStart=2308391431351, SwapBuffers=2308827224351, FrameCompleted=2308853055351, DequeueBufferDuration=328000, QueueBufferDuration=1955000,
09-25 20:54:20.107 7589-7662/com.example.smitsanghvi.cloudassigment W/cr_MediaCodecUtil: HW encoder for video/avc is not available on this device.
09-25 20:54:20.291 7589-7613/com.example.smitsanghvi.cloudassigment W/cr_CrashFileManager: /data/user/0/com.example.smitsanghvi.cloudassigment/cache/WebView/Crash Reports does not exist or is not a directory
09-25 20:54:23.405 7589-7662/com.example.smitsanghvi.cloudassigment D/EGL_emulation: eglCreateContext: 0xca251560: maj 3 min 0 rcv 3
09-25 20:54:23.406 7589-7662/com.example.smitsanghvi.cloudassigment D/EGL_emulation: eglMakeCurrent: 0xca251560: ver 3 0 (tinfo 0xcf708f90)
09-25 20:54:31.146 7589-7589/com.example.smitsanghvi.cloudassigment I/chromium: [INFO:CONSOLE(32048)] source: http://10.0.2.2:3000/static/js/bundle.js (32048)
09-25 20:54:31.679 7589-7589/com.example.smitsanghvi.cloudassigment I/chromium: [INFO:CONSOLE(43724)] "Uncaught TypeError: Cannot read property 'apply' of undefined", source: http://10.0.2.2:3000/static/js/bundle.js (43724)
I tried these IPs:
localhost:3000
http://127.0.0.1:3000/
http://10.0.2.2:3000
All of them are working from my browser.
Mainactivity.java
package com.example.smitsanghvi.cloudassigment;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;
public class MainActivity extends AppCompatActivity {
private WebView webview;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
webview = (WebView) findViewById(R.id.webview);
webview.setWebViewClient(new WebViewClient());
webview.loadUrl("127.0.0.1:3000");
WebSettings webSettings=webview.getSettings();
webSettings.setJavaScriptEnabled(true);
}
#Override
public void onBackPressed() {
if(webview.canGoBack())
{
webview.goBack();
}
else {
super.onBackPressed();
}
}
}
AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.smitsanghvi.cloudassigment">
<uses-permission android:name="android.permission.INTERNET"/>
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:roundIcon="#mipmap/ic_launcher_round"
android:supportsRtl="true"
android:usesCleartextTraffic="true"
android:theme="#style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
If you're using a physical device to run, then,
make sure your website is running at 192.168.x.xxx:port
set the full url in your activity, such as,
webview.loadUrl("http://192.168.1.107:3000/");
add
android:usesCleartextTraffic="true"
in AndroidManifest.xml to fix 'cleartext not permitted' error caused for not using https
For emulator use 10.0.2.2 as stated in the previous answer and follow the 3rd step
Use this
webview.loadUrl("http://10.0.2.2:3000");
Instead of
webview.loadUrl("127.0.0.1:3000");

Categories