index.android.bundle missing in APK after upgrading to RN 0.68 - android

After upgrading our RN app to RN 0.68, we are getting errors with the release build:
FATAL EXCEPTION: create_react_context
Process: com.app, PID: 15057
java.lang.RuntimeException: Unable to load script. Make sure you're either running Metro (run 'npx react-native start') or that your bundle 'index.android.bundle' is packaged correctly for release.
The app works fine in development, and was fine before upgrading. It is using Hermes, but not using the new Fabric architecture.
When building the APK and then looking into its content, we can see that the bundle is not copied. But it is correctly built in the intermediate artifacts:
$ ./gradlew assembleRelease
…
BUILD SUCCESSFUL in 45s
1050 actionable tasks: 14 executed, 1036 up-to-date
$ unzip -l app/build/outputs/apk/release/app-arm64-v8a-release.apk | grep bundle
<nothing>
$ ls -l app/build/outputs/apk/release/app-arm64-v8a-release.apk
-rw-r--r-- 1 renchap staff 15618010 Apr 12 21:03 app/build/outputs/apk/release/app-arm64-v8a-release.apk
$ find . -name "index.android.bundle"
./app/build/generated/assets/react/release/index.android.bundle
./app/build/intermediates/merged_assets/release/out/index.android.bundle
./app/build/intermediates/merged_assets/release/mergeReleaseAssets/out/index.android.bundle
./app/build/intermediates/assets/release/index.android.bundle
$ ls -lh ./app/build/intermediates/assets/release/index.android.bundle
-rw-r--r-- 1 renchap staff 11M Apr 12 19:48 ./app/build/intermediates/assets/release/index.android.bundle
I am suspecting that there is a missing build step and it is not copied to the final directory, but I am not familiar enough with Gradle or RN's build process to check this.
Do you have any idea of what can cause this, or where to look at to troubleshoot this?

Found it after comparing the build files with a brand new RN app!
I had
classpath("com.android.tools.build:gradle:7.1.2")
in android/build.gradle
But with RN 0.68, you need to depend exactly on version 7.0.4, otherwise the JS bundle is not copied into the final APK.
The release APK is now working after switching to
classpath("com.android.tools.build:gradle:7.0.4")

Related

Azure AppCenter: Android build succeeds but no APKs found

I've been setting up Azure App Center build pipelines and after some troubleshooting, I managed to make our debug build succeed. The issue is that, it seems to not be able to find any of the generated APKs in the expected directories. Any ideas on why that is?
Here's the specific part of the output log:
BUILD SUCCESSFUL in 4m 28s 130 actionable tasks: 124 executed, 6
up-to-date
##[section]Finishing: Gradle Task
##[section]Starting: Android Postprocess
============================================================================== Task : Shell script Description : Run a shell script using
Bash Version : 2.206.0 Author : Microsoft Corporation Help
:
https://learn.microsoft.com/azure/devops/pipelines/tasks/utility/shell-script
============================================================================== [command]/bin/bash
/Users/runner/runners/2.206.1/scripts/android-postprocess.sh
/Users/runner/work/1/s/build/outputs/apk Removing all ABI or density
dependent APKs… find: /Users/runner/work/1/s/build/outputs/apk: No
such file or directory find: /Users/runner/work/1/s/build/outputs/apk:
No such file or directory find:
/Users/runner/work/1/s/build/outputs/apk: No such file or directory
Found 0 APK file(s) Found 0 unaligned APK file(s) find:
/Users/runner/work/1/s/build/outputs/apk: No such file or directory
/Users/runner/runners/2.206.1/scripts/android-postprocess.sh: line 36:
pushd: /Users/runner/work/1/s/build/outputs/apk/..: No such file or
directory
/Users/runner/runners/2.206.1/scripts/android-postprocess.sh: line 43:
popd: directory stack empty
##[error]The process '/bin/bash' failed with exit code 1
##[error]Bash failed with error: The process '/bin/bash' failed with exit code 1
##[section]Finishing: Android Postprocess
I also have a post-clone bash script for generating the local.properties file which contains some secrets, and it seems to work just fine since the build uses it and goes through with it.
Sadly, I can't infer much from the logs, I'm not a DevOps engineer and have practically 0 experience in this sector.

I can't run react-native-webrtc-demo on my android emulator in mac os

