Is there a simple way to build and deploy a Debug APK?

All the documentation, apparently, considers it both in development mode and in an attempt to switch ports for a developer device or does a production assembly! I just want to create appDebug.apk that anyone can use to launch the application without seeing errors in bridges, emitter events or AppRegistry, etc. I can’t tell others who want to see the React Native app for switching ports, etc., and I don’t want to do the full version every time I share this application. Any suggestions?

UPDATE: I do not want to debug the application. I just want to release a test assembly that works on any device, so I can share the assembly for testing.

 UPDATE: HERE IS MY PROJECT STRUCTURE:under
   main-project
   -> index.android.js
   ->gridlew
   -> build.properties
   ->build.gradle
   ->package.json
   -> my-app  (App project folder)
       -> build->output->apk->release.apk 
       ->src->main->assets
       ->src->main->res 
       ->src->main->java
+4
4

, build.grade, :

:

import com.android.build.OutputFile
// These properties must be declared above the apply below!
project.ext.react = [
    // whether to bundle JS and assets in debug mode
    bundleInDebug: true,

    // whether to bundle JS and assets in release mode
    bundleInRelease: true,

    bundleIn$releaseDebug: true  // For custom release type

  ]


 apply from: "../node_modules/react-native/react.gradle"  // adjust depending on where your node_modules directory is located.

, ext, .. build.gradle .

, .

+1

fooobar.com/questions/125313/...

.

:

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

:

cd android
./gradlew assembleDebug

..pk :

"APP" /Android/ ///APK

gradle.

:

react-native run-android
react-native start --reset-cache

cd myproject  
react-native start > /dev/null 2>&1 &  
curl "http://localhost:8081/index.android.bundle?platform=android" -o
> "android/app/src/main/assets/index.android.bundle

adb reverse tcp:8081 tcp:8081
+3

, Expo create-react-native-app?

Expo iOS Android-.

, QRCode. qrcode, -.

+2

, , RN APK.

.js

wget RN Node.JS bundle.js:

wget "http://127.0.0.1:8081/index.android.bundle?platform=android&dev=false" -O bundle.js

bundle.js

bundle.js assets/.

, RN

, (bundle.js) . . , .

build.gradle, android node, :

productFlavors {
      bundled {
          buildConfigField 'boolean', 'BUNDLED', 'true'
          buildConfigField 'String', 'DEV_HOST', "null"
      }
}

BuildConfig.java ( ):

public final class BuildConfig {
  public static final boolean DEBUG = Boolean.parseBoolean("true");
  public static final String APPLICATION_ID = "....";
  public static final String BUILD_TYPE = "debug";
  public static final String FLAVOR = "bundled";
  public static final int VERSION_CODE = ...;
  public static final String VERSION_NAME = ...;
  // Fields from product flavor: bundled
  public static final boolean BUNDLED = true;
}

RN bundle.js

, RN :

boolean bundled = BuildConfig.BUNDLED;

mReactInstanceManager = ReactInstanceManager.builder()
        .setApplication(getApplication())
        .setBundleAssetName("bundle.js")
        .setJSMainModuleName("index.android")
        .setJSBundleFile(bundled ? "assets://bundle.js" : null)
        .addPackage(new MainReactPackage(false))
        .addPackage(mInnerItemReactPackage)
        .setUseDeveloperSupport(bundled ? false : ConfigSupplier.isDebuggable())
        .setInitialLifecycleState(LifecycleState.RESUMED)
        .build();

APK

I select the correct build option on the Build Variants screen: enter image description here

And then continue, as usual, by clicking "Build → Build AIC."


I could add a more detailed blog post later.

+1
source

Source: https://habr.com/ru/post/1677335/


All Articles