React-native-interactable: Cannot build for Android

Created on 15 Mar 2017  路  14Comments  路  Source: wix/react-native-interactable

Hi

When I run react-native run-android it fails with the error Cannot evaluate module react-native-interactable : Configuration with name 'default' not found.

Using react-native v0.42.0 and react-native-interactable v0.0.4

Most helpful comment

Hey @ryanwilliams ,
Where are you trying to run react-native run-android on ?
If this is your project trying to use react-native-interactable you must make sure that the path in settings.gradle is set correctly.

Something like this:

include ':react-native-interactable'
project(':react-native-interactable').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-interactable/android/interactable')

All 14 comments

Hey @ryanwilliams ,
Where are you trying to run react-native run-android on ?
If this is your project trying to use react-native-interactable you must make sure that the path in settings.gradle is set correctly.

Something like this:

include ':react-native-interactable'
project(':react-native-interactable').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-interactable/android/interactable')

I had the same issue.

To fix it I changed: settings.gradle:
project(':react-native-interactable').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-interactable/android/interactable') (by default after linking it was set to the android folder)

Then in node_modules/react-native-interactable/android/interactable/build.gradle I changed:

apply plugin: 'com.android.library'

android {
    compileSdkVersion 23            <--------------- Changed
    buildToolsVersion "23.0.1"            <------------ Changed
    defaultConfig {
        targetSdkVersion 23            <------------------Changed
        minSdkVersion 16            <------------Changed
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }

    testOptions {
        unitTests.all { t ->
            reports {
                html.enabled true
            }
            testLogging {
                events "passed", "skipped", "failed", "standardOut", "standardError"
            }
            afterSuite { desc, result ->
                if (!desc.parent) { // will match the outermost suite
                    def output = "      ${result.resultType} (${result.successfulTestCount} successes, ${result.failedTestCount} failures, ${result.skippedTestCount} skipped)     "
                    def repeatLength = output.length()
                    println '\n' + ('-' * repeatLength) + '\n' + output + '\n' + ('-' * repeatLength) + '\n'

                    println "see report at file://${t.reports.html.destination}/index.html"
                }
            }
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
     compile "com.android.support:appcompat-v7:23.0.1"   <-------------Changed
    testCompile 'junit:junit:4.12'

    // node_modules
    compile 'com.facebook.react:react-native:+'
}





Did you try to install it on your on project?
How did you guys install it? Manually or did you try react-native link?

I'm not a 100% sure that react-native link works well on Android

@aperreaultTRU if you can add a PR to fix the automatic linking I'll really appreciate it. I didn't play with react-native link enough.. I'm still from the old days that everything was manual

I used react-native link but after following what @aperreaultTRU suggested it builds fine now.

Thanks guys

Hi, I used react-native link and faced same problem. I try @aperreaultTRU solution, it builds fine.

Mac OS 10.12.3
Android SDK Build-tools 25.0.2 and 23.0.1 installed.

error messege:

Execution failed for task ':app:processDebugResources'.

com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '/Users/deguchi/Library/Android/sdk/build-tools/23.0.1/aapt'' finished with non-zero exit value 1

Similar problem case:
https://github.com/maxs15/react-native-spinkit/issues/21

I 'm glad if you deal with this problem. thx.

I followed @aperreaultTRU solution but I encounter this
screen shot 2017-03-20 at 5 59 14 pm

just attach my build.gradle as below:

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,
 *
 *   // 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: []
 * ]
 */

apply from: "../../node_modules/react-native/react.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.test_042"
        minSdkVersion 16
        targetSdkVersion 23
        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-interactable')
    compile project(':react-native-maps')
    compile project(':react-native-spinkit')
    compile fileTree(dir: "libs", include: ["*.jar"])
    compile "com.android.support:appcompat-v7:23.0.1"
    compile "com.facebook.react:react-native:+"  // From node_modules
}

// 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'
}

@rotemmiz thinks he can fix the react-native link on Android and then everything will hopefully work right out of the box

My fault. Build process passed after I replace

project(':react-native-interactable').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-interactable/android')

by

project(':react-native-interactable').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-interactable/android/interactable')

in the setting.gradle

@aperreaultTRU your solution worked mate. But that's not a good practice. Waiting for a new release. Hope they role out a new version soon.

The fix is a combination of (c2c6b507bda71d8256e1ed9f0636cf739be8002d) and (14592441bf84c89edff40ee93dcc42082aba7acc). and is now released in v0.0.6

react-native link should work now.

I'm using the latest version (v0.1.10) and my CI (CircleCI) wouldn't build correctly with the symlinked android folder.

I think there's an established standard directory layout for React Native packages now and react-native-interactable should just do a major update and move the files.

try to change your settings.gradle to:

project(':react-native-interactable').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-interactable/lib/android')

@uinjei That solved my issue thanks!

node_modules/react-native-interactable contained a symlink that looked like {ios,android} -> lib/{ios,android} which is not a syntax I'm familiar with. Either an error during installation where the curly braces expansion failed or some kind of syntax for symlinks I don't know about? Either way, directly pointing the settings.gradle file to ../node_modules/react-native-interactable/lib/android fixed it. I guess making a new symlink named android would do the same.

EDIT: I did not see #211 . I guess that is the appropriate answer to this problem.

Was this page helpful?
0 / 5 - 0 ratings