Android NDK location not configurable - android

In project settings (File -> Project Structure) 'Android NDK location' field is greyed out:
Clicking on 'Download Android NDK' briefly displays some dialog. There are several versions of NDK installed:
What is wrong with my setup?
Host: Ubuntu 18.04 LTS
Android Studio 4.1.1
Build #AI-201.8743.12.41.6953283, built on November 5, 2020
Runtime version: 1.8.0_242-release-1644-b3-6222593 amd64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
Linux 4.15.0-128-generic
GC: ParNew, ConcurrentMarkSweep
Memory: 2014M
Cores: 4
Registry: ide.new.welcome.screen.force=true, external.system.auto.import.disabled=true, debugger.watches.in.variables=false
Non-Bundled Plugins: com.intellij.ideolog, org.jetbrains.kotlin
Current Desktop: LXDE
Submitted bug report

Leave SDK Location ;) we can still select from Files> Project
Structure> Modules> NDK Version
Or, Simply Add
ndkVersion '22.0.7026061'
in build.gradle(app) like this
externalNativeBuild {
ndkBuild {
path file('src/main/jni/Android.mk')
}
}
ndkVersion '22.0.7026061' // your desire version
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
}
Extra Tips:--- you can set path variable here
Still App not Building for NDK ??
Close Android Studio.
Delete .temp folder located
C:\Users\%USERNAME%\AppData\Local\Android\Sdk (if exist)
Delete Options Folder located in
C:\Users\%USERNAME%\AppData\Roaming\Google\AndroidStudio4.1\
Delete NDK or ndk-bundle folder located in your SDK directory... in my case D:\Android\SDK\ndk
Now clean temps from SDK Manager > Optimize disk Space [don't worry it will not delete your essential files]
Now, install your desire NDK version from SDK Manager

I had this problem and by setting NDK value in local.properties file of my project, that problem gone
ndk.dir=D\:\\mySdkFolder\\sdk\\myNdkFolder
sdk.dir=D\:\\mySdkFolder\\sdk

With a project open, click Tools > SDK Manager.
Click the SDK Tools tab.
Select the NDK (Side by side) and CMake checkboxes.

Related

Build failed: SDK location not found (:app:compileDebugJavaWithJavac)

Since a recent upgrade of Android Studio, I cannot build my project anymore. The surface error is:
e: C:\Users\<user>\dev\<project>\app\build\generated\source\navigation-args\release\com\<org>\<project>\ui\home\HomeFragmentDirections.kt: (3, 8): Unresolved reference: R
If I dig further and build from the terminal with gradlew (gradlew assembleDebug --debug):
FAILURE: Build failed with an exception.
What went wrong:
Could not determine the dependencies of task ':app:compileDebugJavaWithJavac'.
SDK location not found. Define a valid SDK location with an ANDROID_HOME environment variable or by setting the sdk.dir path in your project's local properties file at '/mnt/c/Users/<user>/dev/<project>/local.properties'.
My local.properties file already contains this line:
sdk.dir=C\:\\Users\\<user>\\AppData\\Local\\Android\\Sdk
and that is where the SDK is installed.
In my build.gradle:
...
android {
compileSdkVersion 32
buildToolsVersion '32.1.0-rc1'
...
defaultConfig {
...
minSdkVersion 23
targetSdkVersion 32
...
}
settings.gradle:
include ':app'
rootProject.name = "<projectname>"
What I tried:
As per the error, I set the ANDROID_HOME environment variable to the
SDK location C:\Users\<user>\AppData\Local\Android\Sdk, and
restarting my machine to make sure the var is seen.
Clean project, rebuild project
File -> Invalidate caches
Install different versions of the SDK and SDK Tools
Reinstalling the SDK completely
Reinstalling Android Studio completely
I found innumerable posts with a problem similar to mine, and all seem to be solved by upgrading the SDK, changing compileSdkVersion/buildToolsVersion etc. in build.gradle, changing the SDK location in local.properties or the ANDROID_HOME environment variable. Or even reverting to an older SDK version. None of that works for me.
I'm out of options at this point. Any help/idea would be appreciated.
Current software:
Android Studio:
Android Studio Chipmunk | 2021.2.1
Build #AI-212.5712.43.2112.8512546, built on April 28, 2022
Runtime version: 11.0.12+7-b1504.28-7817840 amd64
VM: OpenJDK 64-Bit Server VM by Oracle Corporation
Windows 10 10.0
GC: G1 Young Generation, G1 Old Generation
Memory: 2048M
Cores: 12
Registry: external.system.auto.import.disabled=true
Non-Bundled Plugins: org.jetbrains.kotlin (212-1.6.21-release-334-AS5457.46)
Android SDK: Android API 32 (Sv2)
Build-Tools installed: 32.1.0-rc1, 32.0.0, 30.0.3
ext.kotlin_version = "1.6.21"
Operating system: Windows 10

Android Studio no longer shows build directory in project pane's project tree

Android Studio used to show my build directories as orange directories in the project tab when displaying as "Project" (as opposed to the "Android" view). Now the only way I can verify if the build succeeded is to open a file browser or a terminal. How can I unhide the build directory and display all items in my directory via the Project pane? i.e. I don't want Android Studio filtering/hiding anything. I want to see everything in the directory.
OS: Ubuntu 20.4
Android Studio:
Android Studio Arctic Fox | 2020.3.1
Build #AI-203.7717.56.2031.7583922, built on July 27, 2021
Runtime version: 11.0.10+0-b96-7249189 amd64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
Linux 5.4.0-80-generic
GC: G1 Young Generation, G1 Old Generation
Memory: 1280M
Cores: 8
Registry: external.system.auto.import.disabled=true
Non-Bundled Plugins: com.thoughtworks.gauge, org.intellij.plugins.markdown
Current Desktop: ubuntu:GNOME
Click on the settings icon on the project tab and make sure "Show Excluded Files" is checked.

Android Studio cannot find custom SDK

I've added my SDK to Android Studio, but it doesn't appear in External Libraries, and gradle fails to sync.
Steps I followed:
Created my SDK in my AOSP build tree
In AS:
SDK Manager: I added my SDK as an SDK Update Site
SDK Platforms: Installed my SDK
Project Structure: Modules: Compile Sdk Version: I selected my SDK. This modifies my compileSdkVersion in my build.gradle file.
At this point, gradle attempts to sync and failed. The log shows:
com.android.tools.idea.gradle.project.sync.idea.issues.SdkPlatformNotFoundException: Module: 'mobile' platform 'MATT:MATT SDK Add-On LOCAL_BUILD:30' not found.
(mobile is the name of my module)
Thing is, everything appears correct. I see the SDK installed exactly where I would expect it in my SDK directory. As I mentioned above, the Project Structure dialog picks it up and writes it to the gradle file. I'm invalidated my cache, restarted, re-tried everything, everything I can think of. The name of the compileSdkVersion appears to be exactly what the XML dictates it should be (and it was all loaded by AS, I didn't manually type it)
I also do not see my SDK in the External Libraries tree in the Project's View
My AS version is
Android Studio Arctic Fox | 2020.3.1 Canary 14
Build #AI-203.7717.56.2031.7260174, built on April 5, 2021
Runtime version: 11.0.9.1+0-b77-7246554 amd64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
Linux 5.8.0-44-generic
GC: G1 Young Generation, G1 Old Generation
Memory: 2048M
Cores: 28
Registry: external.system.auto.import.disabled=true
Non-Bundled Plugins: org.jetbrains.kotlin
Current Desktop: i3
Though I had a co-worker who was previously able to set this up also run into this issue. I suspect there's some subtle step we're missing.
Other settings:
android {
compileSdkVersion 'MATT:MATT SDK Add-On LOCAL_BUILD:30'
buildToolsVersion '30.0.1'
// ...
}
I've played with other installed buildToolsVersion versions to no avail.

Using compiled SDK in Android Studio

I am trying to compile android-6.0.1 from source and use the compiled SDK in Android Studio. To compile the SDK, I tried the commands:
$ lunch sdk-eng
$ make sdk
Also tried:
$ lunch sdk-eng
$ make PRODUCT-sdk-sdk showcommands
Compilation results 0 errors.
To add the SDK in Android Studio, I checked SO questions on how to change SDK path. I am facing issues after path change. The folder of my compiled SDK has key folders named android-6.0.1 such as
platforms/android-6.0.1
build-tools/android-6.0.1
Complete set of folders inside SDK is:
add-ons build-tools docs documentation.html extras platforms platform-tools RELEASE_NOTES.html samples system-images tests
The compiled SDK is for API version 23.
The following are steps I tried so far to add the compiled SDK in Android Studio (version 2.1.2)
1) change sdk path -> Gradle sync begins ->
(Remember the sdk folder does have a build tools folder)
My apps build.gradle contains
android {
compileSdkVersion 23
buildToolsVersion "23.0.0"
defaultConfig {
applicationId "com.example.sdktest"
minSdkVersion 22
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
2) build.gradle does not allow strings like 6.0.1 for platform name, so I attempted to rename relevant folders
platforms/android-6.0.1 --> platforms/android-23
build-tools/android-6.0.1 --> build-tools/23.0.0
system-images/android-6.0.1 --> system-images/android-23
Modified build-tools/23.0.0/source.properties to contain Pkg.Revision=23.0.0
I compared the build-tools folder in meld (left is the new compiled SDK; the folder hierarchy is identical, although I haven't checked all the differences yet):
[Update]
I tried to follow the Android Studio prompts to install build tools version 23.0.0 and also com.android.support:appcompat-v7:23.1.1 -> gradle sync starts again, and prints the following in the log (and then remains stuck):
build-tools/23.0.0/aapt: error while loading shared libraries: libz.so.1: cannot open shared object file: No such file or directory
I tried installing the package lib32z1 but it didn't resolve the problem. Has anyone tried fixing it on Debian jessie (64 bit) ?
I installed the following libraries to solve it:
libc6-i386
lib32stdc++6
lib32gcc1
lib32ncurses5
I found the solution at this answer: https://stackoverflow.com/a/22592888

Error:compileSdkVersion android-21 requires compiling with JDK 7 - windows

Android studio -
updated sdk with android 21 , updated java to 1.7.0 . Whenever i try to compile with android L ( 21 ) , it throws this error and gradle sync is failed.
C:\Users\me>java -version
java version "1.7.0_71"
Java(TM) SE Runtime Environment (build 1.7.0_71-b14)
Java HotSpot(TM) 64-Bit Server VM (build 24.71-b01, mixed mode)
found similar question for mac -
Android Studio needs JDK 7 for Android-L mac
You have two options, you can just switch your compiled version back to 20 if you do not want all the goodness of SDK 21. To upgrade to JDK 7 for Windows, do this:
Download the Jave 7 exe from
http://www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1880260.html
Perform a straight forward install and take note of the installation folder such as C:\Program Files\Java\jdk1.7.0_71
Then click on File > Project Structure and point the JDK location to
the location of the JDK you just installed

Categories

Resources