Unable to locate adb.exe, can't open adb too - react-native

I made optimization of disk size (simply delete all trash) and when i try to use expo cli - i get typical issue : "Can't open emulator , make it manually from D:/AndroidSdk/..." . I try to resolve this problem with reset SDK Manager, but it doesn't help, so i launch emulator from Android Studio (before i do it from expo host ). And i get another error, that doesn't make my fix-way more clearly : "Unable to locate adb.exe" . After that i try to reassign some enviroment variables (Like Adb in PATH), that might not have correct way, well - it doesn't work too. So in this time i reset all Android Studio and related garbage (excluding enviroment variables) . So what i get in last attempt :
Expo :
Classical variable :
Path :
By the way try to run with expo client:install:android - no result (evidently);
And after this manipulation expo (above) doesn't recognize my real phone Imao - casual error "Check Metro logs"

It seems you are missing a few environment variables.
ANDROID_AVD_HOME
This should point to a folder named avd (e.g C:%USERNAME%.android\avd)
JAVA_HOME
While JAVA_HOME can point to any java run time environment, I found that having it point the one Android Studio provides to be a pain saver. I once ran into a problem where my builds were failing and I had no idea why. After a lot of sturggle, I found that the java I had independently installed somehow conflicted with what react native was trying to do. Using the java provided by Android Studio made this problem never occur again (e.g. C:\Program Files\Android\Android Studio\jre)
ANDROID_HOME & ANDROID_SDK_ROOT
For me ANDROID_HOME and ANDROID_SDK_ROOT point to the same folder
In PATH you need the point to the platform-tools and tools of the sdk folder. For an example, if the Android sdk folder was stored at E:\Android\sdk you would add:
E:\Android\sdk\tools
E:\Android\sdk\platform-tools
Also keep in mind that Windows being Windows, uses '\' and not '/'. I'm not sure if they sanitize this in environment variables, but I try not to risk it
If this doesnt resolve your problems, try running react-native doctor, as this may print a more verbose reasons react-native is failing (I'm just comparing my environment variables to what you show in your question)

Related

Problem loading ANDROID_SDK_ROOT to launch AVD emulator on AndroidStudio

I recently wanted to try React Native to code applications. This requires many installations which worked fine, except for AndroidStudio.
I use a Windows 10 PC, with hybrid hard drive.
I had to download AndroidStudio files on the second drive (D:) because my first hard drive is very small and already full. This type of installation never caused any problems with me (I installed dozens of softwares on D: like this).
I followed diligently React Native Getting Started Guide to install everything on windows for android devices. I ran into several problems :
Firstly, the Android Studio installer never asked me if I wanted a Custom or regular installation. I think this is not an issue as I can still install what's needed afterwards via the SDK manager.
Once I installed everything in the SDK manager and in the AVD manager as asked in the tutorial, I placed the path for ANDROID_HOME in environment variables menu (I also tried in system variables, in both, but this doesn't seem to change anything), and the Path for platform-tools in the Path variable.
One particularity is that I have the following files :
D:/AndoidStudio containing the app (that would have installed itself in C:/Program Files otherwise)
D:/AndroidStudio_sdk containing the downloaded sdk (Android Studio makes it mandatory to install these files in a different folder)
Then, when I clicked on the green triangle from AVD manager to start the emulator, nothing happened, and I received a Notification in Android Studio's IDE :
Emulator: PANIC: Cannot find AVD system path. Please define ANDROID_SDK_ROOT
I tried to add this environment variable pointing to the same location as ANDROID_HOME (D:/AndroidStudio_sdk). This hasn't solved the problems and made a new error pop up instead of the first one :
Emulator: PANIC: Broken AVD system path. Check your ANDROID_SDK_ROOT value [D:\AndroidStudio_sdk]!
I looked up on React Native website and it appears that ANDROID_SDK_ROOT environment variable is in this case used when there's no SDK files inside the ANDROID_HOME location.
What I can't understand is why I can't find the sdk location ? I tried in SDK manager, but it just gives me D:\20_AS_sdk, which is just the value of ANDROID_HOME.
Another particularity is that I can't find the sdk folder inside D:\20_AS_sdk (or any default route evoqued on different tutorials).
I really don't understand these issues and I've been blocked on this since 2 days, the only useful comments I found on other threads were just :
- set your ANDROID_HOME variable to the proper place, which I already did
- install the SDKs and emulator needed, but I did it too without issues
I tried to remove everything from AndroidStudio and the linked paths and reinstall everything, many many many times unsuccesfully...
Thank you for your support :)

Intellij will not start with the error: "Error: Could not find or load main class com.intellij.idea.Main"

I killed an "idea" process in terminal after Intellij had frozen. The idea.sh script was missing after I killed the process (I ran a find command and checked other directories & the trash but no luck). I have since copied my friends "idea.sh" script into its former location. Now when I run ./idea.sh I get:
"Error: Could not find or load main class com.intellij.idea.Main".
I have tried searching for this class as well but got no results. Google has no info and I'm not very informed on Intellij.
Any hints on what I might need to do to avoid reinstalling Intellij?
I had the same issue after updating the android studio. I was not able to launch it from click on Android Studio icon and after running ./studio.sh it was giving me the same error
I do this to solve my issue
I downloaded the studio and install it in the new directory.
After installation success, copy all the files & folders and paste and replace it into the old location where the studio was installed.
And it is working fine.

Unable to run app on device using android studio

I have been trying to use android studio and every time I deploy an app on a device, it gives me an error saying:
Installation failed since the device possibly has stale dexed jars that don't match the current version (dexopt error).
In order to proceed, you have to uninstall the existing application.
I have tried using Build->Clean Project and yet it seems to do no good.
I have also tried deleting the file from /data/local/tmp on device (as my phone is a rooted one), but, all in vain.
If anyone knows a way out, please, please help.
Uninstall the application from the device.
Check the storage space.
Once Restart the mobile and try to install it

"classes.dex not found. Try to rebuild project" in Android Studio

I'm unable to build Android project using Android Studio 0.1.3. Everything worked fine until latest SVN update of the project. This is strange, because no settings were changed (SDK, dependencies etc.). I also didn't update any tools. I keep getting the error:
Android Packager: [trunk] File /home/matis/.AndroidStudioPreview/system/compile-server/apilot_f8e91252/android/intermediate_artifacts/trunk/classes.dex not found. Try to rebuild project
There are no errors in source code, I can build and deploy it on a device without problems using Eclipse. I'm using SDK rev. 17 with SDK Tools rev. 22.
I tried to build source from earlier SVN revision, but the same thing happens.
Has anyone else experienced similar problem? How can I solve it?
Update
After some investigation I found out that dx tool doesn't get called at all (I modified its script so it would create some file if run), but aapt is called properly.

How can I fix a missing mscorelib.dll error that occurs when trying to run a Mono for Android app?

In MonoDevelop when compiling and running an app developed for Android against the simulator, the app compiles then crashes immediately in the simulator with the following application output...
E/mono ( 225): The assembly mscorlib.dll was not found or could not be loaded.
E/mono ( 225): It should have been installed in the `/home/jon/Development/xamarin/mono/BUILD/armeabi/install/lib/mono/2.0/mscorlib.dll' directory.
Keep in mind that I'm not Jon so I don't even know where it's getting the /home/jon path configuration. Though I have found that path in other similar but ultimately unrelated searches on the internet so I imagine it's a path on some other devs machine.
mscorlib.dll is indeed on my machine. located here...
/Developer/MonoTouch/usr/lib/mono/2.1/
and here...
/Developer/MonoAndroid/usr/lib/mono/2.1/
I've tried targetting various Android SDK environments (currently 2.3 and the simulator is currently running under the 2.3 SDK environment as well).
I'm on Mac OSx 10.7.2. Using the latest version of MonoDevelop, Mono and Mono for Android. I've also got the latest MonoTouch installed as well and iPhone apps compile fine if that's worth anything.
The closest thing I can find to a hint at the issue is here...
http://phonicuk.com/Forums/ViewThread.aspx?tid=401
I've tried reinstalling Mono and Mono for Android but admittedly have not tried uninstalling in entirely before a reinstall. I've searched within files for the /home/jon path thinking that it must be a configuration somewhere but haven't been able to find it anywhere.
I found this... Mono return error: mono mscorlib.dll was not found
Along with a few other things that were sort of in the same vein, but ultimately nothing that seems to be a fix.
Any ideas?
Update: From the suggestions in jonp's answer below it indeed seems like the Mono.Android.DebugRuntime package is not installed. So far I've tried a couple of MonoAndroid reinstalls and have tried removing MonoAndroid entirely beforehand. I'm trying to figure out if there is a way to add the package manually, but I'm so new to this.
Another update: Not sure why I didn't try this already, but I created a HelloWorld MonoAndroid app and it works fine. The compilation took a while longer too for that one and I could see if was setting up the required packages, so there has to be an issue with the specific solution.
When you install a Debug build of your app on the device, three .apk files are installed:
Mono.Android.DebugRuntime, which contains libmonosgen-2.0.so, mscorlib.dll, etc.
Mono.Android.Plaltform.ApiLevel_N, which contains Mono.Android.dll for API level N.
Your application.
My guess is that the Mono.Android.DebugRuntime package has not been installed. To check this, run:
adb shell pm list packages | grep Mono.Android
I'm going to guess that it's missing. :-)
Next, why is it missing? When you Run the app within MonoDevelop, all required packages are checked for and installed. It seems rather odd that it wouldn't be. Is your device low on disk space?
adb shell df /data
How are you launching the emulator? If you're launching within MonoDevelop, there should be enough free space to install all of the above packages. However, if you launch it yourself, the default /data size is 64MB, which isn't enough to support a Debug build environment. Please launch the simulator from MonoDevelop and re-Run your app, or launch the emulator so that it has enough free space:
emulator -partition-size 512 -avd YOUR_AVD_NAME