missing resource id android.content.res.Resources$NotFoundException: String resource ID #0xb

-1

My app crashes when it moves to the next activity with an error android.content.res.Resources$NotFoundException: String resource ID #0xb. i'm new to this but would love if you can help

Logcat

2020-04-21 19:29:39.538 11528-11528/com.twlapps.lumicliosurveys E/lumicliosurvey: Invalid ID 0x0000000b. 2020-04-21 19:29:39.562 11528-11528/com.twlapps.lumicliosurveys E/AndroidRuntime: FATAL EXCEPTION: main Process: com.twlapps.lumicliosurveys, PID: 11528 java.lang.RuntimeException: Unable to start activity ComponentInfo{com.twlapps.lumicliosurveys/com.twlapps.lumicliosurveys.HomeActivity}: android.content.res.Resources$NotFoundException: String resource ID #0xb at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3344) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3488) at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:83) at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135) at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2049) at android.os.Handler.dispatchMessage(Handler.java:106) at android.os.Looper.loop(Looper.java:216) at android.app.ActivityThread.main(ActivityThread.java:7506) at java.lang.reflect.Method.invoke(Native Method) at com.android.

Activity

        profilecard.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (haveinternet()) {
                String profile = "yes";

                Intent profilesurveys = new Intent(HomeActivity.this, SurveysActivity.class);
                profilesurveys.putExtra("profile",profile);
                startActivity(profilesurveys);
                finish();
            } else if (!haveinternet()) {
                Toast.makeText(HomeActivity.this,"No internet Connection", Toast.LENGTH_LONG).show();
            }
        }
    });

    Calendar cal = Calendar.getInstance();
    if (Calendar.HOUR_OF_DAY >= 4 && Calendar.HOUR < 12 ){
        Toast.makeText(HomeActivity.this,String.valueOf(Calendar.HOUR_OF_DAY), Toast.LENGTH_LONG).show();
        gettime.setText("Good Morning, How was your night?");
    }else  if (Calendar.HOUR_OF_DAY >= 23 && Calendar.HOUR_OF_DAY < 4 ) {
        gettime.setText("Good Night, Have a nice sleep!");
    }else if (Calendar.HOUR_OF_DAY >= 18 && Calendar.HOUR_OF_DAY < 23 ) {
        gettime.setText("Good Evening, How was your day?");
    }else if (Calendar.HOUR_OF_DAY >= 12 && Calendar.HOUR_OF_DAY < 18 ) {
        gettime.setText("Good Afternoon!");
    }


    if (haveinternet()) {
        String uid = FirebaseAuth.getInstance().getCurrentUser().getUid();

        DocumentReference documentReference = firebaseFirestore.collection("USERS").document(uid);
        documentReference.addSnapshotListener(this, new EventListener<DocumentSnapshot>() {
            @Override
            public void onEvent(@Nullable DocumentSnapshot documentSnapshot, @Nullable FirebaseFirestoreException e) {
                if (documentSnapshot.exists()) {
                    String profilechek = documentSnapshot.getString("profile");
                    if (profilechek.equals("false")){
                        profileimgcheck.setVisibility(View.INVISIBLE);
                    }else if (profilechek.equals("true")){
                        profileimgcheck.setVisibility(View.VISIBLE);
                    }
                    String othercheck = documentSnapshot.getString("others");
                    if (othercheck.equals("false")){
                        othersimgcheck.setVisibility(View.INVISIBLE);
                    }else if (othercheck.equals("true")){
                        othersimgcheck.setVisibility(View.VISIBLE);
                    }
                    String followceck = documentSnapshot.getString("followtwitter");
                    if (followceck.equals("false")){
                        followcheck.setVisibility(View.INVISIBLE);
                    }else if (followceck.equals("true")){
                        followcheck.setVisibility(View.VISIBLE);
                    }

                    getYourName.setText(documentSnapshot.getString("fullname"));
                    getYourMoney.setText(String.valueOf(documentSnapshot.getString("Amount")));

                }else {
                    Toast.makeText(HomeActivity.this,"An error occurred... Try again or contact support", Toast.LENGTH_LONG).show();
                }
            }
        });

Please what can i do?

java
android
android-studio
asked on Stack Overflow Apr 21, 2020 by tolu ijiola

2 Answers

0

I don't see the entire activity but based on the logs and code you posted, the problem may be with

String uid = FirebaseAuth.getInstance().getCurrentUser().getUid();

The getUid() may be giving you an integer and you are assigning it to a String value.

answered on Stack Overflow Apr 21, 2020 by Bharath
-1

Looks like you haven't registered your Activity in the AndroidManifesto file.

answered on Stack Overflow Apr 21, 2020 by Karan Dhillon

User contributions licensed under CC BY-SA 3.0