React-native-config: FIXED (CAUSED BY INADEQUATE DOCUMENTATION) on run, I get error: package com.lugg.ReactNativeConfig does not exist

Created on 22 Feb 2018  Â·  4Comments  Â·  Source: luggit/react-native-config

{
"name": "kiosk",
"version": "0.0.1",
"private": true,
"scripts": {},
"dependencies": {
"axios": "0.17.0",
"babel-eslint": "7.2.3",
"eslint": "3.19.0",
"eslint-config-airbnb": "6.0.0",
"eslint-plugin-import": "2.8.0",
"eslint-plugin-react": "3.12.0",
"estraverse-fb": "1.3.2",
"fuse.js": "^3.2.0",
"mobx": "3.3.1",
"mobx-react": "4.3.4",
"react": "16.0.0",
"react-native": "0.50.x",
"react-native-config": "^0.11.5",
"react-native-device-log": "^1.0.2",
"react-native-keep-awake": "^2.0.6",
"react-native-loading-spinner-overlay": "^0.5.2",
"react-native-modal": "^4.1.1",
"react-native-restart": "0.0.6",
"react-native-swiper": "^1.5.13",
"react-native-vector-icons": "^4.4.2",
"react-navigation": "1.0.0-beta.17",
"to-fast-properties": "^2.0.0",
"uuid": "^3.1.0"
},
"devDependencies": {
"babel-plugin-transform-decorators-legacy": "^1.3.4"
},
"rnpm": {
"assets": [
"./src/assets/fonts/"
]
}
}

===============================================

package com.kiosk;

import android.app.Application;

import com.facebook.react.ReactApplication;
import com.lugg.ReactNativeConfig.ReactNativeConfigPackage;
import com.avishayil.rnrestart.ReactNativeRestartPackage;
import com.corbt.keepawake.KCKeepAwakePackage;
import com.oblador.vectoricons.VectorIconsPackage;
import com.facebook.react.ReactNativeHost;
import com.facebook.react.ReactPackage;
import com.facebook.react.shell.MainReactPackage;
import com.facebook.soloader.SoLoader;

import java.util.Arrays;
import java.util.List;

public class MainApplication extends Application implements ReactApplication {

private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) {
@Override
public boolean getUseDeveloperSupport() {
return BuildConfig.DEBUG;
}

@Override
protected List<ReactPackage> getPackages() {
  return Arrays.<ReactPackage>asList(
      new MainReactPackage(),
        new ReactNativeConfigPackage(),
        new ReactNativeRestartPackage(),
        new KCKeepAwakePackage(),
        new VectorIconsPackage()
  );
}

@Override
protected String getJSMainModuleName() {
  return "index";
}

};

@Override
public ReactNativeHost getReactNativeHost() {
return mReactNativeHost;
}

@Override
public void onCreate() {
super.onCreate();
SoLoader.init(this, /* native exopackage */ false);
}
}

===========================================

apply plugin: "com.android.application"
import com.android.build.OutputFile

/**

  • The react.gradle file registers a task for each build variant (e.g. bundleDebugJsAndAssets
  • and bundleReleaseJsAndAssets).
  • These basically call react-native bundle with the correct arguments during the Android build
  • cycle. By default, bundleDebugJsAndAssets is skipped, as in debug/dev mode we prefer to load the
  • bundle directly from the development server. Below you can see all the possible configurations
  • and their defaults. If you decide to add a configuration block, make sure to add it before the
  • apply from: "../../node_modules/react-native/react.gradle" line.
    *
  • project.ext.react = [
  • // the name of the generated asset file containing your JS bundle
  • bundleAssetName: "index.android.bundle",
    *
  • // the entry file for bundle generation
  • entryFile: "index.android.js",
    *
  • // whether to bundle JS and assets in debug mode
  • bundleInDebug: false,
    *
  • // whether to bundle JS and assets in release mode
  • bundleInRelease: true,
    *
  • // whether to bundle JS and assets in another build variant (if configured).
  • // See http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Build-Variants
  • // The configuration property can be in the following formats
  • // 'bundleIn${productFlavor}${buildType}'
  • // 'bundleIn${buildType}'
  • // bundleInFreeDebug: true,
  • // bundleInPaidRelease: true,
  • // bundleInBeta: true,
    *
  • // whether to disable dev mode in custom build variants (by default only disabled in release)
  • // for example: to disable dev mode in the staging build type (if configured)
  • devDisabledInStaging: true,
  • // The configuration property can be in the following formats
  • // 'devDisabledIn${productFlavor}${buildType}'
  • // 'devDisabledIn${buildType}'
    *
  • // the root of your project, i.e. where "package.json" lives
  • root: "../../",
    *
  • // where to put the JS bundle asset in debug mode
  • jsBundleDirDebug: "$buildDir/intermediates/assets/debug",
    *
  • // where to put the JS bundle asset in release mode
  • jsBundleDirRelease: "$buildDir/intermediates/assets/release",
    *
  • // where to put drawable resources / React Native assets, e.g. the ones you use via
  • // require('./image.png')), in debug mode
  • resourcesDirDebug: "$buildDir/intermediates/res/merged/debug",
    *
  • // where to put drawable resources / React Native assets, e.g. the ones you use via
  • // require('./image.png')), in release mode
  • resourcesDirRelease: "$buildDir/intermediates/res/merged/release",
    *
  • // by default the gradle tasks are skipped if none of the JS files or assets change; this means
  • // that we don't look at files in android/ or ios/ to determine whether the tasks are up to
  • // date; if you have any other folders that you want to ignore for performance reasons (gradle
  • // indexes the entire tree), add them here. Alternatively, if you have JS files in android/
  • // for example, you might want to remove it from here.
  • inputExcludes: ["android/", "ios/"],
    *
  • // override which node gets called and with what additional arguments
  • nodeExecutableAndArgs: ["node"],
    *
  • // supply additional arguments to the packager
  • extraPackagerArgs: []
  • ]
    */

