Updated Android_HOME variable Ionic Issue - android

There is an issue with the path. Android Studio SDK is present in my D drive. When I execute the build command I get the following error
"Error: Could not find gradle wrapper within Android SDK. Might need to update your Android SDK.
Looked here: C:\Users\Max\AppData\Local\Android\sdk\tools\templates\gradle\wrapper"
Actual SDK location is in
"D:\Users\Max\AppData\Local\Android\sdk\tools\templates\gradle\wrapper". What should I change in Ionic app such that it looks for SDK in D drive?
Here is the Log
C:\Users\Max\Desktop\Gre\demo\demoApp>ionic build android
Running command: "C:\Program Files\nodejs\node.exe" C:\Users\Max\Desktop\Gre\demo\demoApp\hooks\after_prepare\010_add_platform_class.js C:\Users\Max\Desktop\Gre\demo\demoApp
add to body class: platform-android
ANDROID_HOME=C:\Users\Max\AppData\Local\Android\sdk
JAVA_HOME=C:\Program Files\java\jdk1.8.0_121
Subproject Path: CordovaLib
Where:
Script 'C:\Users\Max\Desktop\Gre\demo\demoApp\platforms\android\CordovaLib\cordova.gradle' line: 64
What went wrong:
A problem occurred evaluating root project 'android'.
No installed build tools found. Install the Android build tools version 19.1.0 or higher.
Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
Home to update the ANDROID_HOME variable?

Unzip -> copy and paste "tools" >only "templates" folder to your project folder (/Libraries/Android/sdk/tools/)
Example: C:\Users\yourUsers\AppData\Local\Android\sdk\tools
Link http://tools.android.com/recent/androidsdktoolsrevision2530feb2017

Get just the command line tools here : https://developer.android.com/studio/index.html#downloads
Next unzip, copy/paste 'templates' folder in '.../Android/sdk/tools/'

Related

How to debug "Build failed with an exception / SDK location not found" in Android?

I'm new in React-Native. I tried several solution in some forums but didn't help. Bellow the errors .
Microsoft Windows [Version 10.0.17134.407]
(c) 2018 Microsoft Corporation. All rights reserved.
C:\xampp\htdocs\Hands-on React-Native\TripPlane>react-native run-android
Starting JS server...
Building and installing the app on the device (cd android && gradlew.bat installDebug)...
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring project ':app'.
> SDK location not found. Define location with sdk.dir in the local.properties file or with an ANDROID_HOME environment variable.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 19s
Could not install the app on the device, read the error above for details.
Make sure you have an Android emulator running or a device connected and have
set up your Android development environment:
https://facebook.github.io/react-native/docs/getting-started.html
You need to setup ReactNative properly.
I have consider that android studio is already installed and emulator or android device is already attached
Follow below steps!
1] Install JDK from official site
2] Install NodeJs from official site
3] Install Python 2 form official site
4] Install ReactNative CLI , open CMD [ right click and run as administrator ]
Type C:\WINDOWS\system32>node -v // to get node version
Type C:\WINDOWS\system32>npm install -g react-native-cli // to install RN CLI
5] Create workspace of your RN projects
- D:\ReactNative>react-native init projectname //it will generate project inside mentioned path.
6] setup environment variable
set up new variable under user variable (if not exist) JAVA_HOME with the value
C:\Program Files\Java\jdk-10.0.2 (your JDK path)
set up new variable under user variable (if not exist) Path with the value
C:\Users\Admin\AppData\Local\Android\sdk\platform-tools //your sdk platform tools path
7] run your project using following command inside CMD
D:\ReactNative>react-native run android

react-native can't find android sdk

I have gone through every similar question on here but can't find a solution. I am testing out react-native on my xubuntu 18.04 and I'm stuck on the last step of launching the app on my phone. I have installed android-sdk and it is located in /usr/lib/android-sdk,
I also see my device attached when I do adb devices
I have added the below inside the .bashrc file and have done $ source ~/.bashrc and restarted the terminal and tried running the app again
export ANDROID_HOME=/usr/lib/android-sdk
export PATH=$ANDROID_HOME/tools:$PATH
export PATH=$ANDROID_HOME/platform-tools:$PATH
export PATH=$ANDROID_HOME/build-tools/24.0.0:$PATH
I keep getting:
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring project ':app'.
> SDK location not found. Define location with sdk.dir in the local.properties file or with an ANDROID_HOME environment variable.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --
debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 2s
Could not install the app on the device, read the error above for details.
Make sure you have an Android emulator running or a device connected and
have
set up your Android development environment:
https://facebook.github.io/react-native/docs/getting-started.html
I also tried the local file approach with local.properties file and adding sdk..what am I doing wrong here?
Please check the version of the sdk installed and the version of the sdk in the gradle
It should be the same.
It worked for me when giving the same versions.

How to Fix Build Failed on React-Native run-android?

