Android Logcat奇怪的错误

时间:2017-12-27 16:35:10

标签: android-studio nullpointerexception android-gradle genymotion android-logcat

我是Android应用开发的新手。在Genymotion上运行我的应用程序(我尝试过多个设备)时,gradle构建没有错误,但模拟器说“不幸的是,Fictiopedia已停止。”,Logcat显示了许多我无法理解的错误。它是一个应用程序,通过随机显示实际英语单词的有意义部分及其定义来创建自己的单词。 (我删除了大部分带有单词及其定义的代码,以使其适合此问题框)

感谢您的帮助。

这里,Logcat显示的内容和我的代码:

logcat的:

12-27 11:09:05.099 1946-1946/? E/libprocessgroup: failed to make and chown /acct/uid_10059: Read-only file system
12-27 11:09:05.099 1946-1946/? W/Zygote: createProcessGroup failed, kernel missing CONFIG_CGROUP_CPUACCT?
12-27 11:09:05.099 1946-1946/? I/art: Late-enabling -Xcheck:jni
12-27 11:09:05.143 1946-1956/? I/art: Debugger is no longer active
12-27 11:09:05.360 1946-1946/? I/InstantRun: starting instant run server: is main process
12-27 11:09:05.454 1946-1946/? W/art: Before Android 4.1, method android.graphics.PorterDuffColorFilter android.support.graphics.drawable.VectorDrawableCompat.updateTintFilter(android.graphics.PorterDuffColorFilter, android.content.res.ColorStateList, android.graphics.PorterDuff$Mode) would have incorrectly overridden the package-private method in android.graphics.drawable.Drawable
12-27 11:09:05.690 1946-1946/? W/ResourceType: Failure getting entry for 0x7f060054 (t=5 e=84) (error -75)
12-27 11:09:05.691 1946-1946/? W/ResourceType: Failure getting entry for 0x7f060054 (t=5 e=84) (error -75)
12-27 11:09:05.692 1946-1946/? D/AndroidRuntime: Shutting down VM


                                                 --------- beginning of crash
12-27 11:09:05.693 1946-1946/? E/AndroidRuntime: FATAL EXCEPTION: main
                                                 Process: com.example.lauramessner.fictiopedia, PID: 1946
                                                 java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.lauramessner.fictiopedia/com.example.lauramessner.fictiopedia.MainActivity}: android.view.InflateException: Binary XML file line #0: Error inflating class ImageView
                                                     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2325)
                                                     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2387)
                                                     at android.app.ActivityThread.access$800(ActivityThread.java:151)
                                                     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1303)
                                                     at android.os.Handler.dispatchMessage(Handler.java:102)
                                                     at android.os.Looper.loop(Looper.java:135)
                                                     at android.app.ActivityThread.main(ActivityThread.java:5254)
                                                     at java.lang.reflect.Method.invoke(Native Method)
                                                     at java.lang.reflect.Method.invoke(Method.java:372)
                                                     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
                                                     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
                                                  Caused by: android.view.InflateException: Binary XML file line #0: Error inflating class ImageView
                                                     at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:763)
                                                     at android.view.LayoutInflater.rInflate(LayoutInflater.java:806)
                                                     at android.view.LayoutInflater.inflate(LayoutInflater.java:504)
                                                     at android.view.LayoutInflater.inflate(LayoutInflater.java:414)
                                                     at android.view.LayoutInflater.inflate(LayoutInflater.java:365)
                                                     at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:287)
                                                     at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:139)
                                                     at com.example.lauramessner.fictiopedia.MainActivity.onCreate(MainActivity.java:26)
                                                     at android.app.Activity.performCreate(Activity.java:5990)
                                                     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1106)
                                                     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2278)
                                                     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2387) 
                                                     at android.app.ActivityThread.access$800(ActivityThread.java:151) 
                                                     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1303) 
                                                     at android.os.Handler.dispatchMessage(Handler.java:102) 
                                                     at android.os.Looper.loop(Looper.java:135) 
                                                     at android.app.ActivityThread.main(ActivityThread.java:5254) 
                                                     at java.lang.reflect.Method.invoke(Native Method) 
                                                     at java.lang.reflect.Method.invoke(Method.java:372) 
                                                     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903) 
                                                     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698) 
                                                  Caused by: android.content.res.Resources$NotFoundException: Resource ID #0x7f060054
                                                     at android.content.res.Resources.getValue(Resources.java:1266)
                                                     at android.support.v7.widget.AppCompatDrawableManager.loadDrawableFromDelegates(AppCompatDrawableManager.java:330)
                                                     at android.support.v7.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:195)
                                                     at android.support.v7.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:188)
                                                     at android.support.v7.content.res.AppCompatResources.getDrawable(AppCompatResources.java:100)
                                                     at android.support.v7.widget.AppCompatImageHelper.loadFromAttributes(AppCompatImageHelper.java:58)
                                                     at android.support.v7.widget.AppCompatImageView.<init>(AppCompatImageView.java:78)
                                                     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:725)
                                                     at android.view.LayoutInflater.rInflate(LayoutInflater.java:806) 
                                                     at android.view.LayoutInflater.inflate(LayoutInflater.java:504) 
                                                     at android.view.LayoutInflater.inflate(LayoutInflater.java:414) 
                                                     at android.view.LayoutInflater.inflate(LayoutInflater.java:365) 
                                                     at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:287) 
                                                     at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:139) 
                                                     at com.example.lauramessner.fictiopedia.MainActivity.onCreate(MainActivity.java:26) 
                                                     at android.app.Activity.performCreate(Activity.java:5990) 
                                                     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1106) 
                                                     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2278) 
                                                     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2387) 
                                                     at android.app.ActivityThread.access$800(ActivityThread.java:151) 
                                                     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1303) 
                                                     at android.os.Handler.dispatchMessage(Handler.java:102) 
                                                     at android.os.Looper.loop(Looper.java:135) 
                                                     at android.app.ActivityThread.main(ActivityThread.java:5254) 
                                                     at java.lang.reflect.Method.invoke(Native Method) 
                                                     at java.lang.reflect.Method.invoke(Method.java:372) 
                                                     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903) 
                                                     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698) 
