78

I have updated Android Studio to 4.1 in Macbook but not able to run app after updating. It is giving following error

Execution failed for task ':app:stripDebugDebugSymbols'.
NDK at ~/Library/Android/sdk/ndk-bundle did not have a source.properties file

and don't forget to mention latest ndk version if you seleted android{

 ndkVersion: '25.1.8937393'

}

Krishna Meena
  • 5,693
  • 5
  • 32
  • 44

35 Answers35

92

After specifying ndk version in build.gradle file it is working

android {
        ndkVersion '21.3.6528147'
    }

And inside local.properties remove the following since it's deprecated and also conflicts with path:

ndk.dir=~/Library/Android/sdk/ndk-bundle
Ahmed Ashour
  • 5,179
  • 10
  • 35
  • 56
Krishna Meena
  • 5,693
  • 5
  • 32
  • 44
  • 9
    Happened to me as well, but this solution didn't work for me. – Abdul Mateen Oct 16 '20 at 22:16
  • 1
    On Android Studio 4.1 – Abdul Mateen Oct 16 '20 at 22:16
  • 3
    Please check your NDK version which you have installed. – Krishna Meena Oct 16 '20 at 22:21
  • 1
    The `ndk.dir` in the `local.properties` will work fine for the Gradle Plugin version < 4.1.0 and the Gradle version < 6.5. But, Gradle will complain once you start to use the latest versions. https://developer.android.com/studio/releases/gradle-plugin – ecle Oct 17 '20 at 14:31
  • 6
    I had to put full path to ndk including version: "ndk.dir=[...]\\Android\\Sdk\\ndk\\21.3.6528147" – promanowicz Oct 19 '20 at 10:30
  • I see the NDK dirs (22.0.7026061 and 21.1.6352462) **have** `source.properties`. None of the remedies in this answer worked for me. I am using Android Studio 4.1.1 on Mac OS 11.1. – Dark Matter Dec 30 '20 at 02:22
  • I have tried it and it worked. But when I upload the apk to play store it shows a warning ... "This App Bundle contains native code, and you've not uploaded debug symbols. We recommend you upload a symbol file to make your crashes and ANRs easier to analyze and debug". How does this affect my app & how to solve it? – mad_lad Jan 07 '21 at 05:31
  • @KrishnaMeena this worked for me, but when i upload apk to google play console it shows like this - https://i.imgur.com/BOQzU3Q.png. How to solve this. – mad_lad Jan 16 '21 at 14:32
  • @mad_lad Follow this https://stackoverflow.com/questions/62568757/playstore-error-app-bundle-contains-native-code-and-youve-not-uploaded-debug – Krishna Meena Jan 16 '21 at 14:44
  • updating build.gradle fix my issue – Mudaser Ali Oct 27 '21 at 16:40
  • It worked for me. I was using NDK version (23.1.7779620). – Ahmad Iqbal Bhatti Jan 05 '22 at 12:24
68

I had the same issue and solve it : Go to SDK location find NDK folder and check the folders if one of them is empty or corrupted delete it and let the android studio use the latest version you have.

mmdreza baqalpour
  • 1,106
  • 9
  • 18
  • 2
    That was the working one. By doing this IDE is auto selecting the last one. It was looking into an empty folder so ofc it couldn't find any source.properties file. Thx ! – Skyle Nov 09 '20 at 09:30
  • 3
    This usually occurs when you cancel the build while it's installing a NDK, you're left with a corrupt/empty folder. – ZephDavies Jun 29 '21 at 15:15
  • Yes this worked for me, the ndk-bundle directory was empty so I removed it and voila, everything worked! – LockieR Mar 25 '22 at 00:20
  • Thanks, for me I had the following structure: sdk -> ndk -> 21.1.6352462 -> .installer and sdk -> ndk -> 21.1.6352462 -> 24.0.8215888 -> build, ... So I used corrupted `21.1.6352462`, change to `24.0.8215888` worked for me – Amin Benarieb Jul 07 '22 at 05:30
  • This should be voted as the correct answer – bgcodes Feb 23 '23 at 10:50
36

I had this error in Flutter.

my solution:

copy file C:\Users\username\AppData\Local\Android\Sdk\ndk\22.1.7171670\source.properties

to

C:\Users\username\AppData\Local\Android\Sdk\ndk-bundle

Ready!

Yoel
  • 7,555
  • 6
  • 27
  • 59
Tavo
  • 361
  • 3
  • 2
  • There is ndk-bundle folder. However your answer helped as I copied the source.properties from 22.1.7171670 to the folder next to it 21.1.6352462 since it was mentioned in the error. Then everything worked – West Aug 02 '21 at 11:39
  • This is really a strange solution, but I will like to register my thank you - it works perfectly for me! – Jackson Ng Sep 25 '21 at 09:52
  • This too worked to me, I copied the source.properties to their parent folder, and the build was successful. – Maske Jan 05 '23 at 01:28
