Error:
02/01 14:12:04: Launching app
$ adb push /Users/Kamran/AndroidStudioProjects/App/app/build/outputs/apk/app-debug.apk /data/local/tmp/com.kami2017.app
$ adb shell pm install -r "/data/local/tmp/com.kami2017.app"
Success
$ adb shell am start -n "com.kami2017.app/com.kami2017.app.MainActivity" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER
Client not ready yet..Waiting for process to come online
Connected to process 2284 on device emulator-5554
W/System: ClassLoader referenced unknown path: /data/app/com.kami2017.app-1/lib/x86
[ 02-01 14:12:28.511 1531: 1552 D/ ]
HostConnection::get() New Host Connection established 0x85a8d240, tid 1552
I/InstantRun: Instant Run Runtime started. Android package is com.kami2017.app, real application class is null.
W/System: ClassLoader referenced unknown path: /data/app/com.kami2017.app-1/lib/x86
W/art: Before Android 4.1, method android.graphics.PorterDuffColorFilter android.support.graphics.drawable.VectorDrawableCompat.updateTintFilter(android.graphics.PorterDuffColorFilter, android.content.res.ColorStateList, android.graphics.PorterDuff$Mode) would have incorrectly overridden the package-private method in android.graphics.drawable.Drawable
D/AndroidRuntime: Shutting down VM
--------- beginning of crash
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.kami2017.app, PID: 2284
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.kami2017.app/com.kami2017.app.MainActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'android.webkit.WebSettings android.webkit.WebView.getSettings()' on a null object reference
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2665)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2726)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1477)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6119)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'android.webkit.WebSettings android.webkit.WebView.getSettings()' on a null object reference
at com.kami2017.app.MainActivity.onCreate(MainActivity.java:17)
at android.app.Activity.performCreate(Activity.java:6679)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1118)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2618)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2726)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1477)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6119)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
Application terminated.
-1
A
답변
0
XML 파일에서 WebView에 대한 ID를 제공하지 않은 것 같습니다. 해당 WebView에 액세스하려고합니다.
는 참고로 아래의 링크로 찾아보세요 : Getting void android.webkit.WebView.loadUrl while loading webview in dialog in Android?
0
귀하의 웹보기가 null입니다. 귀하의 활동에서 XML 파일로부터 webview에 대한 인스턴스를 생성 했습니까?
WebView myWebView = (WebView) findViewById(R.id.webview);
WebSettings webSettings = myWebView.getSettings();
또는 프로그래밍 방식으로 새 웹보기 만들어야합니다 : java.lang.NullPointerException이 :에 의한
WebView webView = new WebView(this);
+0
위의 코드를 어디에 삽입해야합니까? 친절하게 도와주세요. –
+0
MainActivity.java:17 주위에 코드를 붙여 넣을 수 있습니까? 나는 어떤 라인을 말할 것인가? –
를 가상 메서드 'android.webkit.WebSettings의 android.webkit.WebView.getSettings를 호출 시도 () 'com.kami2017.app.MainActivity.onCreate (MainActivity.java:17)에서 null 객체 참조에 대해 친절하게 도와주세요 ........ –