Ubuntu AndroidStudio flutter: JAVA_HOME is not set - bash

I'm having a problem running my flutter application in android studio.
It gives me the following message
Launching lib/main.dart on sdk gphone x86 in debug mode...
Running Gradle task 'assembleDebug'...
ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation.
Exception: Gradle task assembleDebug failed with exit code 1
Here is echo $JAVA_HOME and I have added the bin to my PATH
/usr/lib/jvm/openjdk-14.0.2_linux-x64_bin/jdk-14.0.2
I can run flutter from terminal via flutter run after upgrading gradle from gradle-5.6.2-all.zip to gradle-6.3-all.zip
I think the problem lies in android/gradlew in the following script
# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD="$JAVA_HOME/jre/sh/java"
else
JAVACMD="$JAVA_HOME/bin/java"
fi
if [ ! -x "$JAVACMD" ] ; then
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
else
JAVACMD="java"
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
I tried copying it and running it and it runs with no problems with #!/usr/bin/env bash which is the shebang in gradlew
I tried reinstalling android studio, but it didn't work. My flutter doctor --verbose is a mess. At first it couldn't find android studio- said it is not installed. so I ran flutter config --android-studio-dir="/snap/bin" but now I get this output even though I have the plugins installed
:~$ flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 1.22.4, on Linux, locale en_US.UTF-8)
[!] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
✗ Android license status unknown.
Run `flutter doctor --android-licenses` to accept the SDK licenses.
See https://flutter.dev/docs/get-started/install/linux#android-setup for more details.
[!] Android Studio
✗ Flutter plugin not installed; this adds Flutter specific functionality.
✗ Dart plugin not installed; this adds Dart specific functionality.
✗ android-studio-dir = /snap/bin
✗ Unable to find bundled Java version.
[!] Connected device
! No devices available
! Doctor found issues in 3 categories.
:~$ flutter doctor --android-licenses
Exception in thread "main" java.lang.NoClassDefFoundError: javax/xml/bind/annotation/XmlSchema
at com.android.repository.api.SchemaModule$SchemaModuleVersion.<init>(SchemaModule.java:156)
at com.android.repository.api.SchemaModule.<init>(SchemaModule.java:75)
at com.android.sdklib.repository.AndroidSdkHandler.<clinit>(AndroidSdkHandler.java:81)
at com.android.sdklib.tool.sdkmanager.SdkManagerCli.main(SdkManagerCli.java:73)
at com.android.sdklib.tool.sdkmanager.SdkManagerCli.main(SdkManagerCli.java:48)
Caused by: java.lang.ClassNotFoundException: javax.xml.bind.annotation.XmlSchema
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:602)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522)
... 5 more
Thank you all hopefully I'm missing something simple!

Related

ddev get drud/ddev-platformsh configuration - error when generating needed environment variables on MacOS

I'm encountering an issue with undefined project variables following the installation steps outlined here: https://github.com/drud/ddev-platformsh#install
Steps 1-3 were smooth, with no issues.
On step 4 ddev get drud/ddev-platformsh, the script runs successfully until the 'Executing post-install actions:' section. Here is the output with a few preceding lines for context:
Configuration complete. You may now run 'ddev start'.
Installing project-level components:
👍 web-build/Dockerfile.platformsh
👍 homeadditions/.bashrc.d/platformsh-environment.sh
👍 platformsh/.gitignore
👍 platformsh/generate_db_relationship.sh
👍 platformsh/generate_elasticsearch_relationship.sh
👍 platformsh/generate_memcached_relationship.sh
👍 platformsh/generate_redis_relationship.sh
Installing global components:
👍 commands/web/platform
Executing post-install actions:
👍 Support composer and python3 dependencies
BASE64_ENCODE=base64 -w 0
base64: illegal option -- w
base64: illegal option -- w
👎 Installing dependencies and generating needed environment variables
could not process post-install action (2) 'Installing dependencies and generating needed environment variables'
How do I address this? The issue could be that I'm running this on MacOS, which doesn't support the -w flag for BASE64 (based on this other SO issue).
Also, I see that Platform has these environment variables: https://docs.platform.sh/development/variables/use-variables.html#use-platformsh-provided-variables
...but I'm unclear how/where they should be integrated into the DDEV config files.
Also, after encountering the config error, I ran this command, which failed and further indicated that at least one project variable was missing:
$ ddev drush cr
In Config.php line 567:
The appDir variable is not defined. Are you sure you're running on Platform.sh?
Failed to run drush cr: exit status 1
Any advice wrt how to overcome this issue would be welcome. Thank you.
My environment:
DDEV: v1.21.4
OS: MacOS Ventura 13.1
CPU: Apple M1
I think you're on macOS and you have the homebrew version of base64 installed. Unfortunately, it's quite different in its behavior. Could you please uninstall the homebrew version? brew uninstall base64 && hash -r (hash -r just makes the changes in PATH immediately effective).
See https://github.com/drud/ddev-platformsh/issues/93

