Reputation: 71
The app works on previous versions of Android, but not on Oreo. It's a WebView
with Notification
s. I've been researching this error and haven't found anything similar.
The stack trace:
E/AndroidRuntime: FATAL EXCEPTION: main
Process: net.oneteamit.tk, PID: 3171
java.lang.RuntimeException: Unable to start activity ComponentInfo{net.oneteamit.tk/net.oneteamit.tk.MainActivity}:
java.lang.IllegalArgumentException
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2817)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2892)
at android.app.ActivityThread.-wrap11(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1593)
at android.os.Handler.dispatchMessage(Handler.java:105)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6541)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)
Caused by: java.lang.IllegalArgumentException
at android.os.Parcel.readException(Parcel.java:1946)
at android.os.Parcel.readException(Parcel.java:1888)
at android.app.INotificationManager$Stub$Proxy.createNotificationChannels(INotificationManager.java:1418)
at android.app.NotificationManager.createNotificationChannels(NotificationManager.java:446)
at android.app.NotificationManager.createNotificationChannel(NotificationManager.java:434)
at net.oneteamit.tk.MainActivity.onCreate(MainActivity.java:47)
at android.app.Activity.performCreate(Activity.java:6975)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1213)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2770)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2892)
at android.app.ActivityThread.-wrap11(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1593)
at android.os.Handler.dispatchMessage(Handler.java:105)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6541)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)
MainActivity
:
public class MainActivity extends AppCompatActivity {
private WebView mWebView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mWebView = (WebView) findViewById(R.id.activity_main_webview);
WebSettings webSettings = mWebView.getSettings();
webSettings.setJavaScriptEnabled(true);
mWebView.loadUrl("My test URL");
mWebView.setWebViewClient(new WebViewClient());
mWebView.getSettings().setAppCacheEnabled(false);
mWebView.clearCache(true);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
// Create channel to show notifications.
String channelId = getString(R.string.default_notification_channel_id);
String channelName = getString(R.string.default_notification_channel_name);
NotificationManager notificationManager =
getSystemService(NotificationManager.class);
notificationManager.createNotificationChannel(
new NotificationChannel(channelId,
channelName,
NotificationManager.IMPORTANCE_LOW));
}
mWebView.getSettings().setUseWideViewPort(true);
mWebView.getSettings().setLoadWithOverviewMode(true);
mWebView.setInitialScale(1);
mWebView.getSettings().setBuiltInZoomControls(true);
}
}
Upvotes: 7
Views: 5307
Reputation: 41
<string name="app_name"></string>
was the reason of this error. Empty string causes FATAL EXCEPTION.
Upvotes: 3
Reputation: 38319
This exception occurs when the channel name is invalid. I was able to reproduce the stack trace by running with an empty channel name:
<string name="default_notification_channel_name"></string>
Check the value you have defined for default_notification_channel_name
and change it to a valid value.
Upvotes: 13
Reputation: 101
AppCompactActivity is backward compatible but not forward compatible,are there any components that you are using that are not supported by Android 8.0,or is the Android Studio or the IDE up to date with Oreo.
Upvotes: 1