28

File -> Project Structure -> SDK Location -> "Android NDK Location"
And click "Download" Android NDK. The problem will be solved after downloaded. enter image description here

Yoel
  • 7,555
  • 6
  • 27
  • 59
Lai Lee
  • 1,054
  • 14
  • 17
  • 3
    somehow it can't click download. must manually add on local.properties. – Indra As Lesmana Jan 10 '21 at 23:22
  • I downloaded it for a first time. Right away I checked the path was not there and the "download" link was now disabled. But the NDK was indeed installed here (Windows): C:\Users\myuser\AppData\Local\Android\Sdk\ndk\22.0.7026061. I just needed to add this path in the file named local.properties (which is in the root of your android project, i.e: path_to_your_project/android/), backslashes escaped, just as the path for sdk.dir – Luis Martin Jan 26 '21 at 21:46
  • What if that donload button doesnt show up – Quinn Jul 13 '21 at 20:08
  • 1
    I downloaded ndk version that GitHub repo needs and the problem was solved. thank you. – saber tabatabaee yazdi Oct 04 '21 at 08:59
27

For Android studio 4.1.1+ (gradle-plugin: 4.1.1 or above) use ndkVersion

No ndk.dir at local.properties. If there is, remove it

build.gradle (module)

android {
  defaultConfig {
     // ...
     ndkVersion = "21.1.6352462"
  }
}

Note: The specified version must exist at $SDK/ndk folder.

Mahdi-Malv
  • 16,677
  • 10
  • 70
  • 117
12

In my case I don't have ndk dir in the local.properties file and also didn't add ndk version in the build.gradle. I just simply deleted the ndk-bundle folder in the android sdk folder. and it worked.

Mr. ZeroOne
  • 904
  • 6
  • 20
11

For me, this issue occurred after I upgraded to Android Studio 4.1. To fix this, I had to explicitly pass the path of my NDK directory in my project's local.properties file. It can be done by adding this line in local.properties.

ndk.dir={Path to Android NDK directory}
Abdul Mateen
  • 1,418
  • 1
  • 14
  • 32
7

add ndkversionndk.dir=C:\Users\Hasif\AppData\Local\Android\Sdk\ndk\22.1.7171670

ndk.dir=C:\\Users\\Hasif\\AppData\\Local\\Android\\Sdk\\ndk\\22.1.7171670

enter image description here

lava
  • 6,020
  • 2
  • 31
  • 28
7

I am not sure about other cases but in my case, i facing the same issue

NDK at D:\Android\sdk\ndk-bundle did not have a source.properties file

And by deleting ndk-bundle folder and then rebuilding the project solved my issue Hope anyone else gets this helpful

Zahid Iqbal
  • 394
  • 6
  • 12
6

This is random error from AS, which is encountered by few developers.

Most likely, you don't have NDK linked in your Android Studio.

I would suggest,

In your Android Studio, Go to File -> Project Structure -> SDK Location -> Under "Android NDK Location", click on "Download" Android NDK

Wait for download and re-build the project. Cheers.

mpals
  • 251
  • 1
  • 6
  • after download ndk you need to add ndk location link to local.properties file like this: ndk.dir=/Users/apple/Library/Android/sdk/ndk-bundle – Mohammed Alomair Nov 16 '20 at 13:08
  • Brillant! Had this problem after updating to Android Studio 4.1 + Gradle to 6.5. Once you clicked the download button and downloaded the NDK, don't forget to click the "Apply button" to update properly your project. Then click OK. – toto_tata Nov 19 '20 at 10:56
  • 2
    In my case, right after installed the NDK (23.1.7779620), I had to add this line `ndk.dir=/home/myuser/Android/Sdk/ndk/23.1.7779620` to my `local.properties` – joseluisq Mar 16 '22 at 22:37
6
  1. download NDK in setting, fix that issue.
  2. If you cant click Download. manually add this path to your local.properties file

ndk.dir=/Users/yourusername/Library/Android/sdk/ndk/21.3.6528147

21.3.6528147 --> version your NDK folder

enter image description here

5

Go to project structure then

Go to project structure then

Download the the NDK and rebuild the app.

This solution works for me. enter image description here

5

I was also facing the same problem from a few weeks and I had tried my best but didn't work. Then I downloaded NDK using android studio.

Screenshot of Android Studio

After downloading the NDK also not resolved my problem. Then I visited the SDK folder and found NDK and NDK-bundle. As I know the two folders have the same properties.