I am going to show IP camera real-time on the mobile app.
So I downloaded Oney's RCTWebRTCDemo from GitHub to run it.
I did the following works.
Bians-iMac:MyHome byz$ git clone https://github.com/oney/RCTWebRTCDemo.git
Cloning into 'RCTWebRTCDemo'...
remote: Counting objects: 359, done.
remote: Total 359 (delta 0), reused 0 (delta 0), pack-reused 359
Receiving objects: 100% (359/359), 456.78 KiB | 303.00 KiB/s, done.
Resolving deltas: 100% (155/155), done.
Bians-iMac:MyHome byz$ cd RCTWebRTCDemo
Bians-iMac:RCTWebRTCDemo byz$ npm install
npm WARN deprecated connect#2.30.2: connect 2.x series is deprecated
npm WARN deprecated gulp-util#3.0.8: gulp-util is deprecated - replace it, following the guidelines at https://medium.com/gulpjs/gulp-util-ca3b1f9f9ac5
npm notice created a lockfile as package-lock.json. You should commit this file.
added 592 packages from 409 contributors and audited 5796 packages in 434.447s
found 24 vulnerabilities (13 low, 3 moderate, 8 high)
run `npm audit fix` to fix them, or `npm audit` for details
Bians-iMac:RCTWebRTCDemo byz$ npm audit fix
> fsevents#1.2.4 install /Volumes/STUDY/Work/MyHome/RCTWebRTCDemo/node_modules/fsevents
> node install
[fsevents] Success: "/Volumes/STUDY/Work/MyHome/RCTWebRTCDemo/node_modules/fsevents/lib/binding/Release/node-v57-darwin-x64/fse.node" already installed
Pass --update-binary to reinstall or --build-from-source to recompile
npm WARN react-native#0.56.0 requires a peer of react#16.4.1 but none is installed. You must install peer dependencies yourself.
+ react-native#0.56.0
added 407 packages from 157 contributors, removed 196 packages, updated 72 packages and moved 3 packages in 59.949s
fixed 20 of 24 vulnerabilities in 5796 scanned packages
1 package update for 4 vulns involved breaking changes
(use `npm audit fix --force` to install breaking changes; or refer to `npm audit` for steps to fix these manually)
Bians-iMac:RCTWebRTCDemo byz$ react-native link
Scanning folders for symlinks in /Volumes/STUDY/Work/MyHome/RCTWebRTCDemo/node_modules (9ms)
rnpm-install info Platform 'ios' module react-native-webrtc is already linked
rnpm-install info Linking react-native-webrtc android dependency
rnpm-install info Platform 'android' module react-native-webrtc has been successfully linked
Bians-iMac:RCTWebRTCDemo byz$ react-native run-android
Scanning folders for symlinks in /Volumes/STUDY/Work/MyHome/RCTWebRTCDemo/node_modules (11ms)
JS server already running.
Building and installing the app on the device (cd android && ./gradlew installDebug)...
File /Users/byz/.android/repositories.cfg could not be loaded.
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring project ':WebRTCModule'.
> Could not resolve all dependencies for configuration ':WebRTCModule:_debugPublishCopy'.
> Could not find com.android.support:appcompat-v7:26.1.0.
Searched in the following locations:
file:/Users/byz/Library/Android/sdk/extras/android/m2repository/com/android/support/appcompat-v7/26.1.0/appcompat-v7-26.1.0.pom
file:/Users/byz/Library/Android/sdk/extras/android/m2repository/com/android/support/appcompat-v7/26.1.0/appcompat-v7-26.1.0.jar
file:/Volumes/STUDY/Work/MyHome/RCTWebRTCDemo/android/sdk-manager/com/android/support/appcompat-v7/26.1.0/appcompat-v7-26.1.0.jar
Required by:
RCTWebRTCDemo:WebRTCModule:unspecified > com.facebook.react:react-native:0.56.0
* 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: 13.627 secs
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
Operating System: mac OS HighSierra 10.13.5
Android SDK: 23.0.2 & 26 installed.
Can anyone tell me how to fix this?
Thanks for your attention.
You might miss appcompat-v7:26.1.0 in your android sdk.
Try to change to 27.+. It might help!

Android chromium full browser apk build issues

