我自横刀向天笑,去留肝胆两昆仑。这篇文章主要讲述android Oreo Crash错误相关的知识,希望能为你提供帮助。
该应用程序适用于以前版本的android,但不适用于Oreo,它是使用Firebase通知的Web视图。我对此有点新,但一直在研究这个错误,并没有发现任何类似的东西。
---------崩溃的开始
【android Oreo Crash错误】E / AndroidRuntime:FATAL EXCEPTION:main进程:net.oneteamit.tk,PID:3171 java.lang.RuntimeException:无法启动活动ComponentInfo {net.oneteamit.tk/net.oneteamit.tk.MainActivity}:java.lang。 android.app.A活动时的android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2817)中的android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2892)的android.app.ActivityThread.-wrap11(未知来源:0)的IllegalArgumentException .ActivityThread $ H.handleMessage(ActivityThread.java:1593)在android.app.Loper.loop(Looper.java:164)的android.app.A.运行时,在android.app.ActivityThread的android.os.Handler.dispatchMessage(Handler.java:105)。 main(ActivityThread.java:6541)位于com.android.internal的com.android.internal.os.Zygote $ MethodAndArgsCaller.run(Zygote.java:240)的java.lang.reflect.Method.invoke(Native Method)。 os.ZygoteInit.main(ZygoteInit.java:767)由android.os.Parcel.readException(Parcel上的android.os.Parcel.readException(Parcel.java:1946)中的java.lang.IllegalArgumentException引起.java:1888)在Android.app.NotificationManager.createNotificationChannel(NotificationManager)的android.app.otificationManager $ Stub $ Proxy.createNotificationChannels(INotificationManager.java:1418)android.app.NotificationManager.createNotificationChannels(NotificationManager.java:446)。 java:434)在net.oneteamit.tk.MainActivity.onCreate(MainActivity.java:47)android.app.Activity.performCreate(Activity.java:6975)android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1213) )android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2770)在Android.app的android.app.ActivityThread.- wrap11(未知来源:0)的android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2892) .ActivityThread $ H.handleMessage(ActivityThread.java:1593)在android.app.Loper.loop(Looper.java:164)的android.app.A.运行时,在android.app.ActivityThread的android.os.Handler.dispatchMessage(Handler.java:105)。 main(ActivityThread.java:6541)at java.lang.reflect.Method.invoke(Native M ethod)com.android.internal.os.Zygote $ MethodAndArgsCaller.run(Zygote.java:240)at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)W / cr_media:需要BLUETOOTH权限应用程序终止。
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);
}
}
表现
<
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="https://www.songbingjia.com/android/@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" />
答案通道名称无效时会发生此异常。通过使用空的通道名称运行,我能够重现堆栈跟踪:
<
string name="default_notification_channel_name">
<
/string>
检查为
default_notification_channel_name
定义的值并将其更改为有效值。另一答案AppCompactActivity是向后兼容但不向前兼容,您使用的是Android 8.0不支持的任何组件,还是Android Studio或最新的Oreo IDE。
推荐阅读
- 应用程序在启动时崩溃-android.view.InflateException(二进制XML文件行#0:二进制XML)
- 在Android工作室中没有错误,应用程序仍然在打开时崩溃
- Android - 由于设置撤销了位置权限导致应用崩溃
- /system/lib/libc.so,libgstreamer_android.so上的本机崩溃
- Android LicenseChecker因空指针异常而崩溃
- Kivy Android Sqlite3使应用程序崩溃时出现“没有这样的模块”错误
- Xamarin安卓应用程序在启动时与BroadcastReceiver崩溃但是启动了吗()
- 在Android Developer Console上崩溃和ANR
- setOnClickListener导致APP崩溃