I had copied the source.properties file from the NDK \ 23.1.7779620 and pasted it into the NDK-Bundle folder.

Screenshot of source.properties file

It is working perfectly.

You should also try...

4

Android studio 4.1.1 can not set Android NDK Location on Project Structure, you need edit local.properties file and add

ndk.dir=/Users/yourname/Library/Android/sdk/ndk/21.3.6528147

on build.gradle file ndk version is:21.3.6528147

ext.versions = [
        'minSdk': 19,
        'targetSdk': 30,
        'compileSdk': 30,
        'kotlin': '1.4.10',
        'buildTools': '30.0.2',
        'ndk': '21.3.6528147'
    ]
oHuflying
  • 89
  • 6
4

Make sure you have downloaded and installed NDK bundle under Sdk directory. If not open SDK Manager. Install it by checking NDK(Side by side)

Go to Settings -> Appearance & Behavior -> System settings -> Android SDK

Restart the IDE and try it again. If further any problem, pls add this code in build.gradle file

android {
    ........

    defaultConfig {
        .........

        ndkVersion '22.1.7171670' // Your downloaded NDK version
    }
}

Note: Keep your local.properties file like bellow:

sdk.dir=C:\\Users\\User\\AppData\\Local\\Android\\sdk # My installed SDK location
flutter.buildMode=debug
flutter.versionName=1.0.0
flutter.versionCode=1
Subarata Talukder
  • 5,407
  • 2
  • 34
  • 50
3
ndk.dir=c\:\\Users\\DanielWaiguru\\AppData\\Local\\Android\\Sdk\\ndk\\22.1.7171670

has been deprecated and the AGP should set the default ndk version but in case it doesn't, specify a specific version of ndk in your build.gradle as follows

android {
    ndkVersion <version> 
}

for example

ndkVersion "22.1.7171670"
3

Just remove or rename ndk-bundel in Android SDK folder

Debdutta Panda
  • 168
  • 1
  • 6
  • 7
1

Things to be checked if you are facing this error:

  • Check whether Ndk location is specified or not in local.properties file.

If not, go to the NDK location inside your sdk folder,if there are multiple ndk versions delete previous versions if you don't need. Go inside the latest version folder and check whether source.properties file is present or not. Copy the folder path and specify the path in the local.properties file.

For me it is

ndk.dir=C:\Users\admin\AppData\Local\Android\Sdk\ndk\22.0.6917172

  • In app level build.gradle file specify the version number if it is incorrect

For me it is

android {

ndkVersion '22.0.6917172'

}

Important note:

The value for ndk.dir should no longer be set in your app's local.properties file, and support for this ndk.dir setting will be removed in a future version. The Android Gradle Plugin sets the NDK version by default, but if you need a specific version of the NDK, you can set android.ndkVersion in build.gradle.

You can visit this official page for more details

Dharaneshvar
  • 1,348
  • 1
  • 6
  • 12
1

I was facing the same issue and solved it Go to the Sdk path and then go inside the ndk folder and then cut - paste the folder with the version name somewhere else and then clean and rebuild.

Pranay Das
  • 69
  • 1
  • 4
1

I am using Android Studio 4.1.1 on MacOS 11.1. None of the above solutions worked for me. What worked for me was not a reconfiguration of gradle files but a simple reconfiguration of the NDK package.

cd ~/Library/Android/sdk/ndk/22.0.7026061
cp android-ndk-r22/source.properties .
Dark Matter
  • 90
  • 1
  • 7
1

The root cause for this is: for a specific buildToolsVersion, might come with a default ndk version, but this version of ndk might not located under the ndk.dir, so a simple fix would be

android {
    ndkVersion <an existing version of ndk>
}
kyokose
  • 81
  • 1
  • 9
  • you helped me a lot. I accidentally downloaded half NDK and that was causing problem. just go to /Users/username/Library/Android/sdk and delete NDK bundle folder . ;) – Hamza Muazzam Mar 29 '22 at 09:14
1
> Task :app:stripDebugDebugSymbols FAILED react native

> NDK at C:\Users\{username}\AppData\Local\Android\Sdk\ndk\21.4.7075529 did not have a source.properties file

if you are using the react native change ndk version in build.gradle

i was changed ndkVersion = "21.4.7075529" to ndkVersion = "22.1.7171670"

Nagaraj sk
  • 71
  • 8
1

Go to build.gradle file paste ndkVersion "23.1.7779620" in the android section

android { compileSdkVersion 30 ndkVersion "23.1.7779620" }

  • Welcome to SO! I don't really see how this answer adds anything to the many existing answers. Please only post additional answers if you have contents that add value somehow. – buddemat Nov 19 '21 at 08:05
  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Nov 19 '21 at 12:36
