Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/364.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 不幸的是,“应用程序”已经停止_Java_Android - Fatal编程技术网

Java 不幸的是,“应用程序”已经停止

Java 不幸的是,“应用程序”已经停止,java,android,Java,Android,这是我的日志 08-06 21:38:29.646 25786-25786/com.example.ananaybatra.reddit I/dalvikvm﹕ Could not find method android.content.res.TypedArray.getChangingConfigurations, referenced from method android.support.v7.internal.widget.TintTypedArray.getChanging

这是我的日志

    08-06 21:38:29.646  25786-25786/com.example.ananaybatra.reddit I/dalvikvm﹕ Could not find method android.content.res.TypedArray.getChangingConfigurations, referenced from method android.support.v7.internal.widget.TintTypedArray.getChangingConfigurations
08-06 21:38:29.646  25786-25786/com.example.ananaybatra.reddit W/dalvikvm﹕ VFY: unable to resolve virtual method 407: Landroid/content/res/TypedArray;.getChangingConfigurations ()I
08-06 21:38:29.646  25786-25786/com.example.ananaybatra.reddit D/dalvikvm﹕ VFY: replacing opcode 0x6e at 0x0002
08-06 21:38:29.646  25786-25786/com.example.ananaybatra.reddit I/dalvikvm﹕ Could not find method android.content.res.TypedArray.getType, referenced from method android.support.v7.internal.widget.TintTypedArray.getType
08-06 21:38:29.646  25786-25786/com.example.ananaybatra.reddit W/dalvikvm﹕ VFY: unable to resolve virtual method 429: Landroid/content/res/TypedArray;.getType (I)I
08-06 21:38:29.646  25786-25786/com.example.ananaybatra.reddit D/dalvikvm﹕ VFY: replacing opcode 0x6e at 0x0002
08-06 21:38:29.802  25786-25786/com.example.ananaybatra.reddit V/WebViewChromiumFactoryProvider﹕ Binding Chromium to main looper Looper (main, tid 1) {41cca600}
08-06 21:38:29.802  25786-25786/com.example.ananaybatra.reddit I/LibraryLoader﹕ Expected native library version number "",actual native library version number ""
08-06 21:38:29.802  25786-25786/com.example.ananaybatra.reddit I/chromium﹕ [INFO:library_loader_hooks.cc(116)] Chromium logging enabled: level = 0, default verbosity = 0
08-06 21:38:29.802  25786-25786/com.example.ananaybatra.reddit I/BrowserStartupController﹕ Initializing chromium process, renderers=0
08-06 21:38:29.810  25786-25786/com.example.ananaybatra.reddit E/AudioManagerAndroid﹕ BLUETOOTH permission is missing!
08-06 21:38:29.833  25786-25786/com.example.ananaybatra.reddit D/libEGL﹕ loaded /vendor/lib/egl/libEGL_POWERVR_SGX540_120.so
08-06 21:38:29.841  25786-25786/com.example.ananaybatra.reddit D/libEGL﹕ loaded /vendor/lib/egl/libGLESv1_CM_POWERVR_SGX540_120.so
08-06 21:38:29.841  25786-25786/com.example.ananaybatra.reddit D/libEGL﹕ loaded /vendor/lib/egl/libGLESv2_POWERVR_SGX540_120.so
08-06 21:38:30.513  25786-25825/com.example.ananaybatra.reddit W/chromium﹕ [WARNING:proxy_service.cc(890)] PAC support disabled because there is no system implementation
08-06 21:38:30.685  25786-25786/com.example.ananaybatra.reddit D/AndroidRuntime﹕ Shutting down VM
08-06 21:38:30.685  25786-25786/com.example.ananaybatra.reddit W/dalvikvm﹕ threadid=1: thread exiting with uncaught exception (group=0x419a0ba8)
08-06 21:38:30.685  25786-25786/com.example.ananaybatra.reddit E/AndroidRuntime﹕ FATAL EXCEPTION: main
    Process: com.example.ananaybatra.reddit, PID: 25786
    java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.ananaybatra.reddit/com.example.ananaybatra.reddit.MainActivity}: java.lang.ClassCastException: android.widget.RelativeLayout cannot be cast to android.webkit.WebView
            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2221)
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2280)
            at android.app.ActivityThread.access$800(ActivityThread.java:141)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1202)
            at android.os.Handler.dispatchMessage(Handler.java:102)
            at android.os.Looper.loop(Looper.java:136)
            at android.app.ActivityThread.main(ActivityThread.java:5059)
            at java.lang.reflect.Method.invokeNative(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:515)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
            at dalvik.system.NativeStart.main(Native Method)
     Caused by: java.lang.ClassCastException: android.widget.RelativeLayout cannot be cast to android.webkit.WebView
            at com.example.ananaybatra.reddit.MainActivity.onCreate(MainActivity.java:26)
            at android.app.Activity.performCreate(Activity.java:5312)
            at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2178)
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2280)
            at android.app.ActivityThread.access$800(ActivityThread.java:141)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1202)
            at android.os.Handler.dispatchMessage(Handler.java:102)
            at android.os.Looper.loop(Looper.java:136)
            at android.app.ActivityThread.main(ActivityThread.java:5059)
            at java.lang.reflect.Method.invokeNative(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:515)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
            at dalvik.system.NativeStart.main(Native Method)
