1

I am making an which app which have 2 android project; 1st project is library project and 2nd project is my main project. project-1 is working fine but when I am adding it in my Project-2 as library it is giving me exceptions like this Resource not found String resource ID #0x76000456

when i checked my string bundle and R.java this string is there.

I have tried clean Project restart my eclipse and my system.

my strings.xml file looks like:-

 <string name="pref_loadrecent_id">loadrecent</string>
<string name="pref_loadrecent_defvalue">false</string>

<string name="pref_confirmclose_id">confirmclose</string>
<string name="pref_confirmclose_defvalue">false</string>

and I am calling like this:-

BooleanPreferenceDefinition LOAD_RECENT = new BooleanPreferenceDefinition(pref_loadrecent_id,
        pref_loadrecent_defvalue);

BooleanPreferenceDefinition CONFIRM_CLOSE = new BooleanPreferenceDefinition(pref_confirmclose_id,
        pref_confirmclose_defvalue);

and I am doing static import of R.string like this

import static com.ankit.R.string.*;

For testing instead of calling from string id i hard code the values of pref_loadrecent_id and pref_loadrecent_defvalue then it is showing similar exception(with different ID) for pref_confirmclose_id and pref_confirmclose_defvalue.

Please help me out.

Ankit
  • 1,916
  • 2
  • 20
  • 33

5 Answers5

1

The parameter which you are passing for your answer might not converted into string ... first convert it into string then pass that string parameter for correct answer..

for example..

@Override
public void onClick(View v) {

// TODO Auto-generated method stub

    EditText edittext = (EditText) findViewById(R.id.edT);

    String str = edittext.getText().toString();

    int n = Integer.parseInt(str);

    int fact = n , i ,e;

    e = n;

    if (n==0)
    fact = 1;

    else

    for(i=0; i<n-1; i++)
        {
            fact = fact * (e - 1);
            e = e - 1;

        }


String str1 = String.valueOf(fact);       <-----//Your mistake maybe here.....

Toast.makeText(getApplicationContext(), str1, Toast.LENGTH_LONG).show();

                }
Soner Gönül
  • 97,193
  • 102
  • 206
  • 364
0

Whenever you find any Problem in Resource ID then Go To Project-->Clean

And clean your project, R.java file will be generated Again.

Bhavin
  • 6,020
  • 4
  • 24
  • 26
0

Do, fix project properties and clean the project. Close eclipse and restart it again. It will be resolved.

Programmer
  • 5,360
  • 10
  • 37
  • 61
0

Maybe I'm wrong but to me it looks as if you're importing only int not Strings with

import static com.ankit.R.string.*;

And that could be the reason for your exception Resource not found String resource ID #...

Kay Gladen
  • 1,730
  • 2
  • 14
  • 14
0

In my case, I casted the int value to string value and it was solved

String s = String.valueOf([int value]);
Ardent Coder
  • 3,777
  • 9
  • 27
  • 53
D_K
  • 152
  • 2
  • 9
  • No one is having a problem converting. Android isn't recognizing the strings –  Jun 30 '20 at 19:41