I trying to build chromium android apk with this instruction
But on GN configuration step I have following problem after arguments file editing and saving
ERROR at //build/config/android/internal_rules.gni:1966:13: Script returned non-zero exit code.
exec_script("//build/android/gyp/find.py",
^----------
Current dir: /home/artem/chromium/src/out/Default/
Command: python -- /home/artem/chromium/src/build/android/gyp/find.py ../../third_party/android_tools/sdk/extras/google/google_play_services/libproject/google-play-services_lib/res
Returned 1.
stderr:
../../third_party/android_tools/sdk/extras/google/google_play_services/libproject/google-play-services_lib/res does not exist
See //build/config/android/rules.gni:634:3: whence it was called.
process_resources(process_resources_target_name) {
^-------------------------------------------------
See //third_party/android_tools/BUILD.gn:120:1: whence it was called.
android_resources("google_play_services_default_resources") {
^------------------------------------------------------------
See //base/BUILD.gn:1074:7: which caused the file to be included.
"//third_party/android_tools:cpu_features",
^-----------------------------------------
Then I try manually download google play services with command from this issue thread:
sudo ./build/android/play_services/update.py download
And get this warning:
Your version of the Google Play services library is not up to date. You might run into issues building or running the app. Please run `./build/android/play_services/update.py download` to retry downloading it.
After that I try to build full browser apk
ninja -C out/Default chrome_public_apk
and get error:
ninja: Entering directory `out/Default'
ninja: fatal: chdir to 'out/Default' - No such file or directory
Is there the way to fix this issue and build working apk file?
This works for me:
Run this command at chromium folder:
git rebase-update
gclient sync
Download google play services:
sudo ./build/android/play_services/update.py download
Configure GN: gn args opt/Full
Add this line to file: target_os="android"
Build apk with command: ninja -C opt/Full chrome_public_apk

mobile App with ionic

hello
I am trying to build hybrid app with ionic and cordova
at first i run below commands and they run successfully
but after running the last command i get this error
ionic start firtApp
cd firtApp
ionic platform add android
note: it return me android-21 error, and i changed the android-21 to android-18, and it runs successfully
ionic build android
after running the above command i got this error
BUILD FAILED
D:\New folder\android-sdk-final\android-sdk-fully\sdk\tools\ant\build.xml:601: T
he following error occurred while executing this line:
D:\New folder\android-sdk-final\android-sdk-fully\sdk\tools\ant\build.xml:542: U
nable to resolve project target 'android-21'
Total time: 1 second
C:\Users\Mohammad\firstapp\platforms\android\cordova\node_modules\q\q.js:126
throw e;
^
Error code 1 for command: cmd with args: /s /c "ant debug -f C:\Users\Mohammad\f
irstapp\platforms\android\build.xml -Dout.dir=ant-build -Dgen.absolute.dir=ant-g
en"
ERROR building one of the platforms: Error: C:\Users\Mohammad\firstapp\platforms
\android\cordova\build.bat: Command failed with exit code 8
You may not have the required environment or OS to build this project
Error: C:\Users\Mohammad\firstapp\platforms\android\cordova\build.bat: Command f
ailed with exit code 8
at ChildProcess.whenDone (C:\Users\Mohammad\AppData\Roaming\npm\node_modules
\cordova\node_modules\cordova-lib\src\cordova\superspawn.js:131:23)
at ChildProcess.emit (events.js:98:17)
at maybeClose (child_process.js:756:16)
at Process.ChildProcess._handle.onexit (child_process.js:823:5)
please help me with this error
i really like to bulid hybrid apps with my web knowledge
thanks.
You can try this
Go to this directory
C:\Users\Mohammad\.cordova\lib\npm_cache\cordova-android\3.6.4\package\framework
Edit project.properties file. Change target to 19.
# This file is automatically generated by Android Tools.
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
#
# This file must be checked in Version Control Systems.
#
# To customize properties used by the Ant build system use,
# "ant.properties", and override values to adapt the script to your
# project structure.
# Indicates whether an apk should be generated for each density.
split.density=false
# Project target.
target=android-19
apk-configurations=
renderscript.opt.level=O0
android.library=true
Restart your terminal.
You don't have SDK correctly installed on you computer. (Path or SDK update)
It's write on your error log : You may not have the required environment or OS to build this project
you just need to install ant
sudo apt-get install ant
then do the same as before,its work correctly

Build Android project on command line on OSX: Task 'assembleDebug' not found in root project

I'm trying to build Android projects on the OSX (Mavericks 10.9.5) command line using this how-to: http://developer.android.com/tools/building/building-cmdline.html.
This How-To explains the use of assembleDebug/assembleRelease to build an Android project.
Unfortunately gradle doesn't create the assembleDebug or assembleRelease targets.
Executing ./gradlew assembleDebug returns this:
FAILURE: Build failed with an exception.
* What went wrong:
Task 'assembleDebug' not found in root project 'test'.
* Try:
Run gradlew tasks to get a list of available tasks. Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 2.826 secs
Steps:
android create project
The test project has been created with android create project --path . --name "DummyAPK" --target android-21 --package com.dummyapk.dummyapk --activity DummyActivity
which returned
Created directory /Users/user/Documents/test/src/com/dummyapk/dummyapk
Added file ./src/com/dummyapk/dummyapk/DummyActivity.java
Created directory /Users/user/Documents/test/res
Created directory /Users/user/Documents/test/bin
Created directory /Users/user/Documents/test/libs
Created directory /Users/user/Documents/test/res/values
Added file ./res/values/strings.xml
Created directory /Users/user/Documents/test/res/layout
Added file ./res/layout/main.xml
Created directory /Users/user/Documents/test/res/drawable-xhdpi
Created directory /Users/user/Documents/test/res/drawable-hdpi
Created directory /Users/user/Documents/test/res/drawable-mdpi
Created directory /Users/user/Documents/test/res/drawable-ldpi
Added file ./AndroidManifest.xml
Added file ./build.xml
Added file ./proguard-project.txt
gradle init
After that I executed gradle init, which returned
:wrapper
:init
BUILD SUCCESSFUL
gradlew tasks
Querying the available tasks with gradlew tasks returns (isn't there missing something?)
:tasks
------------------------------------------------------------
All tasks runnable from root project
------------------------------------------------------------
Build Setup tasks
-----------------
init - Initializes a new Gradle build. [incubating]
wrapper - Generates Gradle wrapper files. [incubating]
Help tasks
----------
components - Displays the components produced by root project 'test'. [incubating]
dependencies - Displays all dependencies declared in root project 'test'.
dependencyInsight - Displays the insight into a specific dependency in root project 'test'.
help - Displays a help message.
projects - Displays the sub-projects of root project 'test'.
properties - Displays the properties of root project 'test'.
tasks - Displays the tasks runnable from root project 'test'.
To see all tasks and more detail, run with --all.
BUILD SUCCESSFUL
Total time: 3.474 secs
My Java version is
java version "1.7.0_60"
Java(TM) SE Runtime Environment (build 1.7.0_60-b19)
Java HotSpot(TM) 64-Bit Server VM (build 24.60-b09, mixed mode)
..and Gradle version (installed via brew) is
------------------------------------------------------------
Gradle 2.2.1
------------------------------------------------------------
Build time: 2014-11-24 09:45:35 UTC
Build number: none
Revision: 6fcb59c06f43a4e6b1bcb401f7686a8601a1fb4a
Groovy: 2.3.6
Ant: Apache Ant(TM) version 1.9.3 compiled on December 23 2013
JVM: 1.7.0_60 (Oracle Corporation 24.60-b09)
OS: Mac OS X 10.9.5 x86_64
What am I missing to be able to build an Android project on the command line?
android create project does not create a gradle friendly structure. It creates an ant friendly structure. You have two options depending on your intentions.
use ant to build your project ( not currently supported by Android team )
use Android Studio to generate a gradle friendly project structure.
num 2 is the recommended approach by the Android team. It's as simple as dl'ing Android Studio and creating a new project. From there you should be able to create a new project that can be built with ./gradlew build
try This:
./android create project -p AppPAKTGV -a Main -k com.example.apppaktgv -t android-23 -g -v 0.11.+
it's works but when i try target 24 or 25 not work i don't now
Try to do this and note
a) you need to type tools/android under Step 3 (like step 2: Execute)
-- but as said the ant structure is not helpful
-- not sure I can go from there
b) I follow the advice and also ensure get the platform-tools
-- I can build
-- I can get that .apk
-- I can adb install (I rename any existing .apk)
Seems working!

Categories

Resources