missing android.jar when I try to run flutter project - flutter

Hey I try to run a project but it keeps showing that a android.jar is missing. What can I do ?
Launching lib\main.dart on SM G970F in debug mode...
FAILURE: Build failed with an exception.
* What went wrong:
A problem was found with the configuration of task ':app:processDebugResources'.
> File 'C:\Users\adamr\AppData\Local\Android\sdk\platforms\android-28\android.jar' specified for property 'androidJar' does not exist.
* 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 12s

This issue occurs when your platform SDK have missing android.jar file.
Download android.jar file and paste into directory of your plateform SDK from
https://github.com/Sable/android-platforms
It solved my problem in my Linux. Iam sure it will work on Windows as well✌️.

It seems to be a problem with your Android SDK. Try going to Android Studio, Check if you have installed all the required SDK, must times running flutter doctor -v will show you that.
If flutter doctor is fine then I recommend that you uninstall the current android SDK and re-install it.

Your android sdk is incomplete. Try install it from Android Studio SDK manager. The folder should looks like the following:
/Users/shooding/Library/Android/sdk/platforms/android-28/
├── android-stubs-src.jar
├── android.jar
├── build.prop
├── data
├── framework.aidl
├── optional
├── package.xml
├── sdk.properties
├── skins
├── source.properties
├── templates
└── uiautomator.jar

Related

ionic - BUG! exception in phase 'semantic analysis' in source unit '_BuildScript_' Unsupported class file major version 63

I am working ionic angular
while run this comment cordova build android --release
am getting this error
PS C:\Users\Nirali\Documents\nmhapp> cordova build android --release
Checking Java JDK and Android SDK versions
ANDROID_SDK_ROOT=C:\Users\Nirali\AppData\Local\Android\Sdk (recommended setting)
ANDROID_HOME=C:\Users\Nirali\AppData\Local\Android\Sdk (DEPRECATED)
Using Android SDK: C:\Users\Nirali\AppData\Local\Android\Sdk
FAILURE: Build failed with an exception.
What went wrong:
Could not open settings generic class cache for settings file 'C:\Users\Nirali\Documents\nmhapp\platforms\android\settings.gradle' (C:\Users\Nirali.gradle\caches\7.5.1\scripts\7e15adv812akcxkuh6ist7or8).
BUG! exception in phase 'semantic analysis' in source unit 'BuildScript' Unsupported class file major version 63
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
Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0.
You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.
See https://docs.gradle.org/7.5.1/userguide/command_line_interface.html#sec:command_line_warnings
BUILD FAILED in 771ms
Command failed with exit code 1: C:\ProgramData\chocolatey\bin\gradle.EXE -p C:\Users\Nirali\Documents\nmhapp\platforms\android wrapper -b C:\Users\Nirali\Documents\nmhapp\platforms\android\wrapper.gradle
PS C:\Users\Nirali\Documents\nmhapp>
How to fix this issue.
Upgrade to a snapshot of gradle 7.6, or wait for the 7.6 release
https://services.gradle.org/distributions-snapshots/gradle-7.6-20221021231540+0000-bin.zip
Solved this issue by opening my project in Android Studio, and it began building Gradle, then it recommended I upgrade Gradle. After the upgrade in Android Studio, I can now run my app.
Windows user:
Go to C:\Users\arpan.gradle\caches and delete all the gradle cache.
then,
Go to "C:\Program Files\Android\Android Studio" there you will see jbr and jre folder then copy the content of jbr and paste the content into jre folder.
ss:
and run flutter doctor again and run your App.

JDK installation not found by flutter starter app