08-06 21:38:33.427  25786-25786/com.example.ananaybatra.reddit I/Process﹕ Sending signal. PID: 25786 SIG: 9
08-06 21:40:44.935  26681-26681/com.example.ananaybatra.reddit D/dalvikvm﹕ Late-enabling CheckJNI
08-06 21:40:45.443  26681-26681/com.example.ananaybatra.reddit I/dalvikvm﹕ Could not find method android.content.res.TypedArray.getChangingConfigurations, referenced from method android.support.v7.internal.widget.TintTypedArray.getChangingConfigurations
08-06 21:40:45.443  26681-26681/com.example.ananaybatra.reddit W/dalvikvm﹕ VFY: unable to resolve virtual method 407: Landroid/content/res/TypedArray;.getChangingConfigurations ()I
08-06 21:40:45.451  26681-26681/com.example.ananaybatra.reddit D/dalvikvm﹕ VFY: replacing opcode 0x6e at 0x0002
08-06 21:40:45.451  26681-26681/com.example.ananaybatra.reddit I/dalvikvm﹕ Could not find method android.content.res.TypedArray.getType, referenced from method android.support.v7.internal.widget.TintTypedArray.getType
08-06 21:40:45.451  26681-26681/com.example.ananaybatra.reddit W/dalvikvm﹕ VFY: unable to resolve virtual method 429: Landroid/content/res/TypedArray;.getType (I)I
08-06 21:40:45.451  26681-26681/com.example.ananaybatra.reddit D/dalvikvm﹕ VFY: replacing opcode 0x6e at 0x0002
08-06 21:40:45.505  26681-26681/com.example.ananaybatra.reddit V/WebViewChromiumFactoryProvider﹕ Binding Chromium to main looper Looper (main, tid 1) {41cd1598}
08-06 21:40:45.505  26681-26681/com.example.ananaybatra.reddit I/LibraryLoader﹕ Expected native library version number "",actual native library version number ""
08-06 21:40:45.513  26681-26681/com.example.ananaybatra.reddit I/chromium﹕ [INFO:library_loader_hooks.cc(116)] Chromium logging enabled: level = 0, default verbosity = 0
08-06 21:40:45.513  26681-26681/com.example.ananaybatra.reddit I/BrowserStartupController﹕ Initializing chromium process, renderers=0
08-06 21:40:45.919  26681-26681/com.example.ananaybatra.reddit E/AudioManagerAndroid﹕ BLUETOOTH permission is missing!
08-06 21:40:46.068  26681-26681/com.example.ananaybatra.reddit D/libEGL﹕ loaded /vendor/lib/egl/libEGL_POWERVR_SGX540_120.so
08-06 21:40:46.083  26681-26681/com.example.ananaybatra.reddit D/libEGL﹕ loaded /vendor/lib/egl/libGLESv1_CM_POWERVR_SGX540_120.so
08-06 21:40:46.083  26681-26681/com.example.ananaybatra.reddit D/libEGL﹕ loaded /vendor/lib/egl/libGLESv2_POWERVR_SGX540_120.so
08-06 21:40:46.544  26681-26703/com.example.ananaybatra.reddit W/chromium﹕ [WARNING:proxy_service.cc(890)] PAC support disabled because there is no system implementation
08-06 21:40:46.685  26681-26681/com.example.ananaybatra.reddit D/AndroidRuntime﹕ Shutting down VM
08-06 21:40:46.685  26681-26681/com.example.ananaybatra.reddit W/dalvikvm﹕ threadid=1: thread exiting with uncaught exception (group=0x419a0ba8)
08-06 21:40:46.685  26681-26681/com.example.ananaybatra.reddit E/AndroidRuntime﹕ FATAL EXCEPTION: main
    Process: com.example.ananaybatra.reddit, PID: 26681
    java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.ananaybatra.reddit/com.example.ananaybatra.reddit.MainActivity}: java.lang.ClassCastException: android.widget.RelativeLayout cannot be cast to android.webkit.WebView
            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2221)
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2280)
            at android.app.ActivityThread.access$800(ActivityThread.java:141)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1202)
            at android.os.Handler.dispatchMessage(Handler.java:102)
            at android.os.Looper.loop(Looper.java:136)
            at android.app.ActivityThread.main(ActivityThread.java:5059)
            at java.lang.reflect.Method.invokeNative(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:515)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
            at dalvik.system.NativeStart.main(Native Method)
     Caused by: java.lang.ClassCastException: android.widget.RelativeLayout cannot be cast to android.webkit.WebView
            at com.example.ananaybatra.reddit.MainActivity.onCreate(MainActivity.java:26)
            at android.app.Activity.performCreate(Activity.java:5312)
            at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2178)
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2280)
            at android.app.ActivityThread.access$800(ActivityThread.java:141)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1202)
            at android.os.Handler.dispatchMessage(Handler.java:102)
            at android.os.Looper.loop(Looper.java:136)
            at android.app.ActivityThread.main(ActivityThread.java:5059)
            at java.lang.reflect.Method.invokeNative(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:515)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
            at dalvik.system.NativeStart.main(Native Method)
