I am using two methods to build an APK in React Native project.
using react-native run-android and take the latest apk from projectFolder>android>app>build>output>apk.
react-native bundle --dev false --platform android --entry-file index.android.js --bundle-output ./android/app/build/intermediates/assets/debug/index.android.bundle --assets-dest ./android/app/build/intermediates/res/merged/debug
then run:
cd android
gradlew assembleDebug
then physically locate the file at android/app/build/outputs/apk folder:
app-debug.apk
app-debug-unaligned.apk
The problem I am facing is that if I am building apk from above-mentioned methods then generated apk is not the build of updated code. But the same code which I am running on the Android simulator of Android Studio is working perfectly. Also if I am using a real device as an emulator connected to the android studio, it's running on the older version of build.
(Posted on behalf of the question author, from a comment).
This was solved as follows:
enable usb debugging.
download latest usb driver for phone.
setx PATH "%PATH%;C:\Program Files\android-sdk\platform-tools" (see here)
execute adb. exe from C:\Users[youruser]\AppData\Local\Android\android-studio\sdk\platform-tools
run adb devices in cmd to see list of connected devices
Run the following in a command prompt:
$ adb -s <device name> reverse tcp:8081 tcp:8081
To find the device name, run the following adb command:
$ adb devices
Related
I install Android Studio about 2 week ago and all work fine. But today I run studio and it don't start. I remove and install again. But it also don't work.
open -a /Applications/Android\ Studio.app
LSOpenURLsWithRole() failed for the application /Applications/Android Studio.app with error -10810.
macOS Catalina 10.15.6
I deleted folder /Users/user/Library/Preferences/AndroidStudio4.0
And run app. App run and work correct.
When I am trying to run my android studio program in my device which is connected with USB, It show an error msg:
Installation failed with message Failed to commit install session 482678384 with command cmd package install-commit 482678384. Error: INSTALL_FAILED_USER_RESTRICTED: Install canceled by user.
It is possible that this issue is resolved by uninstalling an existing version of the apk if it is present, and then re-installing.
)
I tried all possible methods but at the end I am not able run my code.
I'm working on Windows 10 and just starting with react-native. from https://facebook.github.io/react-native/docs/getting-started
One of the first steps to get started is to run: react-native run-android. But I'm getting this error:
Starting JS server...
Building and installing the app on the device (cd android && gradlew.bat installDebug)...
Starting a Gradle Daemon (subsequent builds will be faster)
FAILURE: Build failed with an exception.
What went wrong:
Failed to capture snapshot of output files for task ':app:processDebugResources' property 'sourceOutputDir' during up-to-date check.
Could not read path 'C:\Users\Kourosh\Desktop\React Native\AwesomeProject\android\app\build\generated\not_namespaced_r_class_sources\debug\processDebugResources\r\android\arch\lifecycle\livedata\core'.
If this happens after changing your styles.xml in android/app/src/main/res/values, run this:
cd android
./gradlew clean
cd ..
react-native run-android
Source (Github issue comment)
Clearing the cache does fix it. But only once, if you stop the project and re run it, you ll end up with same error again.
Doing following fixes it for me,
cd android
./gradlew clean
react-native start --reset-cache
npm clean cache --force
Next, open two different terminals run
react-native start
in one and in second run
react-native run-android
Hope it'll work for you as well.
So, if you have an Ionic 4 project, into your project folder, go to platforms/android and run ./gradlew clean.
cd platforms/android
./gradlew clean
ionic cordova run android -l
I don't see Installing APKs process when I run the AVD but it's work fine and the virtual device runs but I don't see my application
I have cloned Wix RNN2 repo [Branch v2] and I am not sure how to run playground on my emulator.
If I just run npm run start, I get this error:
> rm -rf ./lib/dist && tsc
'rm' is not recognized as an internal or external command,
operable program or batch file.
Windows cannot recognize that command because its linux.
I have tried running the app from Android Studio, and on my emulator, it says:
Unable to load scripts from assets 'index.android.bundle - which is because I don't have Metro Bundler making a bundle for me.
Anyways, what is the right way to run this example by Wix RNN2?
I have VSCode, Expo, Android Studio and my android build has no errors for the Android project.
follow these steps:
1) git clone https://github.com/wix/react-native-navigation.git
2) cd react-native-navigation
3) npm install
4) npm start
5) open xcode