4

I am developing a library for Android and I keep getting a strange error about a static inner class when I use it in a sample project : "cannot find symbol variable":

This is my factored code :

Outer.java (SDK project)

public class Outer {

    [...] // Attributes and methods

    public static class Inner {
        public static int x = 42; 
    }
}

MainActivity.java (Sample project)

import com.xxx.xxx.Outer;

public class MainActivity extends Activity {

    [...] // Attributes

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

        Log.d("MainActivity", "x = " + Outer.Inner.x);
    }
}

This is the log error :

.../sample/MainActivity.java:54: error: cannot find symbol Log.d("MainActivity", "x = " + Outer.Inner.x);
^

symbol: variable Inner
location: class Outer

I've another case into my SDK :

My class "ImageHelper" has a static inner class "Builder".

I use it into my SDK and it works, but when I want to use it in the sample project, I've the same error at build runtime.

Is there an error in my code ?

titichop
  • 41
  • 2
  • Strange, works here. Did you clean your build? Here is an answer with some hints and tricks... http://stackoverflow.com/questions/25706216/what-does-a-cannot-find-symbol-compilation-error-mean – ElDuderino Mar 24 '15 at 14:01
  • your code seems to be OK. show us your real code. Try to rebuild your project. – alex Mar 24 '15 at 14:12
  • Yes, i clean et rebuild again and again ^^' – titichop Mar 24 '15 at 14:17

1 Answers1

0

Did you try to compile your own cut code? It works fine when I do compilation on my own. Maybe it (provided cut) works for you too and your full program uses different class?

Based on your code

import com.xxx.xxx.Outer;

and absence line for package in the Outer code it is possible that your project has not one Outer but many and one of them has no inner static class.

Alex
  • 4,457
  • 2
  • 20
  • 59