Java – unable to start active resource $notfoundexception

I have published and run an application on Google play for several months

Today, I received an error from a user whose resource did not find an exception I thought I might have forgotten some paintings I get the object ID from the error (I get the ID 0x7f030003 from the error) and look it up in r.java to determine which object is missing

To my surprise, I found IDI from the main activities, so I'm sure I haven't forgotten this!

My application starts with main, from which all other activities / fragments are called When I went back, I just finished the open activity, and then returned to main So my code didn't explicitly call main, so I lost the reason for this I can't reproduce it, only the user's report

Did I encounter some errors when looking for resources? What might happen? The successor is the error I received through the console

java.lang.RuntimeException: Unable to start activity
> ComponentInfo{com.myapp/com.myapp.MainActivity}:
> android.content.res.Resources$NotFoundException: Resource ID
> #0x7f030003 at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
> at
> android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
> at android.app.ActivityThread.access$2300(ActivityThread.java:125) at
> android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
> at android.os.Handler.dispatchMessage(Handler.java:99) at
> android.os.Looper.loop(Looper.java:123) at
> android.app.ActivityThread.main(ActivityThread.java:4627) at
> java.lang.reflect.Method.invokeNative(Native Method) at
> java.lang.reflect.Method.invoke(Method.java:521) at
> com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
> at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618) at
> dalvik.system.NativeStart.main(Native Method) Caused by:
> android.content.res.Resources$NotFoundException: Resource ID
> #0x7f030003 at android.content.res.Resources.getValue(Resources.java:892) at
> android.content.res.Resources.loadXmlResourceParser(Resources.java:1869)
> at android.content.res.Resources.getLayout(Resources.java:731) at
> android.view.LayoutInflater.inflate(LayoutInflater.java:318) at
> android.view.LayoutInflater.inflate(LayoutInflater.java:276) at
> com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:198)
> at android.app.Activity.setContentView(Activity.java:1647) at
> com.myapp.MainActivity.onCreate(MainActivity.java:48) at
> android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
> at
> android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
> ... 11 more

This is my main oncreate()

Basically I have a layout that I use as a splash screen The timer triggers another thread, so when I update the status bar in the startup screen, I can load basic things Once completed, the splash disappears and the main menu is visible If the operating system destroys myapp, my boolean variable "inicializado" is empty, and then I will reload my things That's why I use it to show or not show startup

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

        splashProgress = (ProgressBar) findViewById(R.id.mainSplash_pb_progressBar);
        splashDescProgress = (TextView) findViewById(R.id.mainSplash_tv_descProgreso);

        PACKAGE_NAME = MyApp.getContext().getPackageName();
        media_btnClick = MediaPlayer.create(this,R.raw.btn_click);

        if (savedInstanceState == null) {
            TextView mi_textView = (TextView) findViewById(R.id.main_tv_Version);
            PackageInfo mi_packageInfo = null;
            try {
                mi_packageInfo = getPackageManager().getPackageInfo(getPackageName(),0);
                mi_textView.setText("v" + mi_packageInfo.versionName);
                PACKAGE_CODE = mi_packageInfo.versionCode;
            } catch (NameNotFoundException e) {
                // TODO Auto-generated catch block
            }
            savedInstanceStateNull = true;

        } else {
            savedInstanceStateNull = false;
        }
        if (!MyApp.Inicializado) {
            cargarDatosSplash();

            Timer timer = new Timer();
            timer.schedule(new LanzarInicio(),10);
        } else {
            LinearLayout layoutSplash = (LinearLayout) findViewById(R.id.main_splash);
            LinearLayout layoutMain = (LinearLayout) findViewById(R.id.main_menu);
            layoutSplash.setVisibility(View.GONE);
            layoutMain.setVisibility(View.VISIBLE);
        }
    }

class LanzarInicio extends TimerTask {
    public void run() {
        MainActivity.this.runOnUiThread(new Runnable() {
            public void run() {
                new cargarObjetosTask().execute();
            }
        });

    }
}

Solution

If your activity is locked for rotation, add it to the list:

<activity 
    android:name=".MyActivity"
    android:screenOrientation="landscape" (or "portrait")
    android:configChanges="orientation"
/>

The same solution as the answer to this question

I encountered your problem in another strange situation, setcontentview (r.layout. Activity_main) in the same place;

My app is locked in landscape orientation Oncreate was first called everything was fine; The second time (it happens after pressing the button to close the screen), the device reads the direction status and seems to look for resources I don't have in portrait mode (because I don't need it) I came to this conclusion because the other solution is to add relevant layouts to the "layout" (I only use the "layout land" directory) resource directory

This may be a problem with specific (or old) equipment

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>