Importing a response project in android studio

I have a little problem opening / importing an interactive version into Android studio.

  • If I open a project using the project open dialog, it tells me that the project is not enabled by gradle, and it is painful to make and test code changes. It was not possible to figure out how to include the project as a gradle project after the fact, even after going through the material on the help site.
  • On the other hand, if I import the gradle project dialog with the import and select the build.gradle file, the project is imported, but I see only the files inside the android directory, and not the main project directory. But this method allows me to easily change changes to the emulator.

    How can I fix my problem?

Thank,

+4
source share
1 answer

Just import the android directory from Android Studio, make changes to the application /build.gradle add these codes to from: "../../node_modules/react-native/react.gradle"

project.ext.react = [
        bundleAssetName: "index.android.bundle",
        entryFile: "index.android.js",
        bundleInDebug: false,
        bundleInRelease: true,
        root: "../../",
        jsBundleDirDebug: "$buildDir/intermediates/assets/debug",
        jsBundleDirRelease: "$buildDir/intermediates/assets/release",
        resourcesDirDebug: "$buildDir/intermediates/res/merged/debug",
        resourcesDirRelease: "$buildDir/intermediates/res/merged/release",
        inputExcludes: ["android/", "ios/"],
        nodeExecutableAndArgs: ["node"],
        extraPackagerArgs: []
]

Now create a task for "action-native start" for your gradle

task startReactNative(type: Exec) {
    workingDir "../../"
    commandLine  'cmd', '/c', 'react-native', 'start'
    println "Working Directory for React is: $workingDir"
    standardOutput = new ByteArrayOutputStream()
    ext.output = {
        println "React-Native Output: " + standardOutput.toString()
        return standardOutput.toString()
    }
}

You can start your application as usual, after the application is installed on your device, run the startReactNative task to activate Hot Reload

+2
source

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


All Articles