react-native-i18n icon indicating copy to clipboard operation
react-native-i18n copied to clipboard

Will not build to Android

Open timgcarlson opened this issue 5 years ago • 6 comments

I installed the package and ran react-native link which successfully worked on iOS without any issues, but I cannot build to Android at all. When running react-native run-android, I get the following error:

Scanning folders for symlinks in /Users/timgc/Developer/ReactJS-local/adderpadjs/node_modules (13ms)
JS server already running.
Building and installing the app on the device (cd android && ./gradlew installDebug)...
File /Users/timgc/.android/repositories.cfg could not be loaded.

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring project ':app'.
> Could not resolve all dependencies for configuration ':app:_debugApk'.
   > A problem occurred configuring project ':react-native-i18n'.
      > Could not resolve all dependencies for configuration ':react-native-i18n:_debugPublishCopy'.
         > Could not find com.android.support:appcompat-v7:26.1.0.
           Searched in the following locations:
               file:/Users/timgc/Library/Android/sdk/extras/android/m2repository/com/android/support/appcompat-v7/26.1.0/appcompat-v7-26.1.0.pom
               file:/Users/timgc/Library/Android/sdk/extras/android/m2repository/com/android/support/appcompat-v7/26.1.0/appcompat-v7-26.1.0.jar
               file:/Users/timgc/Developer/ReactJS-local/adderpadjs/android/sdk-manager/com/android/support/appcompat-v7/26.1.0/appcompat-v7-26.1.0.jar
           Required by:
               adderpad:react-native-i18n:unspecified > com.facebook.react:react-native:0.56.0

I've tried using various build SDKs and still cannot get it to build.

My app/build.gradle file has the following...

android {
    compileSdkVersion 26
    buildToolsVersion "26.0.3"

    defaultConfig {
        applicationId "com.adderpad"
        minSdkVersion 16
        targetSdkVersion 26
        versionCode 1
        versionName "1.0"
        ndk {
            abiFilters "armeabi-v7a", "x86"
        }
    }

    // ...
}

dependencies {
    // ...
    compile "com.android.support:appcompat-v7:26.1.0"
}

Changing the appcompat version hasn't done anything for me. After running react-native link, I also verified that everything was linked correctly by following the manual link instructions in the README.

Is there an issue with the latest release of react-native-i8n that is causing this to not build on Android?

timgcarlson avatar Aug 12 '18 17:08 timgcarlson

Have you seen in the README it states the build tools version must be higher than what you have?

Important: You'll need to install Android build tools 27.0.3

benjaminreid avatar Aug 16 '18 13:08 benjaminreid

@benjaminreid Sorry, I should have copied my grade file when I was trying to use build tools 27.0.3, which I also could not get working. In fact, it would result in the same error message, Could not find com.android.support:appcompat-v7:26.1.0.

I downloaded the build tools in Preferences > System Settings > Android SDK > SDK Tools > Show Package Details and then uncheck all versions except 27.0.3. I then updated the app/build.gradle file to 27.0.3 but it still gave the same error verbatim.

timgcarlson avatar Aug 17 '18 17:08 timgcarlson

@timgcarlson I just had the same problem and fixed it this way:

I modified my app/build.gradle to

android {
    compileSdkVersion 27
    buildToolsVersion "27.0.3"

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

Additionally I added the Google Maven repository to my Project build.gradle:

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

buildscript {
    repositories {
        jcenter()
        maven {
            url 'https://maven.google.com/'
            name 'Google'
        }
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.2.3'

        // 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"
        }
        maven {
            url 'https://maven.google.com/'
            name 'Google'
        }
    }
}

I then ran react-native run-android again and it worked.

Mokkapps avatar Aug 27 '18 20:08 Mokkapps

Here is the solution https://github.com/AlexanderZaytsev/react-native-i18n/pull/223/commits/fa3002d062af11b16315dadcd0e2fc0d5b225a94

The PR is from andrewmarmion

Step: Use Android Studio to open your project.

The path is Android/react-native-i18n/manifests/AndroidManifest.xml

remove <uses-sdk android:minSdkVersion="16" />

The issue should be fixed.

motogod avatar Feb 23 '19 08:02 motogod

if other dev pull my work and npm install then this issue should occur again so is the latest versions remove that from manifest

punjasin avatar Jun 26 '19 04:06 punjasin