Error prebuild react-native, build.gradle - android

When you first start the application, this error appears. I don't understand what it can be connected with.
FAILURE: Build failed with an exception.
* Where:
Build file 'C:\xxxx\android\app\build.gradle' line: 1
* What went wrong:
A problem occurred evaluating project ':app'.
> Failed to apply plugin [id 'com.android.application']
> Malformed \uxxxx encoding.

Check the order of execution. I think your computer environment is Windows.
You recommend installing Node and Python2 via Chocolatey, a
popular package manager for Windows.
choco install -y nodejs.install python2 jdk8
If you have already installed Node on your system, make sure it is Node 8.3 or newer. If you already have a JDK on your system, make sure it is version 8 or newer.
Download and install Android Studio. Choose a "Custom" setup when
prompted to select an installation type. Make sure the boxes next to
all of the following are checked:
Android SDK
Android SDK Platform
Performance (Intel ® HAXM) (See here for AMD)
Android Virtual Device
Then, click "Next" to install all of these components.
Android Studio installs the latest Android SDK by default.
Building a React Native app with native code, however, requires the
Android 9 (Pie) SDK in particular. Additional Android SDKs can be
installed through the SDK Manager in Android Studio.
The SDK is installed, by default, at the following location:
c:\Users\YOUR_USERNAME\AppData\Local\Android\Sdk
Add platform-tools to Path
Open the System pane under System and Security in the Windows Control Panel, then click on Change settings.... Open the Advanced tab and click on Environment Variables.... Select the Path variable, then click Edit. Click New and add the path to platform-tools to the list.
The default location for this folder is:
c:\Users\YOUR_USERNAME\AppData\Local\Android\Sdk\platform-tools
React Native has a built-in command line interface, which you can
use to generate a new project. You can access it without installing
anything globally using npx, which ships with Node.js.
npx react-native init AwesomeProject
Run npx react-native run-android inside your React Native project
folder:
cd AwesomeProject
npx react-native run-android
If everything is set up correctly, you should see your new app running in your Android emulator shortly.

Go to your React-native Project -> Android
Create a file local.properties
Open the file
paste your Android SDK path like below
in Windows sdk.dir = C:\\Users\\USERNAME\\AppData\\Local\\Android\\sdk
in macOS sdk.dir = /Users/USERNAME/Library/Android/sdk
in linux sdk.dir = /home/USERNAME/Android/Sdk
Replace USERNAME with your user name
Now, Run the react-native run-android in your terminal.

Related

Cant get react native project to run on android

I've been at this for a whole day.
I created a new project using npx react-native init Project. But If I try to run it on android I get this:
FAILURE: Build failed with an exception.
* What went wrong:
Incompatible magic value 0 in class file java/util/logging/ErrorManager
I've went through the docs many times. When I run npx react-native doctor, I get this:
Android
✓ JDK
✖ Android Studio - Required for building and installing your app on Android
✖ Android SDK - Required for building and installing your app on Android
- Versions found: N/A
- Version supported: 29.0.3
✓ ANDROID_HOME
So there were a few things that were causing this issue.
✖ Android Studio - Required for building and installing your app on Android
It seems that npx react-native doctor looks for /opt/android-studio, after placing my android studio in /opt/, it was able to detect it.
✖ Android SDK - Required for building and installing your app on
Android
Versions found: N/A
Version supported: 29.0.3
From what I understood, react native uses sdkmanager script to look for sdk which comes with command line tools when you install android studio. In my case, when I ran the script it was giving me errors. The reason for that was that I hadn't created JAVA_HOME environment variable. So, after creating the environment variable and adding it to PATH, the sdkmanager script ran successfully and so did the react native project.
TL;DR
You need to have your android studio folder in opt and it must be named android-studio.
Install android sdk command line tools(latest) and add it to your PATH like this export PATH=$PATH:$ANDROID_HOME/cmdline-tools/latest/bin
Also create JAVA_HOME and add it to PATH.
It's look you don't have installed Android Studio in your system.
Try to install from official site https://developer.android.com/studio#downloads
Or use snap https://snapcraft.io/install/android-studio/manjaro
sudo snap install android-studio --classic

Could not find gradle wrapper within Android SDK

