我的Android应用程式由于Java.lang.RuntimeException而当机

时间:2019-05-10 18:06:41

标签: java android exception runtime lang

当我在android版本7以上的模拟器或真实设备上运行此程序时,它确实可以正常工作。但是,当我尝试在android 6或5及更低版本上安装它时,即使我的最低SDK为4.0.1,也开始出现问题。或15.

最近两天,他们尝试通过不同的stackoverflow解决方案来解决该问题,但注意工作正常。

这是我的崩溃堆栈T​​arces日志

java.lang.RuntimeException: 
     at android.app.ActivityThread.performLaunchActivity 
    (ActivityThread.java:2534)
     at android.app.ActivityThread.handleLaunchActivity 
     (ActivityThread.java:2608)
     at android.app.ActivityThread.access$800 (ActivityThread.java:178)
     at android.app.ActivityThread$H.handleMessage (ActivityThread.java:1470)
     at android.os.Handler.dispatchMessage (Handler.java:111)
     at android.os.Looper.loop (Looper.java:194)
     at android.app.ActivityThread.main (ActivityThread.java:5637)
     at java.lang.reflect.Method.invoke (Method.java)
     at java.lang.reflect.Method.invoke (Method.java:372)
     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run 
     (ZygoteInit.java:959)
     at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:754)

Caused by: java.lang.RuntimeException: 
     at android.app.ActivityManager$TaskDescription.<init> 
     (ActivityManager.java:555)
     at android.app.Activity.onApplyThemeResource (Activity.java:3741)
     at android.view.ContextThemeWrapper.initializeTheme 
     (ContextThemeWrapper.java:140)
     at android.view.ContextThemeWrapper.setTheme 
     (ContextThemeWrapper.java:85)
     at android.support.v7.app.AppCompatActivity.setTheme 
     (AppCompatActivity.java)
     at android.app.ActivityThread.performLaunchActivity 
     (ActivityThread.java:2474)
     at android.app.ActivityThread.handleLaunchActivity 
     (ActivityThread.java:2608)
     at android.app.ActivityThread.access$800 (ActivityThread.java:178)
     at android.app.ActivityThread$H.handleMessage (ActivityThread.java:1470)
     at android.os.Handler.dispatchMessage (Handler.java:111)
     at android.os.Looper.loop (Looper.java:194)
     at android.app.ActivityThread.main (ActivityThread.java:5637)
     at java.lang.reflect.Method.invoke (Method.java)
     at java.lang.reflect.Method.invoke (Method.java:372)
     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run 
     (ZygoteInit.java:959)
     at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:754)

android清单

<?xml version="1.0" encoding="utf-8"?>

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

<application 
   android:allowBackup="true"
    android:icon="@drawable/iconlarge"
    android:label="@string/app_name"
    android:roundIcon="@drawable/iconlarge"
    android:supportsRtl="true"
    android:theme="@style/AppTheme">
    <activity android:name=".dropdown.AboutUs"></activity>
    <activity android:name=".Activity.MainActivity">

     <intent-filter>
       [![enter image description here][1]][1]<action android:name="android.intent.action.MAIN" />

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

    <activity android:name=".webview.seetings.PrivacyPolicy" />
    <activity android:name=".webview.seetings.TermsCondition" />
    <activity android:name=".infozone" />
    <activity android:name=".webview.timeadjust" />

</application>

这是我的Style.xml资源:

 <resources>

<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat">
    <!-- Customize your theme here. -->
    <item name="colorPrimary">@color/transparent</item>
    <item name="colorPrimaryDark">@color/black</item>
    <item name="colorAccent">@color/colorAccent</item>
</style>

<style name="AppTheme.NoActionBar">
    <item name="windowActionBar">false</item>
    <item name="windowNoTitle">true</item>
</style>

<style name="AppTheme.AppBarOverlay" 
parent="ThemeOverlay.AppCompat.Dark.ActionBar" />

<style name="AppTheme.PopupOverlay" 
parent="ThemeOverlay.AppCompat.Light"/>

<style name="TextAppearance.AppCompat.Widget.ActionBar.Title"
    parent="@android:style/TextAppearance">
    <item name="android:textSize">20sp</item>
    <item name="android:textColor">@color/black</item>
</style>