project.ext.react = [
entryFile: "index.js"
]

apply from: "../../node_modules/react-native/react.gradle"
apply from: project(':react-native-config').projectDir.getPath() + "/dotenv.gradle"

/*
Include Icon Libraries
(Added by JG)
*/
project.ext.vectoricons = [

iconFontNames: [ 'FontAwesome.ttf', 'Ionicons.ttf'  ]

]
apply from: "../../node_modules/react-native-vector-icons/fonts.gradle"

/**

  • Set this to true to create two separate APKs instead of one:

    • An APK that only works on ARM devices


    • An APK that only works on x86 devices

  • The advantage is the size of the APK is reduced by about 4MB.
  • Upload all the APKs to the Play Store and people will download
  • the correct one based on the CPU architecture of their device.
    */
    def enableSeparateBuildPerCPUArchitecture = false

/**

  • Run Proguard to shrink the Java bytecode in release builds.
    */
    def enableProguardInReleaseBuilds = false

android {
compileSdkVersion 23
buildToolsVersion "23.0.1"

defaultConfig {
    applicationId "com.kiosk"
    minSdkVersion 16
    targetSdkVersion 22
    versionCode 1
    versionName "1.0"
    ndk {
        abiFilters "armeabi-v7a", "x86"
    }
}
splits {
    abi {
        reset()
        enable enableSeparateBuildPerCPUArchitecture
        universalApk false  // If true, also generate a universal APK
        include "armeabi-v7a", "x86"
    }
}
buildTypes {
    release {
        minifyEnabled enableProguardInReleaseBuilds
        proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
    }
}
// applicationVariants are e.g. debug, release
applicationVariants.all { variant ->
    variant.outputs.each { output ->
        // For each separate APK per architecture, set a unique version code as described here:
        // http://tools.android.com/tech-docs/new-build-system/user-guide/apk-splits
        def versionCodes = ["armeabi-v7a":1, "x86":2]
        def abi = output.getFilter(OutputFile.ABI)
        if (abi != null) {  // null for the universal-debug, universal-release variants
            output.versionCodeOverride =
                    versionCodes.get(abi) * 1048576 + defaultConfig.versionCode
        }
    }
}

}

dependencies {
compile project(':react-native-restart')
compile project(':react-native-keep-awake')
compile project(':react-native-vector-icons')
compile fileTree(dir: "libs", include: ["*.jar"])
compile "com.android.support:appcompat-v7:23.0.1"
compile "com.facebook.react:react-native:+" // From node_modules

// For animated GIF support
compile 'com.facebook.fresco:animated-gif:1.3.0'
}

// Run this once to be able to run the application with BUCK
// puts all compile dependencies into folder libs for BUCK to use
task copyDownloadableDepsToLibs(type: Copy) {
from configurations.compile
into 'libs'
}

Most helpful comment

React-Native 0.50.x

Me too, after very much trial and error, do this:

npm install --save react-native-config
react-native link (optionally add the pkg name above, but don't have to)
=> You might notice that this command hangs and never actually finishes running
=> I had to terminate the process with Ctrl+c
=> This command altered some files, including MainApplication.java and settings.gradle
=> BUT it DID NOT update an important file
=> YOU must update this file by hand
Open android/app/build.gradle (which was not altered by the react-native link command and SHOULD HAVE BEEN)
=> line 2, immediately after apply plugin: "com.android.application"
=> add this line apply from: project(':react-native-config').projectDir.getPath() + "/dotenv.gradle"
=> THEN edit the dependencies method like so:

dependencies {
    compile project(':react-native-config')
    ...
    ==> Other projects you depend on
    ...
    compile "com.facebook.react:react-native:+"  
}

NOTE: This last piece of information is NOT contained within this library's documentation!

After all this, please be sure to run ./gradlew clean before opening your emulator and calling react-native run-android

All 4 comments

React-Native 0.50.x

Me too, after very much trial and error, do this:

npm install --save react-native-config
react-native link (optionally add the pkg name above, but don't have to)
=> You might notice that this command hangs and never actually finishes running
=> I had to terminate the process with Ctrl+c
=> This command altered some files, including MainApplication.java and settings.gradle
=> BUT it DID NOT update an important file
=> YOU must update this file by hand
Open android/app/build.gradle (which was not altered by the react-native link command and SHOULD HAVE BEEN)
=> line 2, immediately after apply plugin: "com.android.application"
=> add this line apply from: project(':react-native-config').projectDir.getPath() + "/dotenv.gradle"
=> THEN edit the dependencies method like so:

dependencies {
    compile project(':react-native-config')
    ...
    ==> Other projects you depend on
    ...
    compile "com.facebook.react:react-native:+"  
}

NOTE: This last piece of information is NOT contained within this library's documentation!

After all this, please be sure to run ./gradlew clean before opening your emulator and calling react-native run-android

compile project(':react-native-config')

That was the most important part. Thank's a lot

Cool, glad you got something out of it!

On Mon, Nov 12, 2018 at 12:05 PM Andrei notifications@github.com wrote:

compile project(':react-native-config')

That was the most important part. Thank's a lot

—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
https://github.com/luggit/react-native-config/issues/228#issuecomment-437957040,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AX29FTRZkT_z3DMEuFotLTgNQfVsEhcUks5uuapbgaJpZM4SPvZk
.

I've tried all these with updated implement instead of compile but it still doesn't work for me

It always says :react-native-config doesnt exist in :app

Was this page helpful?
0 / 5 - 0 ratings