device not found
这是我的主要活动。java

package com.example.ananaybatra.reddit;

import android.content.Context;
import android.content.Intent;
import android.os.StrictMode;
import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;


public class MainActivity extends ActionBarActivity {

    private WebView mWebView;

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

        final Context context = this;

        mWebView= (WebView) findViewById(R.id.activity_main_webview);
        WebSettings websettings = mWebView.getSettings();
        websettings.setJavaScriptEnabled(true);
        mWebView.loadUrl("https://www.reddit.com/");
        mWebView.setWebViewClient(new MyAppWebViewClient());

        Intent intent = new Intent(this, WebViewActivity.class);
        startActivity(intent);

        StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
        StrictMode.setThreadPolicy(policy);

    }

    @Override
    public void onBackPressed() {


        if (mWebView.canGoBack()) {
            mWebView.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);
    }

    private class MyAppWebViewClient extends WebViewClient{

    }

}
这是我的MyAppWebViewClient

package com.example.ananaybatra.reddit;

import android.content.Intent;
import android.net.Uri;
import android.webkit.WebView;



/**
 * Created by ananaybatra on 06/08/15.
 */
public class MyAppWebViewClient extends WebViewActivity {

    @Override
    public boolean shouldOverrideUrlLoading(WebView view, String url){
        if(Uri.parse(url).getHost().endsWith("html5rock.com")){
            return false;
        }


        Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
        view.getContext().startActivity(intent);
        return true;


    }
}
这是我的Androidmanifest.xml

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

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

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme"
        android:largeHeap="true"
        >
        <activity
            android:name=".MainActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

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



</manifest>
这是我的activity_main.xml

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
    android:layout_height="match_parent"  tools:context=".MainActivity"
    android:id="@+id/activity_main_webview">

    <WebView
        android:text="@string/hello_world" android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/textView" />

</RelativeLayout>
我的android应用程序一启动就意外关闭了。
一旦我在android模拟器或手机上启动我的应用程序,它就会崩溃,不幸的是,应用程序已经停止

任何帮助都将不胜感激。谢谢
我正在尝试将我的网站转换为android应用程序。

您正在将网络视图初始化为相对视图。请看下面的一行

mWebView= (WebView) findViewById(R.id.activity_main_webview);
以下ID activity_main_webview是RelativeLayout而不是webview的ID

将该行替换为:

mWebView = (WebView) findViewById(R.id.textView);

请尝试对视图使用更具描述性的ID。例如,WebView的ID可能是WebView而不是textView:。

如果查看xml,则您的活动\u main\u WebView是相对的。您正在MainActivity.java中将其转换为WebView

你可能想这样做

    mWebView= (WebView) findViewById(R.id.textView);

如果您查看xml,您的activity\u main\u webview是一个相对的视图。您正在MainActivity.java中将其强制转换为WebView。您的WebView的id是textview。您正在尝试获取活动\主\网络视图,它是一个布局,而不是网络视图。改为使用textview。您的xml文件中是否有id为activity\u main\u webview的RelativeLayout?@AnanBatra请尝试按照我在回答中所述重命名您的WebViews id,仍然可以获得same@AnanBatra您必须得到不同的异常与同一异常中的错误相同,或者不幸的是,“应用程序”意外停止,应用程序已停止