Android studio 应用程序崩溃 webView

Android studio Aplication Crash webView

我正在编写一个应用程序。 我确实从 activity 1 到 2 和 1 到 3 和 1 到 4 但是我的应用程序崩溃了;(

有一个代码: 主要活动 1

    package musial.pzstis.com.pzstiz;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        Button next = (Button) findViewById(R.id.synergia);
        next.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent(MainActivity.this, Main3Activity.class);
                startActivity(intent);
            }
        });}

    {

        Button loadNewActivity = (Button) findViewById(R.id.dzwonki);
        loadNewActivity.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View view) {
                Intent intent = new Intent(MainActivity.this, Main4Activity.class);
                startActivity(intent);
            }
        });
    }
}

Main3Activity

    package musial.pzstis.com.pzstiz;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.Menu;
import android.view.MenuItem;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;

public class Main3Activity extends AppCompatActivity {
    private WebView myWebView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main3);
        myWebView = (WebView)findViewById(R.id.webView2);
        WebSettings webSettings = myWebView.getSettings();
        webSettings.setJavaScriptEnabled(true);
        myWebView.loadUrl("https://synergia.librus.pl/loguj");
        myWebView.setWebViewClient(new WebViewClient());

    }

    @Override
    public void onBackPressed() {
        if(myWebView.canGoBack()){
            myWebView.goBack();
        } else {
            super.onBackPressed();
        }
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.menu_main, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        // Handle action bar item clicks here. The action bar will
        // automatically handle clicks on the Home/Up button, so long
        // as you specify a parent activity in AndroidManifest.xml.
        int id = item.getItemId();

        //noinspection SimplifiableIfStatement
        if (id == R.id.action_settings) {
            return true;
        }

        return super.onOptionsItemSelected(item);
    }
}

Main4Activity

    package musial.pzstis.com.pzstiz;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;

public class Main4Activity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main4);
    }
}

清单

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

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

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:supportsRtl="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>
        <activity android:name=".Main2Activity">
            <intent-filter>

                <category android:name="android.intent.category.DEFAULT"/>
            </intent-filter>
        </activity>
        <activity android:name=".Main4Activity">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.DEFAULT"/>
        </intent-filter>
        </activity>
        <activity android:name=".Main3Activity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

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

    </application>

</manifest>

活动 1 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:id="@+id/activity_main"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context="musial.pzstis.com.pzstiz.MainActivity">


    <Button
        android:text="E-DZIENNIK"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="29dp"
        android:id="@+id/synergia"
        android:layout_below="@+id/dzwonki"
        android:layout_centerHorizontal="true" />

    <Button
        android:text="OGLOSZENIA"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/button3"
        android:layout_marginTop="36dp"
        android:layout_below="@+id/synergia"
        android:layout_alignLeft="@+id/dzwonki"
        android:layout_alignStart="@+id/dzwonki" />

    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="ZASTĘPSTWA"
        android:id="@+id/Za"
        android:layout_marginTop="21dp"
        android:layout_below="@+id/Bt"
        android:layout_alignLeft="@+id/synergia"
        android:layout_alignStart="@+id/synergia" />

    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="NEWSY"
        android:id="@+id/Bt"
        android:layout_marginTop="41dp"
        android:layout_alignParentTop="true"
        android:layout_alignRight="@+id/synergia"
        android:layout_alignEnd="@+id/synergia" />

    <TextClock
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_above="@+id/checkBox"
        android:layout_toRightOf="@+id/button3"
        android:layout_toEndOf="@+id/button3"
        android:layout_marginLeft="20dp"
        android:layout_marginStart="20dp"
        android:id="@+id/textClock" />

    <Button
        android:text="DZWONKI"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/dzwonki"
        android:layout_marginTop="29dp"
        android:layout_below="@+id/Za"
        android:layout_alignRight="@+id/synergia"
        android:layout_alignEnd="@+id/synergia" />

    <CheckBox
        android:text="DEBUG"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/checkBox"
        android:layout_alignBottom="@+id/synergia"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true" />


</RelativeLayout>

我需要帮助,因为我正在编写一个基于许多 webview 网站的应用程序

LOG FROM CONSOLE   
 12-12 20:49:14.642 1761-4023/system_process I/ActivityManager: START u0 {act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=musial.pzstis.com.pzstiz/.MainActivity (has extras)} from uid 10024 on display 0
    12-12 20:49:14.688 1761-1775/system_process W/BroadcastQueue: Permission Denial: receiving Intent { act=com.android.launcher3.action.LAUNCH flg=0x10 (has extras) } to com.google.android.gms/.chimera.GmsIntentOperationService$GmsExternalReceiver requires com.android.launcher3.permission.RECEIVE_LAUNCH_BROADCASTS due to sender com.cyanogenmod.trebuchet (uid 10024)
    12-12 20:49:14.688 1761-1775/system_process W/BroadcastQueue: Permission Denial: broadcasting Intent { act=com.android.launcher3.action.LAUNCH flg=0x10 (has extras) } from com.cyanogenmod.trebuchet (pid=4804, uid=10024) requires com.google.android.launcher.permission.RECEIVE_LAUNCH_BROADCASTS due to receiver com.google.android.gms/.icing.proxy.ApplicationLauncherReceiver
    12-12 20:49:14.715 1761-4094/system_process I/ActivityManager: Start proc 761:musial.pzstis.com.pzstiz/u0a152 for activity musial.pzstis.com.pzstiz/.MainActivity
    12-12 20:49:14.990 1761-1772/system_process W/ActivityManager:   Force finishing activity musial.pzstis.com.pzstiz/.MainActivity
    12-12 20:49:15.124 1761-3887/system_process I/OpenGLRenderer: Initialized EGL, version 1.4
    12-12 20:49:15.535 1761-1775/system_process W/ActivityManager: Activity pause timeout for ActivityRecord{5a2804a u0 musial.pzstis.com.pzstiz/.MainActivity t405 f}
    12-12 20:49:16.552 1761-5430/system_process I/ActivityManager: Killing 31895:in.celest.xash3d.hl/u0a113 (adj 15): empty #17
    12-12 20:49:16.694 1761-1774/system_process W/art: Long monitor contention event with owner method=void com.android.server.am.ActivityManagerService.serviceDoneExecuting(android.os.IBinder, int, int, int) from ActivityManagerService.java:16425 waiters=2 for 129ms
    12-12 20:49:16.695 1761-5450/system_process W/art: Long monitor contention event with owner method=void com.android.server.am.ActivityManagerService.serviceDoneExecuting(android.os.IBinder, int, int, int) from ActivityManagerService.java:16425 waiters=3 for 134ms
    12-12 20:49:25.618 1761-1775/system_process W/ActivityManager: Activity destroy timeout for ActivityRecord{5a2804a u0 musial.pzstis.com.pzstiz/.MainActivity t405 f}

我通常使用 error-error 而不是日志。我认为这是堆栈跟踪。我 运行 你有什么代码,它一直崩溃,我在第一个 activity 上修复了你的缩进,它可以工作。下面是一个固定的缩进。记得留意你的括号 '}' 和 '{'

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    Button next = (Button) findViewById(R.id.synergia);
    next.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            Intent intent = new Intent(MainActivity.this, Main3Activity.class);
            startActivity(intent);
        }
    });


    Button loadNewActivity = (Button) findViewById(R.id.dzwonki);
    loadNewActivity.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            Intent intent = new Intent(MainActivity.this, Main4Activity.class);
            startActivity(intent);
        }
    });

}