Making MagicTextView a library causing R can not resolved to a variable

684 views Asked by At

I was trying to import MagicTextView to my project so that I could make the TextView's innerflow visible. I import it using the File->import->Existing Project into workspace and make it a Library by clicking on "Is Library" of "Android" tab of Property of the project.

I then open up my project go to Android property of Property and clicked on Add and add MagicTextView as Library and then I received R can not be resolved to a variable in my project cause below xml errors in MagicTextView.

 error: No resource identifier found for attribute 'strokeWidth' in package 'com.qwerjk.better_text'
[2013-12-09 14:49:30 - CCC] /home/asutosh/workspace/MagicTextView/res/layout /main.xml:10: error: No resource identifier found for attribute 'foreground' in package   'com.qwerjk.better_text'
[2013-12-09 14:49:30 - CCC] /home/asutosh/workspace/MagicTextView/res/layout/main.xml:10: error: No resource identifier found for attribute 'innerShadowDy' in package 'com.qwerjk.better_text'
[2013-12-09 14:49:30 - CCC] /home/asutosh/workspace/MagicTextView/res/layout/main.xml:10: error: No resource identifier found for attribute 'innerShadowColor' in package 'com.qwerjk.better_text'
[2013-12-09 14:49:30 - CCC] /home/asutosh/workspace/MagicTextView/res/layout/main.xml:10: error: No resource identifier found for attribute 'innerShadowRadius' in package 'com.qwerjk.better_text'
[2013-12-09 14:49:30 - CCC] /home/asutosh/workspace/MagicTextView/res/layout/main.xml:10: error: No resource identifier found for attribute 'outerShadowDy' in package 'com.qwerjk.better_text'
[2013-12-09 14:49:30 - CCC] /home/asutosh/workspace/MagicTextView/res/layout/main.xml:10: error: No resource identifier found for attribute 'outerShadowColor' in package 'com.qwerjk.better_text'
[2013-12-09 14:49:30 - CCC] /home/asutosh/workspace/MagicTextView/res/layout/main.xml:10: error: No resource identifier found for attribute 'outerShadowRadius' in package 'com.qwerjk.better_text'
[2013-12-09 14:49:30 - CCC] /home/asutosh/workspace/MagicTextView/res/layout/main.xml:10: error: No resource identifier found for attribute 'strokeColor' in package 'com.qwerjk.better_text'
[2013-12-09 14:49:30 - CCC] /home/asutosh/workspace/MagicTextView/res/layout/main.xml:10: error: No resource identifier found for attribute 'strokeJoinStyle' in package 'com.qwerjk.better_text'
[2013-12-09 14:49:30 - CCC] /home/asutosh/workspace/MagicTextView/res/layout/main.xml:10: error: No resource identifier found for attribute 'strokeWidth' in package 'com.qwerjk.better_text'
[2013-12-09 14:49:31 - CCC] /home/asutosh/workspace/MagicTextView/res/layout/main.xml:10: error: No resource identifier found for attribute 'foreground' in package 'com.qwerjk.better_text'
[2013-12-09 14:49:31 - CCC] /home/asutosh/workspace/MagicTextView/res/layout/main.xml:10: error: No resource identifier found for attribute 'innerShadowDy' in package 'com.qwerjk.better_text'
[2013-12-09 14:49:31 - CCC] /home/asutosh/workspace/MagicTextView/res/layout/main.xml:10: error: No resource identifier found for attribute 'innerShadowColor' in package 'com.qwerjk.better_text'
[2013-12-09 14:49:31 - CCC] /home/asutosh/workspace/MagicTextView/res/layout/main.xml:10: error: No resource identifier found for attribute 'innerShadowRadius' in package 'com.qwerjk.better_text'
[2013-12-09 14:49:31 - CCC] /home/asutosh/workspace/MagicTextView/res/layout/main.xml:10: error: No resource identifier found for attribute 'outerShadowDy' in package 'com.qwerjk.better_text'
[2013-12-09 14:49:31 - CCC] /home/asutosh/workspace/MagicTextView/res/layout/main.xml:10: error: No resource identifier found for attribute 'outerShadowColor' in package 'com.qwerjk.better_text'
[2013-12-09 14:49:31 - CCC] /home/asutosh/workspace/MagicTextView/res/layout/main.xml:10: error: No resource identifier found for attribute 'outerShadowRadius' in package 'com.qwerjk.better_text'
[2013-12-09 14:49:31 - CCC] /home/asutosh/workspace/MagicTextView/res/layout/main.xml:10: error: No resource identifier found for attribute 'strokeColor' in package 'com.qwerjk.better_text'
[2013-12-09 14:49:31 - CCC] /home/asutosh/workspace/MagicTextView/res/layout/main.xml:10: error: No resource identifier found for attribute 'strokeJoinStyle' in package 'com.qwerjk.better_text'
[2013-12-09 14:49:31 - CCC] /home/asutosh/workspace/MagicTextView/res/layout/main.xml:10: error: No resource identifier found for attribute 'strokeWidth' in package 'com.qwerjk.better_text'

However all these attributes are defined in attr of values in res.

2

There are 2 answers

10
Abhishek Shukla On

I too faced same problem.. Don't use it as library. Copy the MagicTextView.java file and all the related resources in your very project and then use it. It will do the trick.

0
Abhishek Shukla On

Like this :

popUpScoreTextView = new MagicTextView(myContext);
    // popUpScoreTextView.addInnerShadow(0, -1, 0, 0xFFffffff);
    popUpScoreTextView.addOuterShadow(9, 0, 2, Color.BLACK);
    popUpScoreTextView.setStroke(2, Color.parseColor("#612d00"));
    popUpScoreTextView.setTypeface(MyTypfaces.get(myContext, "GROBOLD"));
    popUpScoreTextView.setTextSize(40);
    popUpScoreTextView.setTextColor(Color.parseColor("#ffb400"));
    RelativeLayout.LayoutParams popupScoreTextViewParams = new RelativeLayout.LayoutParams(
            LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    popupScoreTextViewParams.addRule(RelativeLayout.CENTER_IN_PARENT);
    popUpScoreTextView.setLayoutParams(popupScoreTextViewParams);
    // ((GamePlayActivity)myContext).addContentView(popUpScoreTextView,
    // popupScoreTextViewParams);
    popUpScoreTextView.setVisibility(TextView.INVISIBLE);

    if (popUpScoreTextView.getParent() != null)
        ((ViewGroup) popUpScoreTextView.getParent())
                .removeView(popUpScoreTextView);

    // popUpScoreTextView.setTypeface(Typeface.SANS_SERIF,
    // Typeface.BOLD_ITALIC);
    ((RelativeLayout) this.getParent()).addView(popUpScoreTextView);