I have cloned the flutter repo and installed the Android SDK command-line tools, setting them up in $HOME/Android. I then made flutter aware of the SDK installation by setting $ANDROID_HOME to $HOME/Android. Things seem to have worked out, with <path-to-flutter> doctor finding
Android SDK
my Java JDK 8 installation (openjdk-8-jdk package on Ubuntu 18.04), and
a connected Android phone with USB debugging
I am now trying to follow the test-run instructions for building a first app on the command line. <path-to-flutter> create myapp works and produces a myapp directory. I then try to run the resulting starter app:
cd myapp
~/myapp$ ANDROID_HOME=~/Android JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-amd64 <path-to-flutter> run
This results in the following error:
Launching lib/main.dart on ONEPLUS A6013 in debug mode...
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:compileDebugKotlin'.
> Kotlin could not find the required JDK tools in the Java installation '/usr/lib/jvm/java-8-openjdk-amd64/jre' used by Gradle. Make sure Gradle is running on a JDK, not JRE.
* 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 10s
Running Gradle task 'assembleDebug'...
Running Gradle task 'assembleDebug'... Done 11.0s
Exception: Gradle task assembleDebug failed with exit code 1
I have seen this issue discussed before, but none of those replies seem to address it (in my case, at least). You can see from the command that I am exporting the right $JAVA_HOME, and besides, running
./android/gradlew build
inside the myapp directory does work:
~/myapp$ ./android/gradlew build
> Task :buildEnvironment
------------------------------------------------------------
Root project
------------------------------------------------------------
classpath
No dependencies
A web-based, searchable dependency report is available by adding the --scan option.
BUILD SUCCESSFUL in 319ms
1 actionable task: 1 executed
So this seems to be specific to flutter itself somehow, rather than gradle.
It turns out this must have been a path issue. The Flutter starter app builds (and pops up on my device) after inserting the following snippet in a file sourced in my profile (my .bashrc):
# Java
export JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-amd64
# Android
export ANDROID_HOME=${HOME}/Android
export ANDROID_SDK_ROOT=${HOME}/Android
# Flutter
export FLUTTER_HOME=${HOME}/repos/flutter
PATH=${FLUTTER_HOME}/bin:$PATH; export PATH
you can do like this -->
sudo apt-get remove --auto-remove openjdk*
sudo apt-get install openjdk-8-jre
now goto to home and visible your hidden folder by pressing ctrl+h
Now open .bashrc or your .rc
paste these on last
export PATH="$PATH:/snap/bin/flutter/bin"
export PATH="$PATH:/usr/bin/java"
export JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-amd64/jre
export ANDROID_SDK_ROOT=/home/<YOUR USER NAME>/Android/Sdk
then run
source ~/bashrc
flutter doctor -v

How to properly import Open Source projects in Flutter?

I am learning Flutter and I would like to import an Open Source project to learn some of the structure etc.
The project is: https://github.com/matthewtory/trinity-orientation-2018
I am using Android Studio, and so far I can create my own projects and run them via my phone but when I want to import this project I am getting a lot of errors and warnings. The app is finished and also on the play store, so why doesn't it run in my IDE? Am I missing something?
Error message is:
Launching lib\main.dart on SM G960F in debug mode...
Initializing gradle...
Resolving dependencies...
* Error running Gradle:
ProcessException: Process "C:\Users\marcs\AndroidStudioProjects\trinity-orientation-2018-master\android\gradlew.bat" exited abnormally:
firebase_storage
firebase_messaging
url_launcher
camera
path_provider
cloud_firestore
shared_preferences
image_picker
firebase_core
firebase_auth
FAILURE: Build failed with an exception.
* Where:
Build file 'C:\Users\marcs\AndroidStudioProjects\trinity-orientation-2018-master\android\app\build.gradle' line: 16
* What went wrong:
A problem occurred evaluating project ':app'.
> versionCode not found. Define flutter.versionCode in the local.properties file.
* 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
Command: C:\Users\marcs\AndroidStudioProjects\trinity-orientation-2018-master\android\gradlew.bat app:properties
Finished with error: Please review your Gradle project setup in the android/ folder.
I downloaded the project and imported the folder in Android Studio. It first asked to get the dependencies which I did and immediately, I tried to run it on my phone.
Feel free to check the code on the Github project. I have not changed anything. I hope to run this project to learn about animation and navigation concepts.
The error message says you have to define version code. Try to add below lines to your local.properties file (under android folder)
flutter.versionName=1.0.0
flutter.versionCode=1
You may get other errors but at least this will fix the error in your question. Share other error message if you get.

Ionic 3 project and plugin crosswalk error