12-27 11:09:10.334 1946-1946/? I/Process: Sending signal. PID: 1946 SIG: 9

我的代码:

package com.example.lauramessner.fictiopedia;
import android.content.pm.ActivityInfo;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.ImageButton;
import android.widget.TextView;

public class MainActivity extends AppCompatActivity {


    public void happen(View b){

setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);         }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);


        final TextView pref = (TextView) findViewById(R.id.pref);
        final TextView root = (TextView) findViewById(R.id.root);
        final TextView suff = (TextView) findViewById(R.id.suff);
        final TextView predef = (TextView) findViewById(R.id.predef);
        final TextView rootdef = (TextView) findViewById(R.id.rootdef);
        final TextView suffdef = (TextView) findViewById(R.id.suffdef);

        final String[] prefixes =  {"", "A", "An", "Ab", "Ad", "Ambi", "Ana", "Ante", "Anti", "Apo", "Auto","Bene"};
        final String[] roots = {"", "ami", "ann", "anthrop", "aqua"};
         final String[] suffixes = {"", "agog", "agogue", "cide", "ectomy"};


        ImageButton pushMe = findViewById(R.id.pushMe);
        pushMe.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                 final int rando = (int) (Math.random());
                 suff.setText(prefixes[rando]);
                 root.setText(roots[rando]);
                 pref.setText(suffixes[rando]);



                if (pref.getText().toString().contains("")) {
                    predef.setText("");
                }
                if (pref.getText().toString().contains("A")) {
                    predef.setText("not ");
                }
                if (pref.getText().toString().contains("An")) {
                    predef.setText("without ");
                }
                if (pref.getText().toString().contains("Ab")) {
                    predef.setText("away from ");
                }
                if (pref.getText().toString().contains("Ad")) {
                    predef.setText("toward ");
                }
                if (pref.getText().toString().contains("Ambi")) {
                    predef.setText("both ");
                }
                if (pref.getText().toString().contains("Ana")) {
                    predef.setText("again ");
                }
                if (pref.getText().toString().contains("Ante")) {
                    predef.setText("before ");
                }
                if (pref.getText().toString().contains("Anti")) {
                    predef.setText("against ");
                }
                if (pref.getText().toString().contains("Apo")) {
                    predef.setText("away from ");
                }
                if (pref.getText().toString().contains("Auto")) {
                    predef.setText("self ");
                }
                if (pref.getText().toString().contains("Bene")) {
                    predef.setText("good ");
                }

                if (root.getText().toString().contains("")) {
                    rootdef.setText("");
                }
                if (root.getText().toString().contains("ami")) {
                    rootdef.setText("love");
                }
                if (root.getText().toString().contains("ann")) {
                    rootdef.setText("year");
                }
                if (root.getText().toString().contains("anthrop")) {
                    rootdef.setText("human");
                }
                if (root.getText().toString().contains("aqua")) {
                    rootdef.setText("water");
                }

                if (suff.getText().toString().contains("")) {
                    suffdef.setText("");
                }
                if (suff.getText().toString().contains("agog")) {
                    suffdef.setText("Leader ");
                }
                if (suff.getText().toString().contains("agogue")) {
                    suffdef.setText("Leader ");
                }
                if (suff.getText().toString().contains("cide")) {
                    suffdef.setText("Act of killing ");
                }
                if (suff.getText().toString().contains("ectomy")) {
                    suffdef.setText("Surgical removal of ");
                }
            }
        });
    }
}

0 个答案:

没有答案