i am new in Ionic. I added android platform in my ionic application and tried to run the application in real android device but i am getting following error in my command prompt i am using windows 10 machine on my end.
Error: Could not find gradle wrapper within Android SDK. Might need to update your Android SDK.
Looked here: C:\Users\CURRENT_USER\AppData\Local\Android\sdk\tools\templates\gradle\wrapper
following are my environment variables:
ANDROID_HOME=C:\Users\CURRENT_USER\AppData\Local\Android\sdk
JAVA_HOME=C:\Program Files (x86)\java\jdk1.8.0_121
Please suggest
I think you need to update android sdk,
First you update your android sdk atleast API LEVEL 19 & tools & extra options
as follow
& make sure to add sdk url in environment variable
New Android Studio has moved gradle wrapper to C:\Program Files\Android\Android Studio\plugins\android\lib\templates\gradle\wrapper. I copied the templates\ folder to sdk\, then passed the compilation. However the command "Ionic emulate android" still failed with "Error: cmd: Command failed with exit code 1". I don't know how to go further :(

Install the Android build tools version 19.1.0

I run ionic run android and it starts to download lots of things except gradle that i downloaded it and set the path myself, now i have 2 question:
1: Should ionic framework always download lots of things with every new project?
and
2: How i resolve the below error , i set ANDROID_PATH variable to point Android-SDK where packages exist
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.
The answer is yes (through Gradle) and you have to set ANDROID_HOME and then add to PATH based on this.
On the Mac I had much the same problem. I was lacking the Android SDK. I don't know if that was your problem. I'll assume you don't have the SDK but you can pick up from your problem place in this list.
Download and install Android SDK for you platform. I'm on Mac so will present instructions from that perspective.
Go to Configuration on login splash screen or Preferences through File or Apple menu.
Go to Appearance and Behaviour > System Settings > Android SDK
Observe the Android SDK Location. Mine is /Users/me/Library/Android/sdk
Open ~/.profile
Add export ANDROID_HOME=/Users/me/Library/Android/sdk
Add export PATH=$PATH:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools
Save and source ~/.profile
You could have the additional problem of not having Gradle installed. Try:
Download the binary
Extract to /usr/local or wherever you can write (eg. ~/lib where I install such things locally) if you don't have admin rights
sym link the version of gradle - cd /usr/local;ln -s gradle-3.5 gradle
Add /usr/local/gradle to your $PATH like above and source ~/.profile again.
I reread the question and realised I had added too much detail in my answer. I believe the $ANDROID_HOME and path line is what you are missing.
You may also need to open Android Studio and do whatever configuration it requires. And setup a SDK Platform also in that configuration window discussed above.
I hope that helps.

phonegap remote build command "android" failed

I installed latest version of phonegap with npm, which shows version 4, and latest android sdk.
After creating simple myApp "hello world" project to test, I added android platform and can do local build and run the app with phonegap developer app on my phone.
But... if I do a remote phonegap build then the error log from build.phonegap.com for this app shows
'Error: The command "android" failed. Make sure you have the latest Android SDK installed, and the "android" command (inside the tools/ folder) is added to your path.'
I have JAVA_HOME and ANT_HOME configured and ant and the android sdk tools and platform-tools are in my path.
I can execute android from cmd shell to bring up SDK Manager.
This is all on Windows 7 64 bit.
I'm probably missing something simple, but driving me nuts that I can't do a remote build.
It appears that there was a temporary problem with the phonegap build service, which is now working again.
Ah well...

Can't add android platform to phonegap project

I'm trying to add the android platform to my phonegap project. I've added already the iOS platform which worked without any problems. When trying to add android via command
phonegap local run android
I'm always getting this error:
[error] The command `android` failed. Make sure you have the latest Android SDK installed, and the `android` command (inside the tools/ folder) added to your path.
I have already downloaded the latest Android SDK and I set a PATH to the tools and platform-tools folder as well.
export PATH=${PATH}:/Documents/android/sdk/platform-tools:/Documents/android/sdk/tools
I also updated my bash_profile file properly with
source ~/.bash_profile
It turned out that the path to the Android SDK have to be absolute path. After changing my path to something like
export PATH=${PATH}:/Users/your-username/Documents/android/sdk/platform-tools:/Users/your-username/Documents/android/sdk/tools
I could now successfully add the android platform to my project.

Categories

Resources