I have a Ionic 3 project, when I run "ionic cordova run android --prod" I see
This error:
ANDROID_HOME=C:\Users\asus\AppData\Local\Android\sdk\
JAVA_HOME=C:\Program Files\Java\jdk1.8.0_131\
Subproject Path: CordovaLib null
The Task.leftShift(Closure) method has been deprecated and
is scheduled to be removed in Gradle 5.0. Please use
Task.doLast(Action) instead.
at build_86b8k75dm7qqz7n5jyg9xp8kh.run(D:\project\ionic\MyProject\platforms\android\build.gradle:138) org.xwalk:xwalk_core_library:23+ The JavaCompile.setDependencyCacheDir() method has been deprecated and is scheduled to be removed in Gradle 4.0.
Incremental java compilation is an incubating feature. The TaskInputs.source(Object) method has been deprecated and is scheduled to be removed in Gradle 4.0. Please use TaskInp uts.file(Object).skipWhenEmpty() instead.
FAILURE: Build failed with an exception.
* What went wrong:
BUILD FAILED
Total time: 15.644 secs A problem occurred configuring root project 'android'.
> Could not resolve all dependencies for configuration ':_armv7DebugApkCopy'.
> Could not resolve org.xwalk:xwalk_core_library:23+.
Required by:
project :
> Could not resolve org.xwalk:xwalk_core_library:23+.
> Failed to list versions for org.xwalk:xwalk_core_library.
> Unable to load Maven meta-data from https://download.01.org/crosswalk/releases/crosswalk/android/maven2/org /xwalk/xwalk_core_library/maven-metadata.xml.
> Could not GET 'https://download.01.org/crosswalk/releases/crosswalk/android/maven2/org/xwalk/xwalk_core_ library/maven-metadata.xml'. Received status code 503 from server: Service Unavailable
* Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Error: cmd: Command failed with exit code 1 Error output: FAILURE: Build failed with an exception.
* What went wrong: A problem occurred configuring root project 'android'.
> Could not resolve all dependencies for configuration ':_armv7DebugApkCopy'.
> Could not resolve org.xwalk:xwalk_core_library:23+.
Required by:
project :
> Could not resolve org.xwalk:xwalk_core_library:23+.
> Failed to list versions for org.xwalk:xwalk_core_library.
> Unable to load Maven meta-data from https://download.01.org/crosswalk/releases/crosswalk/android/maven2/org /xwalk/xwalk_core_library/maven-metadata.xml.
> Could not GET 'https://download.01.org/crosswalk/releases/crosswalk/android/maven2/org/xwalk/xwalk_core_ library/maven-metadata.xml'. Received status code 503 from server: Service Unavailable
* Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
[ERROR] Cordova encountered an error.
You may get more insight by running the Cordova command above directly.
[ERROR] An error occurred while running cordova run android (exit code 1).
I did not recieve this error before running Ionic.
The 01.org server seems to be down. So till the servers are back online, you can ask Gradle to use the local copy of Crosswalk.
I was having the same issue from last one hour. The following solution worked for me.
Open platforms\android\cordova-plugin-crosswalk-webview\*-xwalk.gradle file in your project directory, where * is your project name.
Look for the section -
dependencies {
compile xwalkSpec
}
Replace it with your exact Crosswalk version which you find in Chrome Developer Tools by typing window.navigator.userAgent in your Developer Tools console.
So your final data would look something like this -
dependencies {
compile 'org.xwalk:xwalk_core_library:23.53.589.4'
}
1 Get crosswalk version
There are another two ways to get xwalk_core_library version, you can use either of them:
Go to platforms/android/build/intermediates/exploded-aar/org.xwalk‌​/xwalk_core_library/‌​, then you can see version like 19.49.514.5
In the Google cache, you can select a version number
2 Change the gradle
Just like #hemantv said, in file platforms\android\cordova-plugin-crosswalk-webview*-xwalk.gradle
Change the file form
dependencies {
compile xwalkSpec
}
to
dependencies {
compile 'org.xwalk:xwalk_core_library:19.49.514.5'
}
19.49.514.5 is the version get from the step one.
Another way, you can use this plugin temporarily:
cordova plugin add https://github.com/zhouzhongyuan/cordova-plugin-crosswalk-webview
It just fixed this error.
Get Crosswalk version
As answered by Zhongyuan Zhou, there are ways to get locally saved Crosswalk library on your project, but I prefer the following:
Go to platforms/android/build/intermediates/exploded-aar/org.xwalk‌​/xwalk_core_library/‌​, then you can see version like 22.52.561.4
Modify config.xml
Add the following into your config.xml
<preference name="xwalkVersion" value="xwalk_core_library:22.52.561.4" />
Compile the Android build
Do the usual ionic cordova build android to build the Android APK or ionic cordova run android to build and run / install the Android app on an emulator or device.
Reference: https://forum.ionicframework.com/t/server-error-with-crosswalk-when-running-ionic-run-android/104009/15
This is follow up to hemantv's answer. I was panicking but his answer saved my day, and I was able to successfully compile the app using the locally stored xwalk.
This is what I did and i hope it helps someone out there who's stuck with the same predicament.
I found out the Crosswalk version I have stored locally by running a search (including sub directorys) for "xwalk_core_library" in my app directory and found the file "org.xwalk-xwalk_core_library-17.46.448.10_9bf812c8b76a44fdb31553d48df45b60d1362adc.jar" and figured out the version I had was "org.xwalk-xwalk_core_library-17.46.448.10" (everything after the underscore "_" is irrelevant)
I followed the instructions and opened up the platforms\android\cordova-plugin-crosswalk-webview*-xwalk.gradle in a text editor
found
dependencies {
compile xwalkSpec
}
replaced with
dependencies {
compile 'org.xwalk:xwalk_core_library:17.46.448.10'
}
reattempted to compile and it worked like a charm.

