Java – Build error when using static inner classes

Build error when using static inner classes… here is a solution to the problem.

Build error when using static inner classes

I’m working on a library for Android, and when I use it in my sample project, I keep getting strange errors about static inner classes: “Symbolic variable not found”:

Here is my decomposition code : (SDK project).

public class Outer {

[...] // Attributes and methods

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

MainActivity .java (sample project).


public class MainActivity extends Activity {

[...] // Attributes

    protected void onCreate(Bundle savedInstanceState) {

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

This is a log error:

…/sample/ error: cannot find symbol
Log.d(“MainActivity”, “x = ” + Outer.Inner.x);

symbol: variable Inner
location: class Outer

I have another case in my SDK:

My class “

ImageHelper” has a static inner class “Builder”.

I use it in

my SDK and it works, but when I want to use it in the sample project, I get the same error when I build run.

Is there an error in my code?


Did you try to compile your own cut code? It works fine when I compile it myself. Maybe it (providing clips) also works for you and your complete program uses a different class?

Based on your code


And the package line is missing in the Outer code, your project may not have one Outer, but many, one of which has no internal static class.

Related Problems and Solutions