1

I am a beginner to android dev and I am trying to launch a simple Android app with a WebView on an emulated android device.

The app opens up on the device, however none of the System.out.println messages get printed, nor Log.i(). Everything else seems to work fine though

Removing the WebView, fixes the issue.

Some kind of voodoo curse going on here.

Can anyone help me with this?

AndroidManifest.xml:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.app.myapp">

<application
    android:usesCleartextTraffic="true"
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:roundIcon="@mipmap/ic_launcher_round"
    android:supportsRtl="true"
    android:theme="@style/Theme.AndroidApp">
    <activity android:name=".MainActivity">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
</application>

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />

activity_main.xml:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity"
    android:weightSum="2">


<WebView
    android:id="@+id/webView"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    />

</RelativeLayout>

MainActivity.java:

package com.myapp.myapppackage;

import android.Manifest;
import android.os.Bundle;
import android.webkit.WebView;

import androidx.appcompat.app.AppCompatActivity;
import androidx.core.app.ActivityCompat;


public class MainActivity extends AppCompatActivity {
    private WebView webView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        System.out.println("Don't get here");
       
    }
}

log output:

Connected to process 30552 on device 'Pixel_3a_API_30_x86 [emulator-5554]'.
Connected to process 30587 on device 'Pixel_3a_API_30_x86 [emulator-5554]'.
Capturing and displaying logcat messages from application. This behavior can be disabled in the "Logcat output" section of the "Debugger" settings page.
W/ocessService0:: Unexpected CPU variant for X86 using defaults: x86
D/NetworkSecurityConfig: No Network Security Config specified, using platform default
    No Network Security Config specified, using platform default
I/cr_ChildProcessService: Creating new ChildProcessService pid=30587
TeabagD
  • 569
  • 6
  • 17
  • Does this answer your question? [NetworkSecurityConfig: No Network Security Config specified, using platform default Error response code: 400](https://stackoverflow.com/questions/53984725/networksecurityconfig-no-network-security-config-specified-using-platform-defa) – javdromero Jul 04 '21 at 15:39
  • No it doesn't. As I mentioned, if I remove the Web View, the app works as expected and the NetworkSecurityConfig message is still there. So that doesn't seem to be related to the problem. – TeabagD Jul 04 '21 at 17:09
  • But in your manifest you don't have a android:networkSecurityConfig tag – javdromero Jul 04 '21 at 17:10
  • no I don't have it, why is that necessary? If I remove the WebView I'm able to make external http requests. with HTTPUrlConnection for example. – TeabagD Jul 04 '21 at 17:12
  • Looks like this may be something to do with System.out.println() not getting to the console – TeabagD Jul 04 '21 at 17:31

0 Answers0