problem with running flutter app in vscode - android

when I run my app I get this error :
Error: ADB exited with exit code 1
Performing Streamed Install
adb: failed to install F:\flutter-project\1\third_app\third_app\build\app\outputs\apk\app.apk: Failure [INSTALL_FAILED_INVALID_APK: Package couldn't be installed in /data/app/com.example.third_app-1: Package /data/app/com.example.third_app-1/base.apk code is missing]
Error launching application on Android SDK built for x86.
update:
I run flutter clear in the terminal and after restarting my computer and executing again, the problem solved

One of the SO post mentioned in the comment:
For Flutter projects, with VS Code editor, go to the project source
folder and delete the "build" folder and start debugging.
This could also be attained by running flutter clean from the terminal. This command helps you delete build cache which is in the /build folder. You can always uses this command when there are any bugs in the build process.

Related

ionic cordova run android fails at invalid adb location?

I'm trying to get a brand new set up in place to run the example Ionic 4 app on an android device. I'm running on a brand new iMac and have installed all the needed prerequisites (ionic cli, npm, JDK8, Gradle, Android SDK, set up environmental variables, etc.) All latest version, fresh install.
I'm able to create the example app, add android platform, and build fine. But when I try to run to a device I get this error:
cordova build android
native-run android --app platforms/android/app/build/outputs/apk/debug/app-debug.apk --forward 8100:8100
[native-run] Error: spawn /Users/mike/Library/Android/sdk/platform-tools/adb ENOENT
[native-run] at Process.ChildProcess._handle.onexit (internal/child_process.js:267:19)
[native-run] at onErrorNT (internal/child_process.js:469:16)
[native-run] at processTicksAndRejections (internal/process/task_queues.js:84:21)
[ERROR] An error occurred while running subprocess native-run.
What concerns me is the file path shown (.../sdk/platform-tools/adb) is different from where I see the location when navigating there myself (i.e. the fresh install of Android Studio has this at the location .../sdk/platform-tools/platform-tools/adb .... (note the extra "platform-tools" folder.
When I run "adb devices" it works, but only when I have the environmental variable (PATH) set to .../platform-tools/platform-tools/adb but when I try the ionic run command its obviously trying the other location. How? Why? What did I install wrong???
After much toiling... final step was to completely uninstall and remove all components of Android Studio, then reinstall again. This solved it and removed the duplicate folders. No idea how it would have happened on a standard install but if anyone else experiences it, this would be my recommendation.

Can't able to run react native application on android device

Im Using MacBook Pro.. Im New To React Native.. After Creating An Project Im Running On iOS Device It's Running.. At The Same Time While I'm Running On Android Device Means Im Getting This Error.. Any One Please Help Me To Resolve This Error.. Im Using Visual Studio Code IDE For React Native Application
Thanks In Advance..
Error Details :
[Info] local.properties file doesn't exist. Using Android SDK location from PATH.
[Info] Starting React Native Packager.
info Running jetifier to migrate libraries to AndroidX. You can disable it using "--no-jetifier" flag.
Jetifier found 864 file(s) to forward-jetify. Using 8 workers...
/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...
FAILURE: Build failed with an exception.
* Where:
Settings file '/Users/manikandan/AwesomeProject/android/settings.gradle'
* What went wrong:
Could not compile settings file '/Users/manikandan/AwesomeProject/android/settings.gradle'.
startup failed:
General error during semantic analysis: Unsupported class file major version 57
So you have two errors to fix here as your error log
local.properties file doesn't exist.
Failed to launch the emulator
local.properties file issue fixing
Open your react native project android folder using Android Studio.
Wait for gradle sync and clean the project and rebuild it using Android Studio
After that make sure you have local.properties file is been created inside android folder
If not try these steps to make local.properties file manually
Right click top level of project and Create new file 'local.properties' then add: sdk.dir=/Users/<YourUsername>/Library/Android/sdk
Clean and build
Before running your react native project on android make sure you have turn on the Android Emulator by AVD Manager in Android Studio
If you have not create any emulators then try this link - I have posted full answer on how to make Android Emulator -
React native failed to launch emulator
EDIT :
For adb error you need to install adb drivers on you Mac
Follow these steps
First install Homebrew using this command
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
or this command
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
After that install adb using homebrew
brew cask install android-platform-tools
Try to re run

Error in running flutter project which no permission

Launching lib/main.dart on Android SDK built for x86 in debug mode...
[!] Gradle does not have execution permission.
You should change the ownership of the project directory to your user, or move the project to a directory with execute permissions.
Gradle task assembleDebug failed with exit code 1
Exited (sigterm)
I got the same error trying to execute flutter run on a mac. Apparently, in your flutter project, there is a file android/gradlew that is expected to be executable (and it wasn't). So in my case, I ran...
chmod a+rx android/gradlew
...afterwards the flutter command worked.
FOR FLUTTER
I have tried mostly everything mentioned here and on my own. The solution, actually, it is a series of solutions and worked for me, I am mentioning them try as you wish.
Make sure no antivirus *firewall is blocking,
gradle.bat, gradlew.bat,
git,
flutter,
android studio
Get the latest Gradle and install it to lower privilege directory, not in Program Files or Program Files (X86); I did it in D drive.
Don't forget to update the path in Environment Variables.
I also installed JAVA Runtime (JRE).
Install git as it is necessary for flutter.
You can Check-in windows command line after installing each (Git, Gradle and flutter doctor). if nothing seems to work Restart the pc after each.
You might try it first, Disable the Gradle plugin and re-enable and restart android studio.
After this when you will compile /run the app it will take a long time please bear with that(at least 15 min just to be sure).
I had the app directory with Read, Write & Modifying permissions still, it was giving that error-
Error code 1 "gradle does not have execution permission. you should change the ownership of the project directory to your user, or move the project to a directory with execute permissions."
so I think it is related to the connection with the plugin.
Hope it helped :-)
Try to set the execution flag on your gradlew file:
chmod +x gradlew
chmod a+rx android/gradlew
This works but for windows you need to install "Git for Windows"

Could not create service of type ScriptPluginFactory using BuildScopeServices.createScriptPluginFactory() react-native. How to fix?

I have the template code for my "Helloworld" app written in javascript and react-native on Windows. I connected my android emulator and wanted to launch the app on it. The following happens when I run "react-native run-android" command. Node.js opens as a separate window and it's written "Loading dependency graph, done". However, in the terminal window, there is following error message:
>User helloworld $ 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:
Could not create service of type ScriptPluginFactory using
BuildScopeServices.createScriptPluginFactory().
>Could not create service of type PluginResolutionStrategyInternal using BuildScopeServices.createPluginResolutionStrategy().
>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 1s
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
Command failed: gradlew.bat installDebug
Error: Command failed: gradlew.bat installDebug
at checkExecSyncError (child_process.js:616:11)
at Object.execFileSync (child_process.js:634:13)
at runOnAllDevices (C:\Users\User\helloworld\node_modules\react-native\local-cli\runAndroid\runAndroid.js:299:19)
at buildAndRun (C:\Users\User\helloworld\node_modules\react-native\local-cli\runAndroid\runAndroid.js:135:12)
at isPackagerRunning.then.result (C:\Users\User\helloworld\node_modules\react-native\local-cli\runAndroid\runAndroid.js:65:12)
at process._tickCallback (internal/process/next_tick.js:68:7)
-Concerning whether emulator is connected:
$ adb devices
List of devices attached
emulator-5554 device
(Works similarly for my Android smartphone). USB debugging is enabled.
-Concerning what I have tried to solve the problem:
My user is set as administrator.
I had JDK11.0.1 version. I installed JDK1.8.0_201 and it is now set as my java version.
User helloworld $ java -version
java version "1.8.0_201"
I created ".gradle" folder in my project's directory in case there are problems with accessing/creating this kind of folder.
-I specified the path for sdk.dir in local.properties file
-My OS is Windows 8.1. Gradle's version is 4.7.
-I have installed Android Studio, JDK8 and 11.
-I am using GitBash for the terminal purposes.
-I have the following system's environment variables:
ANDROID_HOME = c:\Users\User\AppData\Local\Android\Sdk
GRADLE_HOME = C:\Users\User.gradle\wrapper\dists\gradle-4.7-all\4cret0dgl5o3b21weaoncl7ys\gradle-4.7
JAVA_HOME = C:\Program Files\Java\jdk1.8.0_201
Path = C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files\Git\cmd;.\Plugins;C:\Users\User\AppData\Local\Programs\Python\Python37-32;C:\Program Files\nodejs\;c:\Users\User\AppData\Local\Android\Sdk\platform-tools;C:\Users\User\AppData\Local\Android\Sdk\platform-tools;%GRADLE_HOME%\bin;%JAVA_HOME%\bin
In case you are interested what was in the question before:
My initial problem was that there just was not any error shown, but still nothing was launched on the emulator. I went around that by putting my project's "android" folder into Android Studio and it launched the app on my smartphone. However, when I introduced small changes to App.js, the project could not be updated due to some unknown error, and I couldn't reopen it as a new project. So I had to solve this problem by trying to run the app by using "react-native run-android" through terminal, and now I'm at this state of the problem.
Mmmm... when you run react-native run-android on the console, 1 it should check if you have the android sdk's, second it should compile some things, and third, it should start metro bundler in ANOTHER console . The "Loading dependency graph, done" should appear on that OTHER console, while the main console is gonna still compile for about a minute or even more... then it's gonna launch the intent and open the app. Sometimes it just displays a blank screen after the first load, so you should exit the app and delete it from recents, and reopen the app
Post screenshots, it seems like you only see that secondary console while the main console is not displaying (?)
Do you want to run a react-native or purely java application for which you must have used Android studio?
If for the studio app: you must enable the developer's options from your phone for enabling that check this:
https://www.samsung.com/uk/support/mobile-devices/how-do-i-turn-on-the-developer-options-menu-on-my-samsung-galaxy-device/

nativescript sample projects fail with error Command ant failed with exit code 1

I went through the setup steps - on mac - but the sample nativescript projects all fail with the same error.
"Command ant failed with exit code 1"
Here is the log trace:
https://gist.github.com/getsetbro/c0225e8fc493d57b3f64
Other info
Android Studio on this mac run projects fine in emulators and connected devices
The same projects run in ios emulator without errors.
I installed JDK 8, never had version 7 on this system.
I see the following error in the logs.
Cannot run program "/Users/sb/Documents/Dev/nativescript/test_nativescript/platforms/android/${aapt}"
I might be wrong but it seems aapt tool is missing from your $PATH environment variable. If this is the case, try adding <ANDROID_SDK_ROOT>/tools to $PATH

Categories

Resources