So I'm getting this error
~/projects/personal-projects/react/myapp ⌚ 18:12:24
$ react-native run-android --variant=release
Scanning folders for symlinks in /Users/user/projects/personal-projects/react/myapp/node_modules (22ms)
JS server already running.
Building and installing the app on the device (cd android && ./gradlew installRelease)...
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring project ':app'.
> SDK location not found. Define location with sdk.dir in the local.properties file or with an ANDROID_HOME environment variable.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 14.706 secs
Could not install the app on the device, read the error above for details.
Make sure you have an Android emulator running or a device connected and have
set up your Android development environment:
https://facebook.github.io/react-native/docs/getting-started.html
I already have my android sdk installed and I also have java installed.
this is what is in my .bach_profile
export ANDROID_HOME=$HOME/Library/Android/sdk
export PATH=$PATH:$ANDROID_HOME/tools
export PATH=$PATH:$ANDROID_HOME/platform-tools
export JAVA_HOME=$Home/Library/Java/JavaVirtualMachines/jdk1.8.0_101.jdk/Contents/Home
I've tried adding a local.properties file and added sdk.dir pointing to my Android/sdk folder. But still this error persists. How do I fix this?
Please make file local.properties in folder android then add the following line on file
sdk.dir=/Users/apple/Library/Android/sdk(Please add your sdk path here)
You need to add ANDROID_HOME, JAVA_HOME variables in environmental variables and
tools and platform-tools in path of system to run android apk.
Setting ANDROID_HOME variable in environmental variables.
Setting JAVA_HOME variable in environmental variables.
So the solution to my problem was:
1) add my ANDROID_HOME and JAVA_HOME paths in my .bash_profile
Solution by #rana_sadam
2) Create local.properties and add sdk.dir=<PATH TO ANDROID SDK> inside the android folder.
Solution by #nisarg Thakkar

Ionic: Failed to build android

Having huge issues trying to build to android with Ionic. I tried initially the normal ionic build android, it failed with
[Error: ANDROID_HOME is not set and "android" command not in your PATH. You must fulfill at least one of these conditions.]
I did some hunting around stack overflow and ionic forums, and installed Java and Android Studio as a 'solution', it began to install lots of .jar files, and this happened:
Download https://repo1.maven.org/maven2/commons-logging/commons-logging/1.1.1/commons-logging-1.1.1.jar
Download https://repo1.maven.org/maven2/commons-codec/commons-codec/1.4/commons-codec-1.4.jar
Download https://repo1.maven.org/maven2/com/android/tools/external/lombok/lombok-ast/0.2.3/lombok-ast-0.2.3.jar
Download https://repo1.maven.org/maven2/org/abego/treelayout/org.abego.treelayout.core/1.0.1/org.abego.treelayout.core-1.0.1.jar
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring root project 'android'.
> failed to find target with hash string 'android-23' in: /Users/.../Library/Android/sdk
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 51.558 secs
Error: /users/nick/documents/.../.../platforms/android/gradlew: Command failed with exit code 1 Error output:
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring root project 'android'.
> failed to find target with hash string 'android-23' in: /Users/.../Library/Android/sdk
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
Please install Android target: "android-23".
Hint: Open the SDK manager by running: /Users/.../Library/Android/sdk/tools/android
You will require:
1. "SDK Platform" for android-23
2. "Android SDK Platform-tools (latest)
3. "Android SDK Build-tools" (latest)
Any advice? Maybe I need to un-install Android Studio or something? I'm very bad at this, as you likely can tell. But this is hugely holding back the project I'm working on, so will be amazing if someone could help!
Base from Installing the Android Development Environment
Configure the ANDROID_HOME environment variable based on the location of the Android SDK. Additionally, consider adding ANDROID_HOME/tools, and ANDROID_HOME/platform-tools to your PATH.
For Mac :
export ANDROID_HOME=/<installation location>/android-sdk-macosx
export PATH=${PATH}:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools
For windows :
set ANDROID_HOME=C:\<installation location>\android-sdk-windows
set PATH=%PATH%;%ANDROID_HOME%\tools;%ANDROID_HOME%\platform-tools
For linux :
export ANDROID_HOME=/<installation location>/android-sdk-linux
export PATH=${PATH}:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools

Unable to build Android using ionic

I am trying to setup Ionic framework for developing android apps on my mac but I am having some problems in building android apps.
I have followed following procedure for installing ionic :
Run: "sudo npm install -g cordova"
Run: "sudo npm install -g ionic"
Run: “android” then install the following packages
Tools: Andoird SDK Tools, Android SDK Platform-tools, Android SDK Build-tools
Android 4.4.2 (API 19)
Extras: Android Support Library
My .bash file is like this :
export JAVA_HOME=$(/usr/libexec/java_home)
export PATH=${JAVA_HOME}/bin:$PATH
export PATH=${PATH}:~/Library/Android/sdk/tools:~/Library/Android/sdk/platform-tools
This is the error I am getting while building android app :
You have been opted out of telemetry. To change this, run: cordova telemetry on.
Running command: /Users/coderahul/sampleIonicApp/hooks/after_prepare/010_add_platform_class.js /Users/coderahul/sampleIonicApp
add to body class: platform-android
ANDROID_HOME=/Users/coderahul/Library/Android/sdk
JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_91.jdk/Contents/Home
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring root project 'android'.
> failed to find target with hash string 'android-23' in: /Users/coderahul/Library/Android/sdk
* Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 2.299 secs
Error: /Users/coderahul/sampleIonicApp/platforms/android/gradlew: Command failed with exit code 1 Error output:
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring root project 'android'.
> failed to find target with hash string 'android-23' in: /Users/coderahul/Library/Android/sdk
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
Please install Android target: "android-23".
Hint: Open the SDK manager by running: /Users/coderahul/Library/Android/sdk/tools/android
You will require:
1. "SDK Platform" for android-23
2. "Android SDK Platform-tools (latest)
3. "Android SDK Build-tools" (latest)
This happened to me just type this in your terminal "/Users/coderahul/Library/Android/sdk/tools/android" and proceed with the steps to download the sdk for android-23.
This happens because your device is using the higher version of OS than the sdk version

Categories

Resources