3
respostas

Erro ao configurar React Native Navigation

Boa noite,

Estou tentando realizar as configurações do react native navigation, porém estou enfrentando dificuldades.

O Android Studio Apresenta alguns erros no console na hora que dá sync:

Configuration 'compile' is obsolete and has been replaced with 'implementation' and 'api'. It will be removed at the end of 2018. For more information see: http://d.android.com/r/tools/update-dependency-configurations.html

The specified Android SDK Build Tools version (26.0.2) is ignored, as it is below the minimum supported version (27.0.3) for Android Gradle Plugin 3.1.4. Android SDK Build Tools 27.0.3 will be used. To suppress this warning, remove "buildToolsVersion '26.0.2'" from your build.gradle file, as each version of the Android Gradle Plugin now has a default version of the build tools. Update Build Tools version and sync project Open File

Configuration 'compile' is obsolete and has been replaced with 'implementation' and 'api'. It will be removed at the end of 2018. For more information see: http://d.android.com/r/tools/update-dependency-configurations.html

Configuration 'testCompile' is obsolete and has been replaced with 'testImplementation' and 'testApi'. It will be removed at the end of 2018. For more information see: http://d.android.com/r/tools/update-dependency-configurations.html

Configuration 'testApi' is obsolete and has been replaced with 'testImplementation'. It will be removed at the end of 2018. For more information see: http://d.android.com/r/tools/update-dependency-configurations.html

O meu build.gradle no IntaluraMobile está assim:

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    ext {
        buildToolsVersion = "27.0.3"
        minSdkVersion = 16
        compileSdkVersion = 27
        targetSdkVersion = 26
        supportLibVersion = "27.1.1"
    }
    repositories {
        jcenter()
        google()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.1.4'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        mavenLocal()
        jcenter()
        maven {
            // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
            url "$rootDir/../node_modules/react-native/android"
        }
        google()
    }
}


task wrapper(type: Wrapper) {
    gradleVersion = '4.4'
    distributionUrl = distributionUrl.replace("bin", "all")
}

O build.gradle do /app está assim:

android {
    compileSdkVersion 25
    buildToolsVersion '27.0.3'

    defaultConfig {
        applicationId "com.instaluramobile"
        minSdkVersion rootProject.ext.minSdkVersion
        targetSdkVersion rootProject.ext.targetSdkVersion
        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 fileTree(dir: "libs", include: ["*.jar"])
    compile "com.android.support:appcompat-v7:25.4.0"
    compile "com.facebook.react:react-native:+"
    compile project(':react-native-navigation')
}

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

O settings.gradle está assim:

rootProject.name = 'InstaluraMobile'

include ':app'
include ':react-native-navigation'
project(':react-native-navigation').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-navigation/android/app/')
3 respostas

Tentei utilizar a documentação versão 2 do React Native Navigation e tive dificuldade também!

Na v2 o erro que tive foi:

No toolchains found in the NDK toolchains folder for ABI with prefix: mips64el-linux-android

Fala Ramon, tudo bem ?

Bom, me parece que o problema está com a versão do build tools que esta sendo considerada no build da app. Conforme feito na aula onde configuramos a lib, o conteúdo de build.gradle de app deveria estar com o conteúdo como segue:

...

android {
     compileSdkVersion 25
     buildToolsVersion "25.0.1"
     ...
 }

 dependencies {
     compile fileTree(dir: "libs", include: ["*.jar"])
     compile "com.android.support:appcompat-v7:23.0.1"
     compile "com.facebook.react:react-native:+"
     compile project(':react-native-navigation')
 }

... 

Também é possível ver as alterações necessárias para configuração aqui -> https://wix.github.io/react-native-navigation/#/installation-android

Atente para a instalação da v1 da lib que é a utilizada no curso. yarn add react-native-navigation@1.x.x

Tivemos alguns reports de problemas de compatibilidade entre o react native release 0.57 e a lib react native navigation. Caso depois dos ajustes persista o problema dê uma olhada sobre qual versão do RN sua app foi criado (pode usar o comando react-native info para obter essas informações, ou olhar direto no arquivo package.json) se é mesmo a 0.57

Se for sugiro criar um novo projeto na versão 0.56 react-native init --version="0.56" NomeDoProjeto, fazer as alterações necessárias para configuração da lib e transportar seu código para o novo projeto.

Espero ter ajudado. Abraço!

Também tive problemas com a versão 0.57, a sacada de criar o projeto na versão 0.56 funcionou, mas com alguns ajustes.

  • Passar `react-native@0.56.0` na version quando cria o projeto:

react-native init --version="react-native@0.56.0" NomeDoProjetoMobile