1

Just go to:

  1. File settings
  2. Search for the Android SDK
  3. In the SDK tools, locate ndk and tick "show package details."
  4. Download the ndk error version displaying on your console.
  5. Make sure you've cmake sdk also installed
Kwesi Welbred
  • 69
  • 1
  • 5
0

Me too! When I upgrade AS4.0.1---->4.1.1

And project‘s build.gradle

classpath 'com.android.tools.build:gradle:4.1.1'

gradle-wrapper.properties
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-all.zip

I got this problem,And solution is very simple:

I copy the file to ndk-bundle directory

DONE

AlexChu
  • 31
  • 4
0

Downloan Ndk https://developer.android.com/ndk/downloads And place in /Users/yourname/Library/Android/sdk/ndk/21.3.6528147

Crimiss
  • 1
  • 1
0

Try downgrading your gradle version to 3.4.2, by adding the following line to your Project's build.grade file,

classpath 'com.android.tools.build:gradle:3.4.2'

Ashwin Balani
  • 745
  • 7
  • 19
0

1.First of all make sure you have installed ndk on the android studio sdk manager 2. add the following lines in the local.properties file

ndk.dir = C:\\Users\\MACOWIGO\\AppData\\Local\\Android\\Sdk\\ndk\\22.1.7171670

  1. then on the build.gradle file add the following line

    buildscript { ext { buildToolsVersion = "29.0.3" minSdkVersion = 21 compileSdkVersion = 29 targetSdkVersion = 29 ndkVersion = "22.1.7171670" }

nake sure the ndk version provided on the build.gradle file is the same as the one provided/written in local.properties file

Joseph Owigo
  • 430
  • 3
  • 10
0
  1. Go to local.properties(SDK Locations)

  2. Add to NDK Source path

    ndk.dir=c\:\\Users\\SankA\\AppData\\Local\\Android\\Sdk\\ndk\\22.1.7171670

Look Like this Image - Myexample image

0

Removing following line from local.properties worked for me as mentioned in accepted answer it is deprecated.

ndk.dir=~/Library/Android/sdk/ndk-bundle
Waqas Ahmed
  • 1,321
  • 1
  • 14
  • 23
0

For Flutter projects:

Run the command flutter clean in your android studio terminal.

Then add the ndk version in the defaultConfig in the file at this location: android > app > build.gradle, just like shown below:

android{
  defaultConfig {
    ndkVersion = "22.1.7171670"
  }
}
Victor Eronmosele
  • 7,040
  • 2
  • 10
  • 33
0

First of all do you really use NDk?

1.If yes you can try above accepted answer and let android studio download latest ndk for you

2.If no then go to NDK folder location /Users/yourname/Library/Android/sdk/ndk/ Delete all folder that start with "ndk" like ndk , ndk-bundle . Rebuild project

  • Because the OP accepted the answer, doesn't that mean that only option1 in your answer is true – Vega Jun 19 '21 at 15:52
  • Android studio let you download the latest ndk and that is vry much correct answer and i have tried that too.But my point is if you application uses NDK then only update the NDK otherwise just remove the NDK folders as mentioned in 2nd point. Just randomly downloading latest ndk does not make sense if you really don't use it. – Akashi Singh Jun 20 '21 at 08:39
  • Downvoting because removing the NDK should not be a recommended solution as it might affect those projects which require the usage of NDK. – Abdul Mateen Jul 10 '21 at 23:36
0

In my case running several Flutter builds, it seems I had an older NDK version installed that I no longer needed. Removing that via SDK Manager fixed the issue

> NDK at /Users/gene/tools/android-sdk-macosx/ndk/21.1.6352462 did not have a source.properties file

Trying the answers here to update the SDK, I removed the offending NDK version, with plan to refresh the update. However, after then trying to run the app without bringing back that older NDK, all apps then built successfully

Gene Bo
  • 11,284
  • 8
  • 90
  • 137
0

In my case upgrade gradle as follows at gradle-wrapper.properties

distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-all.zip
9Dragons
  • 137
  • 1
  • 4
0

My case is funny.

I downloaded ndkVersion '24.0.8215888' one minute before, and use it.

Then OK.

Here is in

/Users/xx/Library/Android/sdk/ndk/

111

And in app/build.gradle


android {
    ndkVersion '24.0.8215888'
}

And in gradle/local.properties

ndk.dir=/Users/xx/Library/Android/sdk/ndk/24.0.8215888

I tried NDK 21.1.6352462 a lot,

Not working.

black_pearl
  • 2,549
  • 1
  • 23
  • 36