I moved my Android SDK (and NDK) when my hard drive failed.
In my working project, I updated local.properties to reflect these changes in the variables ndk.dir and sdk.dir, yet when I run ./gradlew clean --info on the command line from within my project directory, gradle gives me a failure at the following command:
<old_ndk_path>/ndk-build NDK_PROJECT_PATH=null APP_BUILD_SCRIPT=<oldprojdir>/app/src/main/jni/Android.mk APP_ABI=armeabi NDK_ALL_ABIS=armeabi NDK_DEBUG=1 APP_PLATFORM=android-23 NDK_OUT=<oldprojdir>/app/build/intermediates/ndkBuild/debug/obj NDK_LIBS_OUT=<oldprojdir>/app/build/intermediates/ndkBuild/debug/lib clean
It's no wonder that the task fails, since no executable exists at that path now, but how can I get gradle to make use of the new NDK path? And how can I make it use the new project directory?
Delete the <projdir>/.gradle directory and try again.
Related
I am writing a Gradle task around Robolectric in Android Studio. How can I delete the jars that it downloads at runtime? I need a clean slate to test my task.
I tried running clean but that didn't cause the jar to be redownloaded on next run.
Is there a command I can run? Or where can I find the directory for downloaded jars?
I could not find a designated clean command, but I found a workaround:
Run test with debug flag -d; can be set either in Preferences>Compiler>Command-line Options, or run from terminal with ./gradlew :app:testDebugUnitTest -d --tests com.package.YourTestClass.testMethod > gradle_log.txt 2>&1
In the logs, search for this: Dependency cache location:
The destination directory be specified on that line. Then you can just remove it rm -r /var/folders/directoryname
I am using native code in the android project seems the last 1.5 years. but today suddenly android studio shows below error.
Build command failed. Error while executing process
D:\Android\sdk\ndk-bundle\ndk-build.cmd with arguments
{NDK_PROJECT_PATH=null
APP_BUILD_SCRIPT=D:\Android_Project\CLONE\xyz\app\src\abc\jni\Android.mk
APP_ABI=arm64-v8a NDK_ALL_ABIS=arm64-v8a NDK_DEBUG=1
APP_PLATFORM=android-16
NDK_OUT=D:/Android_Project/CLONE/Separate_Apps/xyz/app/build/intermediates/ndkBuild/abc/debug/obj
NDK_LIBS_OUT=D:\Android_Project\CLONE\Separate_Apps\xyz\app\build\intermediates\ndkBuild\abc\debug\lib
APP_CFLAGS+=-DDEBUG APP_SHORT_COMMANDS=false
LOCAL_SHORT_COMMANDS=false -B -n}
'"D:\Android\sdk\ndk-bundle\build\..\prebuilt\windows-x86_64\bin\make.exe"'
is not recognized as an internal or external command, operable program
or batch file.
I have tried too many solutions but it doesn't work.
After too much research on this issue finally, I got a solution.
Step: 1
Update build:gradle version
USE
classpath 'com.android.tools.build:gradle:3.6.1'
INSTEAD OF
classpath 'com.android.tools.build:gradle:3.4.2'
Step: 2
Update Android NDK Location in project Structure
USE
D:\Android\sdk\ndk\21.0.6113669
INSTEAD OF
D:\Android\sdk\ndk-bundle
Note: Install and configure the NDK and CMake
Step: 3
finally, sync project.
deleting this part from build.gradle file works for me:
externalNativeBuild {
cmake {
path 'tools/CMakeLists.txt'
}
}
I am trying to use gitlab/fastlane to build my project.
When i execute the scripts in the default project they work correctly, but when the runner checks out the project the build fails with the message "Task 'assembleRelease' not found in root project 'projectname'".
When i open the CI project location in Android Studio I have to execute "sync project with gradle files" before build is available.
After I have done this i can execute ./gradlew assembleRelease (and the fastlane script also works correctly)
The console output shows that several files/directories are removed when the repository is checked out:
Removing .gradle/
Removing .idea/
Removing app/app.iml
Removing app/build/
Removing build/
Removing local.properties
Removing project.iml
I can't seem to find what exactly Android Studio does when I select "Sync Project with Gradle Files" and how i reproduce that with my build script.
I had the same problem. The reason was that the ANDROID_HOME environment variable was not set and the local.properties file did not have an sdk.path set.
You could set it via Jenkinsfile into the local.properties file:
sh 'echo "sdk.dir=/<your_path_to_Android_SDK>" > ./local.properties'
in my case:
sh 'echo "sdk.dir=/home/jenkins/Android/Sdk" > ./local.properties'
Instead of writing it into the Jenkinsfile you could also create a custom fastlane lane which calls the the above mentioned shell command before you execute ./gradlew assembleRelease
In an attempt to compile external jars, I have to use the terminal and do a clean. However, when I go into the root directory of my project and execute
gradlew clean
I get the following message:
-bash: gradlew: command not found
Here's a screenshot of my application folder's home directory.
Let me know if you need anything else, I'm not sure why this is happening.
gradlew is not in your global path. To execute the 'clean' task (or any task for that matter) using the gradle wrapper (gradlew) in your project directory in your terminal, specify the current directory with the './':
./gradlew clean
You need to give it the permission by running this one first:
chmod 777 gradlew
gradlew is not in your global path. To execute the 'rebuild' task (or any task for that matter) using the gradle wrapper (gradlew) in your project directory in your terminal, specify the current directory with the './':
./gradlew rebuild
I Want to build apk using commandline, I am using ant server by using it I am building apk with commandline but when I give this command ant debug it shows error BUILD FAILED Unable to locate tools.jar and then it gives error source resource doesnt exist
This might be because your JAVA_HOME is not set to your C:\Program Files\Java\jdk folder.
instead it might be set to C:\Program Files\Java\jre so it's not getting tools.jar.
just check out this.
You can do this in this way:
C:\>set JAVA_HOME=C:\Program Files\Java\jdk
C:\>ant debug
You need tools.jar file from your jdk/lib/ folder.