How to run nativescript project in another visual studio code

I created android app using native script and i am using visual studio code.
so i want to run same project in another laptop using visual studio code.
so please tell me how to run because whenever i am trying to run project,its not able to build.
here is error:
E:\NS-APP\sample-ImageUpload-master>tns run android Skipping prepare.
Searching for devices... Building project...
Configuring > 0/3 projects > root project :config phase: createDefaultIncludeFiles
+found plugins: nativescript-background-http
+found plugins: nativescript-telerik-ui
+found plugins: tns-core-modules-widgets
:config phase: createPluginsConfigFile
Creating product flavors include.gradle file in E:\NS-APP\sample-ImageUpload-master\platforms\android/configurations
folder...
:config phase: pluginExtend
+applying configuration from: E:\NS-APP\sample-ImageUpload-master\platforms\android\configurations\include.gradle
+applying configuration from: E:\NS-APP\sample-ImageUpload-master\platforms\android\configurations\nativescript-background-http\include.gradle
+applying configuration from: E:\NS-APP\sample-ImageUpload-master\platforms\android\configurations\nativescript-telerik-ui\include.gradle
+applying configuration from: E:\NS-APP\sample-ImageUpload-master\platforms\android\configurations\tns-core-modules-widgets\include.gradle
Configuring > 0/3 projects > root project :config phase: addAarDependencies
+adding dependency: E:\NS-APP\sample-ImageUpload-master\platforms\android\libs\aar\Common-2017.1.222-dev-release.aar
+adding dependency: E:\NS-APP\sample-ImageUpload-master\platforms\android\libs\aar\Data-2017.1.222-dev-release.aar
+adding dependency: E:\NS-APP\sample-ImageUpload-master\platforms\android\libs\aar\List-2017.1.222-dev-release.aar
+adding dependency: E:\NS-APP\sample-ImageUpload-master\platforms\android\libs\aar\Primitives-2017.1.222-dev-release.aar
+adding dependency: E:\NS-APP\sample-ImageUpload-master\platforms\android\libs\aar\widgets-release.aar
The JavaCompile.setDependencyCacheDir() method has been deprecated and
is scheduled to be removed in Gradle 4.0. The
TaskInputs.source(Object) method has been deprecated and is scheduled
to be removed in Gradle 4.0. Please use
TaskInputs.file(Object).skipWhenEmpty() instead. Incremental java
compilation is an incubating feature. The Task.leftShift(Closure)
method has been deprecated and is scheduled to be removed in Gradle
5.0. Please use Task.doLast(Action) instead.
at build_1xv9gqucl7v9i0b8ti7pqf8cd.run(E:\NS-APP\sample-ImageUpload-master\platforms\android\build-tools\android-static-binding-generator\build.gradle:126)
:preBuild UP-TO-DATE :preF0F1F2DebugBuild UP-TO-DATE
:checkF0F1F2DebugManifest :preF0F1F2ReleaseBuild UP-TO-DATE
:prepareBackHttpAppRuntimeUnspecifiedLibrary UP-TO-DATE
:prepareComAndroidSupportAnimatedVectorDrawable2531Library UP-TO-DATE
:prepareComAndroidSupportAppcompatV72531Library UP-TO-DATE
:prepareComAndroidSupportDesign2531Library UP-TO-DATE
:prepareComAndroidSupportRecyclerviewV72531Library UP-TO-DATE
:prepareComAndroidSupportSupportCompat2531Library UP-TO-DATE
:prepareComAndroidSupportSupportCoreUi2531Library UP-TO-DATE
:prepareComAndroidSupportSupportCoreUtils2531Library UP-TO-DATE
:prepareComAndroidSupportSupportFragment2531Library UP-TO-DATE
:prepareComAndroidSupportSupportMediaCompat2531Library UP-TO-DATE
:prepareComAndroidSupportSupportV42531Library UP-TO-DATE
:prepareComAndroidSupportSupportVectorDrawable2531Library UP-TO-DATE
:prepareComAndroidSupportTransition2531Library UP-TO-DATE
:prepareCommon20171222DevReleaseLibrary UP-TO-DATE
:prepareData20171222DevReleaseLibrary UP-TO-DATE
:prepareList20171222DevReleaseLibrary UP-TO-DATE
:prepareNetGotevUploadservice303Library UP-TO-DATE
:preparePrimitives20171222DevReleaseLibrary UP-TO-DATE
:prepareWidgetsReleaseLibrary UP-TO-DATE
:prepareF0F1F2DebugDependencies :compileF0F1F2DebugAidl UP-TO-DATE
:compileF0F1F2DebugRenderscript UP-TO-DATE
:generateF0F1F2DebugBuildConfig UP-TO-DATE :cleanLocalAarFiles
:ensureMetadataOutDir :collectAllJars :setProperties
:generateTypescriptDefinitions SKIPPED :copyTypings SKIPPED
:asbg:generateInterfaceNamesList :asbg:traverseJsFiles
:asbg:runAstParser UP-TO-DATE :asbg:generateBindings Exception in
thread "main" java.io.IOException: File already exists. This may lead
to undesired behavior. Please change the name of one of the extended
classes.
E:\NS-APP\sample-ImageUpload-master\platforms\android\src\main\java\com\tns\gen\net\gotev\uploadservice\UploadServiceBroadcastReceiver_ftns_modules_nativescript_background_http_background_http_l6_c79__.java
at org.nativescript.staticbindinggenerator.Generator.writeBindings(Generator.java:60)
at org.nativescript.staticbindinggenerator.Main.main(Main.java:15)
:asbg:generateBindings FAILED
FAILURE: Build failed with an exception.
Where: Build file 'E:\NS-APP\sample-ImageUpload-master\platforms\android\build-tools\android-static-binding-generator\build.gradle'
line: 251
What went wrong: Execution failed for task ':asbg:generateBindings'.
Process 'command 'C:\Program Files\Java\jdk1.8.0_131\bin\java.exe'' finished with non-zero exit value 1
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.86 secs Command
E:\NS-APP\sample-ImageUpload-master\platforms\android\gradlew.bat
failed with exit code 1
run android
┌────────────────────────┬─────────────────────────────────────────────────────────────────────────────────────────┐
│ Usage │ Synopsis
│ │ Run on all connected │ $ tns run android [--key-store-path --key-store-password --key │ │ devices and running
│ -store-alias --key-store-alias-password ]
[--release] [--justlaunch] │ │ emulators │
│ │ Run on a selected │ $ tns run android --device
[--key-store-path --key-store │ │ connected device
or │ -password --key-store-alias
--key-store-alias-password ] [- │ │ running emulator │ -release] [--justlaunch] │ │ Start an emulator and │ $ tns run android --emulator [] [--key-store-path --key │ │ run the app inside
it │ -store-password --key-store-alias
--key-store-alias-password │ │ │ ] [--release] [--justlaunch]
│
└────────────────────────┴─────────────────────────────────────────────────────────────────────────────────────────┘
Runs your project on a connected Android device or in a native Android
emulator, if configured. This is shorthand for prepare, build and
deploy. While your app is running, prints the output from the
application in the console and watches for changes in your code. Once
a change is detected, it synchronizes the change with all selected
devices and restarts/refreshes the application.
Options
* --no-watch - If set, changes in your code will not be reflected during the execution of this command.
* --device - Specifies a connected device/emulator on which to run the app.
* --emulator - If set, runs the app in a native emulator for the target platform, if configured. When set, you can also set any other
valid combination of emulator options as listed by $ tns help emulate
android.
* --release - If set, produces a release build. Otherwise, produces a debug build. When set, you must also specify the
--key-store-* options.
* --key-store-path - Specifies the file path to the keystore file (P12) which you want to use to code sign your APK. You can use the
--key-store-* options along with --release to produce a signed release build. You need to specify all --key-store-* options.
* --key-store-password - Provides the password for the keystore file specified with --key-store-path. You can use the --key-store-*
options along with --release to produce a signed release build. You
need to specify all --key-store-* options.
* --key-store-alias - Provides the alias for the keystore file specified with --key-store-path. You can use the --key-store-* options
along with --release to produce a signed release build. You need to
specify all --key-store-* options.
* --key-store-alias-password - Provides the password for the alias specified with --key-store-alias-password. You can use the
--key-store-* options along with --release to produce a signed release build. You need to specify all --key-store-* options.
* --justlaunch - If set, does not print the application output in the console.
* --clean - If set, forces rebuilding the native application.
Attributes
* <Device ID> is the index or name of the target device as listed by $ tns device android
* <Emulator Options> is any valid combination of options as listed by $ tns help emulate android
Sending exception report (press Ctrl+C to stop).....
Reset your entire project by deleting node_modules, platforms and hooks folders and then rebuild the project with tns build android or tns run android
You need not delete node_modules and hooks, just deleting platforms and rebuilding should be fine.
rm -rf platforms
tns run android