android - 在牛轧糖以下的操作系统版本上获得运行时异常

标签 android crash android-resources runtimeexception inflate-exception

我的应用程序在 android 7 版本以下的手机上崩溃了。 这是我申请的链接 https://play.google.com/store/apps/details?id=comdhanusharea.wixsite.benitinhere.phonebook .

我不知道为什么我会收到此崩溃报告。当我尝试在低于 Android 版本 7 的手机应用程序中安装我的应用程序时崩溃并向我展示

Unfortunately,Application is stopped

我在我的开发者帐户上收到了这份崩溃报告。

java.lang.RuntimeException: 
  at android.app.ActivityThread.performLaunchActivity (ActivityThread.java:2338)
  at android.app.ActivityThread.handleLaunchActivity (ActivityThread.java:2390)
  at android.app.ActivityThread.access$800 (ActivityThread.java:151)
  at android.app.ActivityThread$H.handleMessage (ActivityThread.java:1321)
  at android.os.Handler.dispatchMessage (Handler.java:110)
  at android.os.Looper.loop (Looper.java:193)
  at android.app.ActivityThread.main (ActivityThread.java:5292)
  at java.lang.reflect.Method.invokeNative (Native Method)
  at java.lang.reflect.Method.invoke (Method.java:515)
  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run (ZygoteInit.java:824)
  at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:640)
  at dalvik.system.NativeStart.main (Native Method)
Caused by: android.view.InflateException: 
  at android.view.LayoutInflater.createViewFromTag (LayoutInflater.java:713)
  at android.view.LayoutInflater.rInflate (LayoutInflater.java:755)
  at android.view.LayoutInflater.rInflate (LayoutInflater.java:758)
  at android.view.LayoutInflater.rInflate (LayoutInflater.java:758)
  at android.view.LayoutInflater.rInflate (LayoutInflater.java:758)
  at android.view.LayoutInflater.inflate (LayoutInflater.java:492)
  at android.view.LayoutInflater.inflate (LayoutInflater.java:397)
  at android.view.LayoutInflater.inflate (LayoutInflater.java:353)
  at android.support.v7.app.AppCompatDelegateImplV9.setContentView (AppCompatDelegateImplV9.java:287)
  at android.support.v7.app.AppCompatActivity.setContentView (AppCompatActivity.java:139)
  at comdhanusharea.wixsite.benitinhere.phonebook.A2_Login.onCreate (A2_Login.java:36)
  at android.app.Activity.performCreate (Activity.java:5264)
  at android.app.Instrumentation.callActivityOnCreate (Instrumentation.java:1088)
  at android.app.ActivityThread.performLaunchActivity (ActivityThread.java:2302)
Caused by: android.content.res.Resources$NotFoundException: 
  at android.content.res.Resources.loadDrawable (Resources.java:2124)
  at android.content.res.TypedArray.getDrawable (TypedArray.java:602)
  at android.widget.ImageView.<init> (ImageView.java:129)
  at android.support.v7.widget.AppCompatImageView.<init> (AppCompatImageView.java:72)
  at android.support.v7.widget.AppCompatImageView.<init> (AppCompatImageView.java:68)
  at android.support.v7.app.AppCompatViewInflater.createView (AppCompatViewInflater.java:106)
  at android.support.v7.app.AppCompatDelegateImplV9.createView (AppCompatDelegateImplV9.java:1024)
  at android.support.v7.app.AppCompatDelegateImplV9.onCreateView (AppCompatDelegateImplV9.java:1081)
  at android.view.LayoutInflater.createViewFromTag (LayoutInflater.java:684)

这是我的 A2_Login onCreate 函数的 Java 代码

@Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_a2__login);
        SharedPreferences preferences=getSharedPreferences("PhoneBook",MODE_PRIVATE);
        Boolean b= preferences.getBoolean("IsLogin",false);
        if(b)
        {
            startActivity(new Intent(this,A3_HomePage.class));
            finish();
        }
        if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.M){
            if (ContextCompat.checkSelfPermission(A2_Login.this, Manifest.permission.READ_CONTACTS) != PackageManager.PERMISSION_GRANTED &&
                    ContextCompat.checkSelfPermission(A2_Login.this, Manifest.permission.WRITE_CONTACTS) != PackageManager.PERMISSION_GRANTED
                   )
            {
                ActivityCompat.requestPermissions(A2_Login.this, new String[]{Manifest.permission.READ_CONTACTS}, REQUEST_PHONE_CALL);
                ActivityCompat.requestPermissions(A2_Login.this, new String[]{Manifest.permission.WRITE_CONTACTS}, REQUEST_PHONE_CALL);
            }
            if( ContextCompat.checkSelfPermission(A2_Login.this, Manifest.permission.INTERNET) != PackageManager.PERMISSION_GRANTED){
                ActivityCompat.requestPermissions(A2_Login.this, new String[]{Manifest.permission.INTERNET}, REQUEST_PHONE_CALL);
            }
        }
        else{
            if (ContextCompat.checkSelfPermission(A2_Login.this, Manifest.permission.READ_CONTACTS) != PackageManager.PERMISSION_GRANTED &&
                    ContextCompat.checkSelfPermission(A2_Login.this, Manifest.permission.WRITE_CONTACTS) != PackageManager.PERMISSION_GRANTED
                   )
            {
                ActivityCompat.requestPermissions(A2_Login.this, new String[]{Manifest.permission.READ_CONTACTS}, REQUEST_PHONE_CALL);
                ActivityCompat.requestPermissions(A2_Login.this, new String[]{Manifest.permission.WRITE_CONTACTS}, REQUEST_PHONE_CALL);
                }
            if( ContextCompat.checkSelfPermission(A2_Login.this, Manifest.permission.INTERNET) != PackageManager.PERMISSION_GRANTED){
                ActivityCompat.requestPermissions(A2_Login.this, new String[]{Manifest.permission.INTERNET}, REQUEST_PHONE_CALL);
            }
        }
        db = openOrCreateDatabase("db_contactmanager", MODE_PRIVATE, null);
        db.execSQL("Create Table If Not Exists tbl_register(" +
                "db_regiser_id Integer Primary Key AutoIncrement," +
                "db_gender nvarchar(20)," +
                "db_fname nvarchar(20)," +
                "db_lname nvarchar(20)," +
                "db_mobile nvarchar(13)," +
                "db_mail nvarchar(50)," +
                "db_passwd nvarchar(15))");
        db.execSQL("Create Table If Not Exists tbl_root1(" +
                "db_security nvarchar(50) not null," +
                "db_fname nvarchar(20)," +
                "db_lname nvarchar(20)," +
                "db_mobile nvarchar(13)," +
                "db_mail nvarchar(50)," +
                "db_passwd nvarchar(15))");
        edt_phone_mail = (EditText) findViewById(R.id.A2_edt_phone_mail);
        edit_passwd = (EditText) findViewById(R.id.A2_edt_passwd);
    }