主要活动布局

    <?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <RelativeLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:gravity="center">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical"
        android:layout_marginTop="10dp">


        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_margin="4dp"
            android:gravity="center"
            android:padding="1dp"
            android:orientation="vertical">

            <TextView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:id="@+id/Land1"
                android:layout_margin="14dp"
                android:text="@string/LandTime"
                android:textAllCaps="false"
                android:textAlignment="center"
                android:textSize="15sp"
                android:textStyle="bold"
                android:textColor="@color/liteblue"
                android:background="@drawable/border"
                android:padding="10dp"
                />

            <TextView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:id="@+id/Land2"
                android:layout_margin="14dp"
                android:text="@string/LandDua"
                android:textAllCaps="false"
                android:textAlignment="center"
                android:textSize="15sp"
                android:textStyle="bold"
                android:textColor="@color/liteblue"
                android:background="@drawable/border"
                android:padding="10dp"/>

            <TextView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:id="@+id/Land3"
                android:layout_margin="14dp"
                android:text="@string/LandOju"
                android:textAllCaps="false"
                android:textAlignment="center"
                android:textSize="15sp"
                android:textStyle="bold"
                android:textColor="@color/liteblue"
                android:background="@drawable/border"
                android:padding="10dp"/>

            <TextView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:id="@+id/Land4"
                android:layout_margin="14dp"
                android:text="@string/LandKoron"
                android:textAllCaps="false"
                android:textAlignment="center"
                android:textSize="15sp"
                android:textStyle="bold"
                android:textColor="@color/liteblue"
                android:background="@drawable/border"
                android:padding="10dp"/>

            <TextView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:id="@+id/Land5"
                android:layout_margin="14dp"
                android:text="@string/LandHadis"
                android:textAllCaps="false"
                android:textAlignment="center"
                android:textSize="15sp"
                android:textStyle="bold"
                android:textColor="@color/liteblue"
                android:background="@drawable/border"
                android:padding="10dp"/>

        </LinearLayout>


        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="50dp"
            android:layout_marginBottom="50dp"
            android:orientation="horizontal"
            android:weightSum="9"
            >




            <Button
                android:id="@+id/share"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginLeft="5dp"
                android:layout_marginTop="3dp"
                android:layout_weight="3"
                android:background="@color/coloraqua"
                android:drawableLeft="@drawable/share"
                android:text="Share"
                android:textAllCaps="false"
                />


            <Button
                android:id="@+id/rate"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginLeft="5dp"
                android:layout_marginTop="3dp"
                android:layout_weight="3"
                android:background="@color/coloraqua"
                android:drawableLeft="@drawable/rating"
                android:shadowColor="@color/colorAccent"
                android:text="Rate"
                android:textAllCaps="false" />
            <Button
                android:id="@+id/info"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginLeft="5dp"
                android:layout_marginTop="3dp"
                android:layout_marginRight="3dp"
                android:layout_weight="3"
                android:background="@color/coloraqua"
                android:drawableLeft="@drawable/infoa"
                android:text="Info"
                android:textAllCaps="false" />


        </LinearLayout>


        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="50dp"
            android:orientation="horizontal"
            android:weightSum="9">











        </LinearLayout>

    </LinearLayout>

        <com.google.android.gms.ads.AdView
            xmlns:ads="http://schemas.android.com/apk/res-auto"
            android:id="@+id/adView"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerHorizontal="true"
            android:layout_alignParentBottom="true"
            ads:adSize="BANNER"
            ads:adUnitId="ca-app-pub-2863417604404784/6151426605">
        </com.google.android.gms.ads.AdView>




    </RelativeLayout>


</android.support.v7.widget.CardView>

查看回收站适配器的类

  <?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_margin="15dp"
    android:background="@drawable/border"

    >




    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:gravity="center"
        android:layout_gravity="center"
        android:layout_margin="5dp"
        android:background="@color/white"
        >


            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="ddddddddd"
                android:textStyle="bold"
                android:textSize="20sp"
                android:id="@+id/title"
                android:padding="10dp"
                android:textColor="@color/black"/>

    </LinearLayout>





    </RelativeLayout>

回收站适配器的视图类

   <?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.CardView
    xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_gravity="center">

    <android.support.v7.widget.RecyclerView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/recycle"
        android:layout_gravity="center"
        >

    </android.support.v7.widget.RecyclerView>

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <com.google.android.gms.ads.AdView
            xmlns:ads="http://schemas.android.com/apk/res-auto"
            android:id="@+id/adView"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerHorizontal="true"
            android:layout_alignParentBottom="true"

            ads:adSize="BANNER"
            ads:adUnitId="@string/banner">
        </com.google.android.gms.ads.AdView>




    </RelativeLayout>

网络视图布局

<?xml version="1.0" encoding="utf-8"?>

 <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"
 android:paddingLeft="@dimen/activity_horizontal_margin"
 android:paddingRight="@dimen/activity_horizontal_margin"
 android:paddingTop="@dimen/activity_vertical_margin"
 android:paddingBottom="@dimen/activity_vertical_margin"
  tools:context=".Activity.MainActivity">

 <LinearLayout
 android:layout_width="match_parent"
 android:layout_height="match_parent"
 android:layout_marginBottom="58dp">

  <WebView
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:id="@+id/webView"
    android:layout_alignParentTop="true"
    android:layout_alignParentLeft="true"
    android:layout_alignParentStart="true" />
   </LinearLayout>


   <com.google.android.gms.ads.AdView
    xmlns:ads="http://schemas.android.com/apk/res-auto"
    android:id="@+id/adView"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_centerHorizontal="true"
    android:layout_alignParentBottom="true"

    ads:adSize="BANNER"
    ads:adUnitId="@string/O3">
 </com.google.android.gms.ads.AdView>

</RelativeLayout>

一个额外的错误日志

 1. java.lang.RuntimeException: 
 2.   at android.app.ActivityThread.performLaunchActivity (ActivityThread.java:2534)
 3.   at android.app.ActivityThread.handleLaunchActivity (ActivityThread.java:2608)
 4. at android.app.ActivityThread.access$800 (ActivityThread.java:178)
 5. at android.app.ActivityThread$H.handleMessage (ActivityThread.java:1470)
 6. at android.os.Handler.dispatchMessage (Handler.java:111)
 7. at android.os.Looper.loop (Looper.java:194)
 8. at android.app.ActivityThread.main (ActivityThread.java:5637)
 9. at java.lang.reflect.Method.invoke (Native Method)
11. at java.lang.reflect.Method.invoke (Method.java:372)
12. at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run (ZygoteInit.java:959)
 13. at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:754)

 Caused by: java.lang.RuntimeException: 
  14. at android.app.ActivityManager$TaskDescription.<init> (ActivityManager.java:555)
  15.  at android.app.Activity.onApplyThemeResource (Activity.java:3741)
  16. at android.view.ContextThemeWrapper.initializeTheme (ContextThemeWrapper.java:140)
  17.  at android.view.ContextThemeWrapper.setTheme (ContextThemeWrapper.java:85)
  18. at a.b.h.a.m.setTheme(:0)
  19. at android.app.ActivityThread.performLaunchActivity (ActivityThread.java:2474) 

0 个答案:

没有答案