Реагируйте на собственную сборку Android: «ОШИБКА: не удалось получить неизвестное свойство« mergeResourcesProvider »» - PullRequest
2 голосов
/ 03 апреля 2019

Я обновил свое приложение до 0,59,3 RN, и с тех пор я получаю сообщение об ошибке при сборке Android. iOS прекрасно создает приложение.

Студия Android

ОШИБКА: не удалось получить неизвестное свойство 'mergeResourcesProvider' для объекта типа com.android.build.gradle.internal.api.ApplicationVariantImpl.

Консоль

error Could not install the app on the device, read the error above for details.
Make sure you have an Android emulator running or a device connected and have set up your Android development environment:
https://facebook.github.io/react-native/docs/getting-started.html
error Command failed: ./gradlew app:installSabdebugDebug

Я попытался изменить distributionUrl в android / app / gralde / wrapper / gradle-wrapper.propeties на

distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.2-all.zip 

и я обновил зависимости build.gradle до этих версий

dependencies {
    classpath 'com.android.tools.build:gradle:3.3.0'
    classpath 'com.google.gms:google-services:4.2.0'
    ...
}

Вот весь документ

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

buildscript {
    ext {
        minSdkVersion = 16
        compileSdkVersion = 27
        targetSdkVersion = 26
        androidMapsUtilsVersion = "0.5+"
        googlePlayServicesAuthVersion = "16.0.1"
    }

    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.3.0'
        classpath 'com.google.gms:google-services:4.2.0'


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

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

И я устанавливаю эти app / build.gradle

android {
      compileSdkVersion safeExtGet('compileSdkVersion', 28)
    buildToolsVersion safeExtGet('buildToolsVersion', '28.0.0')

    defaultConfig {
        applicationId "com.myapp"
        resValue "string", "build_config_package", "com.myapp"
        minSdkVersion 18
        multiDexEnabled true
        targetSdkVersion 26
        versionCode 24
        versionName "1.3.5"
        ndk {
            abiFilters "armeabi-v7a", "x86"
        }
    }
...

Мой пакет.json

"dependencies": {
    "babel-plugin-transform-remove-console": "^6.9.4",
    "formik": "^1.3.1",
    "lodash": "^4.17.10",
    "moment": "^2.23.0",
    "moment-timezone": "^0.5.21",
    "native-base": "^2.8.1",
    "react": "16.8.3",
    "react-native": "0.59.3",
    ....
}
"devDependencies": {
    "@babel/core": "^7.4.3",
    "@babel/runtime": "^7.4.3",
    "babel-jest": "^24.7.0",
    "jest": "^24.7.0",
    "metro-react-native-babel-preset": "^0.53.1",
    "react-test-renderer": "16.8.3",
    "run-script-os": "~1.0.5"
  },

Также мы используем сценарии для создания различных сред приложения с помощью run-script-os, но я не верю, что это вызывает проблему.

У меня также была ошибка невозможности найти Android SDK, но я решил эту проблему с помощью local.properties.

Ура!

Ответы [ 2 ]

1 голос
/ 30 апреля 2019

В gradle-wrapper.properties: изменить distributionUrl

на

distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.1-all.zip

И в корне build.gradle файл изменить путь к классу gradle к этому:

classpath 'com.android.tools.build:gradle:3.3.0'

Удалить node_modules и npm установить && реагировать на собственный запуск-Android снова.

0 голосов
/ 27 июня 2019

Редактировать: РАБОЧАЯ ВЕРСИЯ

Я обновил свое приложение до

   "react": "16.8.6",
   "react-native": "0.59.8"

android / app / gradle / wrapper / gradle-wrapper.propeties

distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.1-all.zip 

андроид / build.gradle

dependencies {
    classpath 'com.android.tools.build:gradle:3.3.0'
    classpath 'com.google.gms:google-services:4.2.0'
    ...
}

Вот весь документ

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

buildscript {
    ext {
        buildToolsVersion = "28.0.3"
        minSdkVersion = 19
        compileSdkVersion = 28
        targetSdkVersion = 28
        supportLibVersion = "28.0.0"
        appCompatVersion = "28.0.0"
        androidMapsUtilsVersion = "0.5+"

        googlePlayServicesAuthVersion = "16.0.1"
        googlePlayServicesBaseVersion = "16.1.0"
        googlePlayServicesLocationVersion = "16.0.0"
        googlePlayServicesPlacesVersion = "1.1.0"
        firebaseCoreVersion = "16.0.9"
        firebaseMessagingVersion = "18.0.0"
    }

    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.3.0'
        classpath 'com.google.gms:google-services:4.2.0'


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

allprojects {
    repositories {
        google()
        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 {
        //     // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
        //     url "https://maven.google.com"
        // }
    }
}

Android / приложение / build.gradle

android {
     compileSdkVersion safeExtGet('compileSdkVersion', 28)
    buildToolsVersion safeExtGet('buildToolsVersion', '28.0.0')

    defaultConfig {
        applicationId "com.sportjoe"
        resValue "string", "build_config_package", "com.myapp"
        minSdkVersion safeExtGet('minSdkVersion', 19)
        multiDexEnabled true
        targetSdkVersion safeExtGet( 'targetSdkVersion' , 28 )
        versionCode 34
        versionName "1.4.11"
        ndk {
            abiFilters 'armeabi-v7a','arm64-v8a','x86','x86_64'
        }
    }
...

My package.json

"dependencies": {
    "babel-plugin-transform-remove-console": "^6.9.4",
    "formik": "^1.5.4",
    "lodash": "^4.17.11",
    "moment": "^2.24.0",
    "moment-timezone": "^0.5.25",
    "native-base": "^2.12.1",
    "react": "16.8.6",
    "react-native": "0.59.8"
    ....
}
"devDependencies": {
    "babel-jest": "24.8.0",
    "babel-preset-react-native": "4.0.1",
    "jest": "24.8.0",
    "react-test-renderer": "16.8.6",
    "run-script-os": "~1.0.5"
  },

Кажется, теперь работает для меня, надеюсь, это поможет!

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...