这是我的布局文件

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@drawable/back2"
    android:orientation="vertical"
    tools:context="comdhanusharea.wixsite.benitinhere.phonebook.A2_Login">


    <TextView
        android:id="@+id/A2_r_txt"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:layout_marginBottom="20dp"
        android:layout_marginTop="30dp"
        android:layout_weight="1.5"
        android:fontFamily="cursive"
        android:gravity="center"
        android:text="Sign In"
        android:textColor="@color/md_black_1000"
        android:textSize="50dp"
        android:textStyle="bold" />

    <ScrollView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_below="@+id/A2_r_txt">

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

            <LinearLayout
                android:id="@+id/A2_r_ll1"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_below="@+id/A2_r_txt"
                android:layout_weight="1">


                <ImageView
                    android:layout_width="0dp"
                    android:layout_height="match_parent"
                    android:layout_marginLeft="5dp"
                    android:layout_marginRight="8dp"
                    android:layout_weight=".5"
                    android:backgroundTint="@color/colorPrimary"
                    android:src="@drawable/username" />


                <EditText
                    android:id="@+id/A2_edt_phone_mail"
                    android:layout_width="0dp"
                    android:layout_height="wrap_content"
                    android:layout_marginLeft="10dp"
                    android:layout_marginRight="10dp"
                    android:layout_weight="4.6"
                    android:backgroundTint="@color/colorPrimary"
                    android:ems="10"
                    android:hint="Enter Email id or Phone number"
                    android:inputType="text"
                    android:padding="20dp" />

            </LinearLayout>

            <LinearLayout
                android:id="@+id/A2_r_ll2"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_below="@+id/A2_r_ll1"
                android:layout_weight="1">


                <ImageView
                    android:layout_width="0dp"
                    android:layout_height="match_parent"
                    android:layout_marginLeft="5dp"
                    android:layout_marginRight="8dp"
                    android:layout_weight=".5"
                    android:src="@drawable/password" />


                <EditText
                    android:id="@+id/A2_edt_passwd"
                    android:layout_width="0dp"
                    android:layout_height="wrap_content"
                    android:layout_marginLeft="10dp"
                    android:layout_marginRight="10dp"
                    android:layout_weight="4.6"
                    android:ems="10"
                    android:hint="Enter Password"
                    android:inputType="textPassword"
                    android:padding="20dp" />

            </LinearLayout>

            <Button
                android:id="@+id/A2_r_btn_signup"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_below="@+id/A2_r_ll2"
                android:layout_centerHorizontal="true"
                android:layout_gravity="center"
                android:layout_marginTop="15dp"
                android:layout_weight=".8"
                android:background="@drawable/btn_background"
                android:onClick="fun_A2_btnlogin"
                android:text="Login" />

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_below="@+id/A2_r_btn_signup"
                android:layout_centerHorizontal="true"
                android:layout_gravity="center"
                android:layout_marginBottom="100dp"
                android:layout_marginTop="15dp"
                android:layout_weight="1"
                android:onClick="fun_A2_btnsignup"
                android:text="I don't have an account"
                android:textColor="@color/md_black_1000"
                android:textSize="20dp" />


        </LinearLayout>
    </ScrollView>


</RelativeLayout>

jelly bean 支持的最低 android 版本

我的问题不是 Unfortunately MyApp has stopped. How can I solve this? 的重复问题 我的问题与此不同,因为在编译我的项目时,我没有遇到任何类型的崩溃或错误。

提前致谢。

最佳答案

我认为您的图像在 drawable-v24 或其他文件夹中,将其移动到 drawable 文件夹并再次测试。

关于android - 在牛轧糖以下的操作系统版本上获得运行时异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49229989/

相关文章:

python-3.x - 如何修复 Python 3 PyAutoGUI 截图错误? (苹果系统)

android - 提供MDPI和HDPI资源的意义

android - 支持独立第三方对 Android 应用程序进行本地化;应用 APK 之外的本地化数据

ios - WebTryThreadLock 线程崩溃 0xbbadbeef

iPhone 4 在 xcode 4 上点击运行或停止后有时会崩溃

android:allowbackup ="false"不工作

android - 在 React Native 中保存和共享项目 Assets 中的图像

android - InstanceApp 无法访问 java 代码中的功能到功能模块资源

android - UnsupportedMethodException Android Studio 2.2

java - 如何在android中获取月份和日期?