The App works on previous versions of Android but not on Oreo, its a webview using Firebase Notifications. I am a bit new to this but have been researching this error and haven't found anything that is similar.
--------- beginning of crash
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) W/cr_media: Requires BLUETOOTH permission Application terminated.
public class MainActivity extends AppCompatActivity {
private WebView mWebView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView( R.layout.activity_main );
//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()); //I DISABLED THIS TO HAVE IT OPEN in browser
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));
}
//webSettings.setDomStorageEnabled (true);
//mWebView.getSettings().setDomStorageEnabled(true);
//mWebView.getSettings().setDatabaseEnabled(true);
//mWebView.getSettings().setAppCacheEnabled(true);
//mWebView.getSettings().setJavaScriptEnabled(true);
//mWebView.setFocusable(false);
//mWebView.setFocusableInTouchMode(false);
//mWebView.getSettings().setRenderPriority(WebSettings.RenderPriority.HIGH);
// mWebView.getSettings().setCacheMode(WebSettings.LOAD_NO_CACHE);
//mWebView.setScrollBarStyle(View.SCROLLBARS_OUTSIDE_OVERLAY);
//mWebView.setScrollbarFadingEnabled(false);
//this.mWebView.setVerticalScrollBarEnabled(true);
//this.mWebView.setHorizontalScrollBarEnabled(true);
mWebView.getSettings().setUseWideViewPort(true);//setting wide view
mWebView.getSettings().setLoadWithOverviewMode(true);//setting default zoomed out view
mWebView.setInitialScale(1);
mWebView.getSettings().setBuiltInZoomControls(true);//setting zoom controls
}
@Override
public void onBackPressed() {
if(mWebView.canGoBack()) {
mWebView.goBack();
} else {
super.onBackPressed();
}
}
@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);
}
}
Manifest
<application
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.AppCompat.Light.NoActionBar">
<!-- Set custom default icon. This is used when no icon is set for incoming notification messages.
<meta-data
android:name="com.google.firebase.messaging.default_notification_icon"
android:resource="@mipmap/ic_launcher" />
<!-- the location above will tell the app where to look for your notification Icon -->
<meta-data
android:name="com.google.firebase.messaging.default_notification_color"
android:resource="@color/colorAccent" />
<meta-data
android:name="com.google.firebase.messaging.default_notification_channel_id"
android:value="@string/default_notification_channel_id"/>
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="com.androidsrc.launchfrombrowser" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
</intent-filter>
</activity>
<service android:name=".FirebaseInstanceIdService">
<intent-filter>
<action android:name="com.google.firebase.INSTANCE_ID_EVENT" />
</intent-filter>
</service>
<service android:name=".FirebaseMessagingService">
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT" />
</intent-filter>
</service>
<service android:name=".MyJobService"
android:exported="false">
<intent-filter>
<action android:name="com.firebase.jobdispatcher.ACTION_EXECUTE"/>
</intent-filter>
</service>
</application>
<uses-permission android:name="android.permission.INTERNET" />