Android Studio need to rebuild project before each run
Asked Answered
S

5

23

Recently the android studio shows Error Java cannot find Symbol or each run. i have to go to built and rebuilt the project before each run. Is there any way to fix it? i don't know if my project problem or the problem of the latest update of android studio. is anyone facing the same problem ? any way to fix it?

Statius answered 24/6, 2013 at 6:42 Comment(1)
I have this problme recently on a Android studio 3Barbarese
L
6

It's a known issue. Maybe you should try this:

Same issue here, to avoid rebuild EACH TIME, i'm going to my module project settings -> Dependencies and up or down one of my library item -> Apply -> Ok -> Make regenerating R.java.

You could also try unchecking "Use external build" in compiler settings:

File -> Settings (Ctrl+Alt+S) -> Compiler -> Uncheck "Use external build"

Lanai answered 24/6, 2013 at 6:59 Comment(2)
your solution doesn't work with Android Studio 3.2.1 (external build)Aloisius
I can't find it in Android studio 3.5.3Coble
F
19

Please check run/debug configuration.Make sure include ‘Gradle-aware Make’ enter image description here

Fondue answered 25/12, 2017 at 8:1 Comment(6)
Thank you very much! Worked great for me :)Permanence
Thanks this solution is perfect. Made my dayMatheson
This should be the accepted answer. Works on AS 3.4Frisk
How can I add it??Quitclaim
What does it do??Quitclaim
Wow, thank you so much! Why was it missing tho.Sponge
L
6

It's a known issue. Maybe you should try this:

Same issue here, to avoid rebuild EACH TIME, i'm going to my module project settings -> Dependencies and up or down one of my library item -> Apply -> Ok -> Make regenerating R.java.

You could also try unchecking "Use external build" in compiler settings:

File -> Settings (Ctrl+Alt+S) -> Compiler -> Uncheck "Use external build"

Lanai answered 24/6, 2013 at 6:59 Comment(2)
your solution doesn't work with Android Studio 3.2.1 (external build)Aloisius
I can't find it in Android studio 3.5.3Coble
R
1

in android studio version 2+, use this in all gradle config files

android{
..

compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_7
        targetCompatibility JavaVersion.VERSION_1_7
        incremental = false;
}
...

}

and if you have experimental for ndk use like this

model {
    android.compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_7
        targetCompatibility JavaVersion.VERSION_1_7
        incremental false
    }
}
Roughandtumble answered 20/6, 2016 at 8:15 Comment(0)
A
0

I know nothing about the problem in your 2013, but in mine 2016 (Android Studio 2.1.3) instant run forces Android Studio to rebuild the project from the scratch every time I press "Debug". Switching it off solve this issue

Apposition answered 13/9, 2016 at 10:24 Comment(0)
S
0

In my case, I had changed the sourceSets:

android {
    sourceSets {
        main {
            res.srcDirs =
                    [
                            'src/main/res',
                            'src/main/res/layouts',
                            'src/main/res/layouts/content',
                            'src/main/res/layouts/layout',
                            'src/main/res/layouts/fragment',
                            'src/main/res/layouts/dialog',
                            'src/main/res/layouts/appbar',
                    ]
        }
    }
}

and locate some *.xml to layouts/layout directory...

finally I got the problem, don't place file in layouts/layout directory, so I created an activity directory and cut that files to activity directory, and finally edit the gradle this way:

android {
    sourceSets {
        main {
            res.srcDirs =
                    [
                            'src/main/res',
                            'src/main/res/layouts',
                            'src/main/res/layouts/activity',
                            'src/main/res/layouts/content',
                            'src/main/res/layouts/layout',
                            'src/main/res/layouts/fragment',
                            'src/main/res/layouts/dialog',
                            'src/main/res/layouts/appbar',
                    ]
        }
    }
}
Stedfast answered 5/2, 2017 at 12:13 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.