Nativescript Error: Executing webpack failed with exit code 1

I've done a fresh install of Nativescript on a new iMac (running Big Sur) following the instructions carefully (from https://docs.nativescript.org/environment-setup.html#macos-ios).
It was working fine after the install yesterday, but today I cannot run apps in ios simulator (or in an Android virtual device).
The ns doctor command in terminal gives me this initially:
No issues were detected.
✔ Your ANDROID_HOME environment variable is set and points to correct directory.
✔ Your adb from the Android SDK is correctly installed.
✔ The Android SDK is installed.
✔ A compatible Android SDK for compilation is found.
✔ Javac is installed and is configured properly.
✔ The Java Development Kit (JDK) is installed and is configured properly.
✔ Xcode is installed and is configured properly.
✔ xcodeproj is installed and is configured properly.
✔ CocoaPods are installed.
✔ CocoaPods update is not required.
✔ CocoaPods are configured properly.
✔ Your current CocoaPods version is newer than 1.0.0.
✔ Python installed and configured correctly.
✔ The Python 'six' package is found.
✔ Xcode version 12.5.1 satisfies minimum required version 10.
✔ Getting NativeScript components versions information...
✔ Component nativescript has 8.0.2 version and is up to date.
However, when I create a new app (ns create) and then try to run in (ns run ios), I get this error: Executing webpack failed with exit code 1.
The error messages start with this: TypeError: Cannot read property 'resolved' of undefined.
The same thing is also happening when I try to run it on Android.
After trying to run it on both ios and Android, ns doctor adds these lines:
✔ Component #nativescript/core has 8.0.8 version and is up to date.
✔ Component #nativescript/ios has 8.0.0 version and is up to date.
✔ Component #nativescript/android has 8.0.0 version and is up to date.
So it seems like the platforms are being added properly.
Any help would be greatly appreciated!
The full error message is:
Searching for devices...
Preparing project...
webpack is watching the files...
/Users/student/Desktop/testApp/node_modules/webpack/lib/FileSystemInfo.js:817
if (entry.resolved !== undefined) return entry.resolved;
^
TypeError: Cannot read property 'resolved' of undefined
at getResolvedTimestamp (/Users/student/Desktop/testApp/node_modules/webpack/lib/FileSystemInfo.js:817:12)
at /Users/student/Desktop/testApp/node_modules/webpack/lib/FileSystemInfo.js:1167:21
at /Users/student/Desktop/testApp/node_modules/webpack/lib/util/AsyncQueue.js:352:5
at Hook.eval [as callAsync] (eval at create (/Users/student/Desktop/testApp/node_modules/webpack/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:6:1)
at Hook.CALL_ASYNC_DELEGATE [as _callAsync] (/Users/student/Desktop/testApp/node_modules/webpack/node_modules/tapable/lib/Hook.js:18:14)
at AsyncQueue._handleResult (/Users/student/Desktop/testApp/node_modules/webpack/lib/util/AsyncQueue.js:322:21)
at /Users/student/Desktop/testApp/node_modules/webpack/lib/util/AsyncQueue.js:305:11
at /Users/student/Desktop/testApp/node_modules/webpack/lib/FileSystemInfo.js:3098:21
at /Users/student/Desktop/testApp/node_modules/webpack/lib/FileSystemInfo.js:3010:22
at /Users/student/Desktop/testApp/node_modules/neo-async/async.js:2830:7
at done (/Users/student/Desktop/testApp/node_modules/neo-async/async.js:2925:13)
at /Users/student/Desktop/testApp/node_modules/webpack/lib/FileSystemInfo.js:2994:23
at Array.<anonymous> (/Users/student/Desktop/testApp/node_modules/webpack/lib/util/fs.js:311:21)
at runCallbacks (/Users/student/Desktop/testApp/node_modules/enhanced-resolve/lib/CachedInputFileSystem.js:27:15)
at /Users/student/Desktop/testApp/node_modules/enhanced-resolve/lib/CachedInputFileSystem.js:200:4
at callback (/Users/student/Desktop/testApp/node_modules/graceful-fs/polyfills.js:299:20)
Executing webpack failed with exit code 1.
Thank you for reporting this, we have confirmed a breaking change in the latest webpack release:
https://github.com/webpack/webpack/releases/tag/v5.51.1
You can switch your package.json to use the rc as follows to resolve this right now:
"devDependencies": {
...
"#nativescript/webpack": "rc"
},
Then ns clean and you should be able to run your app now.
We also published another beta tag pinning webpack to 5.50.0 so doing ns clean without making any other dependency change in your own package.json should also work now.

Unable to locate adb on macOS Catalina

I am starting to learn how to do mobile programming with ReactNative on an android environment. I’m using MacOS Catalina and I’ve installed android studio and react-native-cli. I ran react-native init ShoppingList which passed
Downloading template,
Copying template,
Processing template
but failed at Installing CocoaPods dependencies because I wasn't at the latest OS yet(I hope this is not part of the problem because I don’t have enough memory to upgrade OS)
I’ve referred to a suggestion inside this issue, which asks me to run
npm uninstall -g react-native react-native-cli
npm install -g react-native react-native-cli
react-native start --reset-cache
I’ve also deleted the node_modules and npm install at the root of the project. Then at the root of the project I ran react-native run-android.
Which gave me the following error
info Running jetifier to migrate libraries to AndroidX. You can disable it using "--no-jetifier" flag.
Jetifier found 967 file(s) to forward-jetify. Using 8 workers...
info Starting JS server...
/bin/sh: adb: command not found
info Launching emulator...
error Failed to launch emulator. Reason: No emulators found as an output of `emulator -list-avds`.
warn Please launch an emulator manually or connect a device. Otherwise app may fail to launch.
info Installing the app...
Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.2/userguide/command_line_interface.html#sec:command_line_warnings
FAILURE: Build failed with an exception.
* What went wrong:
Could not determine the dependencies of task ':app:installDebug'.
> SDK location not found. Define location with an ANDROID_SDK_ROOT environment variable or by setting the sdk.dir path in your project's local properties file at '/Users/prashin/Test/ShoppingList/android/local.properties'.
* 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
error Failed to install the app. Make sure you have the Android development environment set up: https://reactnative.dev/docs/environment-setup. Run CLI with --verbose flag for more details.
Error: Command failed: ./gradlew app:installDebug -PreactNativeDevServerPort=8081
Inside Android Studio, the following are installed
Android 11.0(R),
Android SDK Build-Tools,
Android Emulator 30.2.6,
Android SDK-Platform-Tools 30.0.5,
Intel x86 Emulator Accelerator (HAXM installer) 7.5.1
I created a Pixel 2 Device with Release name R(API Level 30), and pressed the Play button countless times, it gives me the error of AVD Manager: Unable to locate ADB.
This is my .bash_profile file.
source ~/.profile
# Setting PATH for Python 3.7
# The original version is saved in .bash_profile.pysave
PATH="/Library/Frameworks/Python.framework/Versions/3.7/bin:${PATH}"
export PATH
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
##
# Your previous /Users/prashin/.bash_profile file was backed up as /Users/prashin/.bash_profile.macports-saved_2019-10-23_at_18:32:04
##
# MacPorts Installer addition on 2019-10-23_at_18:32:04: adding an appropriate PATH variable for use with MacPorts.
export PATH="/opt/local/bin:/opt/local/sbin:$PATH"
export ANDROID_HOME=/Users/prashin/Library/Android/sdk
export ANDROID_SDK_ROOT=$ANDROID_HOME
export PATH="$PATH:$ANDROID_HOME/emulator:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools"
# export PATH="$PATH:/Users/$USER/Library/Android/sdk/platform-tools"
# export PATH=${PATH}:/usr/local/mysql-5.7.31-macos10.14-x86_64/bin
# Finished adapting your PATH environment variable for use with MacPorts.
And I do see an adb executable inside platform-tools according to this post.
What could I be missing here which is preventing me from running my basic application on the simulator? Do inform me if more information is needed.
Edit
A suggested solution of switching to .zprofile changed the error message instead. It got stuck at info launching emulator for 30s before producing the error below.
error Failed to launch emulator. Reason: Could not start emulator within 30 seconds..
warn Please launch an emulator manually or connect a device. Otherwise app may fail to launch.
info Installing the app...
> Task :app:stripDebugDebugSymbols UP-TO-DATE
Compatible side by side NDK version was not found.
> Task :app:installDebug FAILED
Skipping device 'emulator-5554' (emulator-5554): Device is OFFLINE.
Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.2/userguide/command_line_interface.html#sec:command_line_warnings
27 actionable tasks: 2 executed, 25 up-to-date
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:installDebug'.
> com.android.builder.testing.api.DeviceException: No online devices found.
* 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 4s
error Failed to install the app. Make sure you have the Android development environment set up: https://reactnative.dev/docs/environment-setup. Run CLI with --verbose flag for more details.
Error: Command failed: ./gradlew app:installDebug -PreactNativeDevServerPort=8081
With Catalina, Apple has changed the default shell to zsh. Therefore you have to rename your configuration files. .bashrc is now .zshrc and .bash_profile is now .zprofile. Move the contents of your .bash_profile to a new .zprofile file and restart your terminal. Run the app again with new environment variables in place.
Simply restarting the terminal made the trick for me...

Titanium SDK zip package is not being generated

I downloaded the Titanium SDK and followed the steps to locally build it from here.
According to the guide, they changed the way to build the SDK to the one listed in here.
But when I try to perform the build like this:
node scons.js build --android-ndk c:\Android\android-ndk-r9
--android-sdk c:\Android\SDK
The console shows the following lines of text:
Building MobileSDK version 6.1.0, githash 591555a You don't seem to
have the appropriate thirdparty files. I'll fetch them. This could
take awhile.. Might want to grab a cup of Joe or make fun of Nolan.
Downloading
http://timobile.appcelerator.com.s3.amazonaws.com/libTiCore-24.a.gz
100% [========================================] 0.0s
Gunzipping C:\Users\AGUSTN~1\AppData\Local\Temp\117215-10132-d88fho.gz
to C:\Titanium\titanium_mobile\iphone\lib\libTiCore.a
And it stops there, when I go check the dist folder no zip is found.
Why is the zip not being generated and no error being thrown?
I have the following enviroment variables set:
ANDROID_SDK
ANDROID_NDK
PATH with the paths to THE BINARIES for NPM (3.83), Node.js (5.10.1),
git (2.8.1.windows.1), Python (2.7.13), Java (8 rev 77), Ant (1.9.7),
gperf (3.0.1), $ANDORID_SDK/platform-tools and $ANDROID_SDK/tools
JAVA_HOME (Java 8 rev 77)
ANDROID_PLATFORM (set to 17)
GOOGLE_APIS (set to 23)
Why is the SDK not being packaged?
Install the node tools titanium and appc with:
npm install titanium appc -g
in order to compile the SDK

Cordova/Phone Gap 2.5.0 create error

I have a problem while creating a new android project for phonegap 2.5.0. I use a Mac and set the path variables correctly. But after the command
./create /pathtoProject/PhoneGap FirstPackage CatchMyPainPG
the terminal works for about a second and then i get the following error:
An unexpected error occurred: "$ANDROID_BIN" create project --target $TARGET --path "$PROJECT_PATH" --package $PACKAGE --activity $ACTIVITY >&/dev/null exited with 1
Deleting project...
What does this mean? I think i've set the correct path variables and have all the android sdk's installed.
I hope you can help me! Thanks in advance
The package name should be prefixed accordingly with 3 namespace.
Example: com.companyname.projectname
Try this:
./create /pathtoProject/PhoneGap com.YourCompanyName.FirstPackage CatchMyPainPG
make sure you can run the commands below from your terminal:
ant -version
java -version
android -h

Resources