I have a strange problem that suddenly appeared in android studio. I created a new cpp file, and included it in Android.mk. Then I synced the project. However, android studi
I had a similar problem. Like yourself, I have tried everything.
One thing that kind of helped me was: I changed the NDK version. I compiled, then got a compilation error (didn't matter because it was the wrong version of NDK anyway), then I reverted to the original NDK. This appeared to solve the problem, however, it got back again.
My solution was to reset Android Studio to factory settings. If you are on Linux, you can start by deleting these folders:
rm -rf ~/.android
rm -rf ~/.AndroidStudio3.4
Then you download and run your Android Studio and not import anything from anywhere.
I suspect the problem was caused by one of the plugins I've installed.
It may be a good idea to backup those two folders from time to time and reload them from there if necessary.
EDIT: It seems that my problem persisted after the above solution after adding more .cpp files. After seeing that, I searched where that popup came from. It follows that "This file is not part of project..." popup is pushed from ndk-build. (Class name: NewCppSourceNotificationProvider - StaleCppProjectNotificationPanel). What I tried, and what worked so far; I used Android Studio 3.5 Canary13 with NDK version r19c (Stable version). I hope this helps you.
fix this by update my 'com.android.tools.build:gradle'
Had the same problem with Android Studio 4.0.1 and the latest gradle at this time (6.1.1?). The problem went away after I exited Android Studio and deleted .gradle and .idea folders in the project main directory, plus deleted .cxx and build directories in the affected module directory. I'm not sure which really helped, but most probably deleting .grade and/or .idea
I have similar problem, it could be the compatibility issue of gradle version and gradle plugin version, because my solution is replacing the old configuration
// build.gradle
classpath 'com.android.tools.build:gradle:3.2.1'
...
// gradle-wrapper.properties
distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip
with the following new one by changing gradle version from 4.6
to 4.10.1
.
// build.gradle
classpath 'com.android.tools.build:gradle:3.2.1'
...
// gradle-wrapper.properties
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.1-all.zip
After that, Android studio can index and track my new cpp files in project.
Android Studio 3.5 RC 2
gradle-4.10-all
com.android.tools.build:gradle:3.2.1
Update to:
- gradle-5.5.1-all
- com.android.tools.build:gradle:3.4.2
From the project root run (note this has to be done first):
./gradlew wrapper --gradle-version 5.5.1 --distribution-type all
In root build.gradle
file:
buildscript {
//...
dependencies {
classpath("com.android.tools.build:gradle:3.4.2")
//...
}
}