React-native-onesignal: Ausführung für Task ':react-native-onesignal:processReleaseResources' fehlgeschlagen

Erstellt am 3. Juni 2018  ·  36Kommentare  ·  Quelle: OneSignal/react-native-onesignal

Beschreibung:

Die Verwendung von "react-native-onesignal": "^3.2.4" mit "react-native": "0.55.4" führt zu folgendem Build-Fehler:

Ausführung für Task ':react-native- onesignal:processReleaseResources '
Fehler: mehr als eine Bibliothek mit dem Paketnamen 'com.google.android.gms.license'

Ich habe alle Einrichtungsschritte von der offiziellen Website befolgt, einschließlich https://documentation.onesignal.com/docs/react-native-sdk-setup#section -adding-the-gradle-plugin

Wie auch im Fußzeilenkommentar von .../node_modules/react-native-onesignal/android/build.gradle , habe ich versucht, den folgenden Abschnitt am Anfang von .../android/app/build.gradle \ hinzuzufügen:-

plugins { id 'com.onesignal.androidsdk.onesignal-gradle-plugin' version '0.8.1' }

apply plugin: 'com.onesignal.androidsdk.onesignal-gradle-plugin'

aber es macht keinen Unterschied.

Hilfreichster Kommentar

Ich musste noch eine Änderung vornehmen. Ich habe distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip in gradle-wrapper.properties geändert und es hat funktioniert. CompileSdkVersion ist 23 und buildToolsVersion ist 23.0.1

Alle 36 Kommentare

@avin3sh Sie verwenden eine alte Version des OneSignal Gradle-Plugins.

Bitte versuchen Sie es mit der neuen Version, entfernen Sie bitte das alte Gradle-Plugin und fügen Sie das neue auf die gleiche Weise hinzu (am Anfang von app/build.gradle ):

buildscript {
    repositories {
        maven { url 'https://plugins.gradle.org/m2/'}
    }
    dependencies {
        classpath 'gradle.plugin.com.onesignal:onesignal-gradle-plugin:[0.10.0, 0.99.99]'
    }
}
apply plugin: 'com.onesignal.androidsdk.onesignal-gradle-plugin'

@Nightsd01 Danke für die Lösung,
Ich habe dieses Problem auch, aber es hat nicht funktioniert, der Fehler wird immer noch angezeigt

Passiert mir auch. Ich habe das neueste Gradle-Plugin ausprobiert, die Firebase-Bibliotheksversion angeheftet, während die gcm-Gruppe vom Android-Plugin ausgeschlossen wurde, und alle Firebase-Bibliotheken auf Version 15 aktualisiert, aber bisher kein Glück. Dies war der letzte Fehler, den ich erhalten habe: https://github.com/OneSignal/OneSignal-Android-SDK/issues/298 , konnte aber nicht darüber hinwegkommen.

Das ist mein react-native info . Sieht etwas fehl am Platz aus?

Environment:
  OS: macOS High Sierra 10.13
  Node: 10.3.0
  Yarn: 1.7.0
  npm: 6.1.0
  Watchman: 4.7.0
  Xcode: Not Found
  Android Studio: 2.3 AI-162.4069837

Packages: (wanted => installed)
  react: 16.3.1 => 16.3.1
  react-native: ~0.55.2 => 0.55.4

Hier gilt das gleiche. Ich bekomme auch den gleichen Fehler. Ich habe die obige Lösung versucht, aber es hat bei mir nicht funktioniert.
Kann jemand helfen ?

@Nightsd01 Ich hatte diese Zeilen bereits zu meinem build.gradle hinzugefügt, aber ich stehe immer noch vor dem Problem.

Könnten Sie (oder jemand anderes, der mit diesem Problem konfrontiert ist) uns bitte alle Abhängigkeiten mitteilen, die Sie verwenden? Sie können einfach Ihre package.json post posten

Für alle, die mit diesem Problem konfrontiert sind, kopieren Sie bitte Ihre app/build.gradle Datei und fügen Sie sie ein. Insbesondere möchten wir einige der folgenden Parameter kennen: compileSdkVersion , buildToolsVersion , minSdkVersion und targetSdkVersion

Ich habe das gleiche Problem, hier ist mein package.json

{
  "dependencies": {
    "native-base": "^2.4.3",
    "react": "16.3.2",
    "react-native": "0.55.3",
    "react-native-cookies": "^3.2.0",
    "react-native-elements": "^0.19.1",
    "react-native-haptic-feedback": "^1.1.0",
    "react-native-iphone-x-helper": "^1.0.3",
    "react-native-navigation": "^1.1.452",
    "react-native-onesignal": "^3.2.3",
    "react-native-scrollable-tab-view": "^0.8.0",
    "react-native-share": "^1.0.27",
    "react-native-vector-icons": "^4.6.0",
    "react-native-wkwebview-reborn": "^1.20.0",
    "react-native-xml2js": "^1.0.3",
    "react-redux": "^5.0.7",
    "redux": "^4.0.0",
    "redux-logger": "^3.0.6",
    "redux-persist": "^5.9.1",
    "redux-thunk": "^2.2.0",
    "rn-sliding-up-panel": "^1.2.0",
    "url-parse": "^1.4.0"
  },
  "devDependencies": {
    "babel-jest": "22.4.3",
    "babel-preset-react-native": "4.0.0",
    "jest": "22.4.3",
    "react-native-dotenv": "^0.1.1",
    "react-test-renderer": "16.3.1"
  },
  "jest": {
    "preset": "react-native"
  }
}

Hier sind die anderen Parameterdetails

compileSdkVersion 23
    buildToolsVersion "23.0.1"

    defaultConfig {
        minSdkVersion 16
        targetSdkVersion 22
        versionCode 1
        versionName "1.0"
        ndk {
            abiFilters "armeabi-v7a", "x86"
        }
    }

Ich habe meine build.gradle-Datei nicht mehr, habe aber versucht, alles auf > Version 23 oder Version 26 einzustellen und konnte keine von beiden zum Laufen bringen

Endlich diese Arbeit bekommen
durch Entfernen des https://documentation.onesignal.com/docs/react-native-sdk-setup#section -adding-the-gradle-plugin
und füge compile "com.google.android.gms:play-services-base:12.0.1" unter app/build.gradle ein

& fügen Sie google() bei android/build.gradle wie unten hinzu

buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
}
}

allprojects {
repositories {
google()
mavenLocal()
jcenter()
maven {
url "$rootDir/../node_modules/react-native/android"
}
}
}

@neo125874 Was sind Ihre compilSdkVersion- und buildToolsVersion-Versionen?

Ich musste noch eine Änderung vornehmen. Ich habe distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip in gradle-wrapper.properties geändert und es hat funktioniert. CompileSdkVersion ist 23 und buildToolsVersion ist 23.0.1

@Nightsd01

Hier ist der Inhalt meines package.json

"dependencies": {
    "native-base": "^2.3.9",
    "react": "16.3.1",
    "react-native": "0.55.4",
    "react-native-onesignal": "^3.2.4",
    "react-native-router-flux": "^4.0.0-beta.28",
    "react-native-smart-splash-screen": "^2.3.5"
  },
  "devDependencies": {
    "babel-jest": "22.4.1",
    "babel-preset-react-native": "4.0.0",
    "jest": "22.4.2",
    "react-test-renderer": "16.2.0"
  },
  "jest": {
    "preset": "react-native"
  }

Und hier ist app/build.gradle

Plugin anwenden: "com.android.application"

buildscript {
    repositories {
        maven { url 'https://plugins.gradle.org/m2/' } // Gradle Plugin Portal 
    }
    dependencies {
        classpath 'gradle.plugin.com.onesignal:onesignal-gradle-plugin:[0.10.0, 0.99.99]'
    }
}

apply plugin: 'com.onesignal.androidsdk.onesignal-gradle-plugin'
import com.android.build.OutputFile

project.ext.react = [
    entryFile: "index.js"
]

apply from: "../../node_modules/react-native/react.gradle"

def enableProguardInReleaseBuilds = false

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.1"

    //compileSdkVersion 27 //made no difference
    //buildToolsVersion "27.0.1" //made no difference

    defaultConfig {
        applicationId "com.fpapp"
        minSdkVersion 16
        targetSdkVersion 22
        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-smart-splash-screen')
    compile project(':react-native-onesignal')
    compile fileTree(dir: "libs", include: ["*.jar"])
    compile "com.android.support:appcompat-v7:23.0.1"
    compile "com.facebook.react:react-native:+"  // From node_modules
    //compile "com.google.android.gms:play-services-base:12.0.1" //github onesignal experiment
}

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

Ich habe es mit empfohlenem und standardmäßigem buildTool und CompileSdk versucht, und es hat keinen Unterschied gemacht.

@neo125874 Ihre Änderungen zusammen mit den vorgeschlagenen Änderungen von @dhamaniasad für gradle-wrapper.properties funktioniert!

@dhamaniasad Ich habe 23 oder 26 ausprobiert, könnte gut funktionieren, und freue mich zu hören, dass es funktioniert hat!
@avin3sh Glückwunsch! es scheint mit dem Google Play-Dienst etw zu tun zu haben.

@avin3sh @dhamaniasad Ich habe es wie von Ihnen vorgeschlagen versucht, aber diesen Fehler erhalten

Beim Konfigurieren des Projekts ':app' ist ein Problem aufgetreten.

Fehler beim Benachrichtigen des Projektbewertungs-Listeners.
com.android.build.gradle.tasks.factory.AndroidJavaCompile.setDependencyCacheDir(Ljava/io/File;)V

bitte helft mir das zu lösen danke im voraus

mein app/build.gradle

buildscript {
    repositories {
        maven { url 'https://plugins.gradle.org/m2/' } // Gradle Plugin Portal
    }
    dependencies {
        classpath 'gradle.plugin.com.onesignal:onesignal-gradle-plugin:[0.10.0, 0.99.99]'
    }
}

apply plugin: 'com.onesignal.androidsdk.onesignal-gradle-plugin'
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,
 *
 *   // whether to disable dev mode in custom build variants (by default only disabled in release)
 *   // for example: to disable dev mode in the staging build type (if configured)
 *   devDisabledInStaging: true,
 *   // The configuration property can be in the following formats
 *   //         'devDisabledIn${productFlavor}${buildType}'
 *   //         'devDisabledIn${buildType}'
 *
 *   // 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: []
 * ]
 */

project.ext.react = [
    entryFile: "index.js"
]

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.onesignal"
        minSdkVersion 16
        targetSdkVersion 22
        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-onesignal')
    compile fileTree(dir: "libs", include: ["*.jar"])
    compile "com.android.support:appcompat-v7:23.0.1"
    compile "com.facebook.react:react-native:+"  // From node_modules
    compile "com.google.android.gms:play-services-base:12.0.1" //github onesignal experiment
}

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

mein gradle

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

buildscript {
    repositories {
        jcenter()
        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()
        google()
        maven {
            // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
            url "$rootDir/../node_modules/react-native/android"
        }
    }
}
`

package.json
`{
  "name": "onesignal",
  "version": "0.1.0",
  "private": true,
  "devDependencies": {
    "babel-preset-react-native-stage-0": "^1.0.1",
    "jest": "^23.1.0",
    "jest-react-native": "^18.0.0",
    "react-test-renderer": "16.3.1"
  },
  "scripts": {
    "start": "react-native start",
    "android": "react-native run-android",
    "ios": "react-native run-ios",
    "test": "jest"
  },
  "jest": {
    "preset": "react-native"
  },
  "dependencies": {
    "react": "16.3.1",
    "react-native": "~0.55.2",
    "react-native-onesignal": "^3.2.4"
  }
}

@avin3sh @dhamaniasad kann ich das Repo Ihres Projekts vergleichen?

@Nightsd01 bitte helft

@davekedar haben Sie die Gradle-Wrapper-Version aktualisiert?
Wenn dies der Fall ist, müssen Sie Ihre Gradle-Dateiabhängigkeiten von . aktualisieren
classpath 'com.android.tools.build:gradle:2.2.3'
zu
classpath 'com.android.tools.build:gradle:4.4' (oder welche Version Sie verwenden)

Hier ist der Artikel, auf den ich mich bezogen habe, damit es funktioniert. https://medium.com/@chuckyong_3313/react -native-android-build-compilation-issue-with-google-play-api-for-android-v12-0-0-ccb2f1a0fb9c

@ashishmusale was ist deine Android Studio-Version? Ich habe die Studio-Version 3.1.3 aktualisiert

gradle-wrapper.properties

#Fri Jun 08 10:09:57 IST 2018
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip

app/build.gradle

buildscript {
    repositories {
        maven { url 'https://plugins.gradle.org/m2/' } // Gradle Plugin Portal
    }
    dependencies {
        classpath 'gradle.plugin.com.onesignal:onesignal-gradle-plugin:[0.10.0, 0.99.99]'
    }
}

apply plugin: 'com.onesignal.androidsdk.onesignal-gradle-plugin'

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,
 *
 *   // whether to disable dev mode in custom build variants (by default only disabled in release)
 *   // for example: to disable dev mode in the staging build type (if configured)
 *   devDisabledInStaging: true,
 *   // The configuration property can be in the following formats
 *   //         'devDisabledIn${productFlavor}${buildType}'
 *   //         'devDisabledIn${buildType}'
 *
 *   // 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: []
 * ]
 */

project.ext.react = [
    entryFile: "index.js"
]

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 27
    buildToolsVersion '27.0.3'

    defaultConfig {
        applicationId "com.nesignal"
        minSdkVersion 16
        targetSdkVersion 22
        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-onesignal')
    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'
}

android/build.gradle

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

buildscript {
    repositories {
        jcenter()
        google()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.1.3'
        classpath 'com.android.tools.build:gradle:3.0.1'
        classpath 'com.google.gms:google-services:3.2.0'

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

ext {
    googlePlayServicesVersion = '11.8.0'
    compileSdkVersion = 27
    buildToolsVersion = '27.0.3'
    supportLibrariesVersion = '27.1.0'
}
// Force sub libs to use the compile sdk & build tools version
subprojects { subproject ->
    afterEvaluate{
        if((subproject.plugins.hasPlugin('android') || subproject.plugins.hasPlugin('android-library'))) {
            android {
                compileSdkVersion rootProject.ext.compileSdkVersion
                buildToolsVersion rootProject.ext.buildToolsVersion
            }
        }
    }
}

und bekomme fehler

Firebase-messaging.jar (com.google.firebase:firebase-messaging:12.0.0) konnte nicht gefunden werden.
An folgenden Orten gesucht:
https://jcenter.bintray.com/com/google/firebase/firebase-messaging/12.0.0/firebase-messaging-12.0.0.jar

https://github.com/davekedar/onesignal-error.git Dies ist mein Repo zum Testen, können Sie bitte bei der Lösung helfen?

Danke im Voraus @ashishmusale @Nightsd01

@davekedar Ich konnte dein Projekt nicht kompilieren

@davekedar Ich habe in letzter Zeit einige Probleme festgestellt, bei denen jcenter Google-Bibliotheken nicht mehr auflöst. Ich empfehle, google() zu Ihrem Abschnitt allprojects { repositories { ... } } hinzuzufügen, der diesen Fehler beheben sollte.

allprojects {
    repositories {
        mavenLocal()
        google()
        jcenter()
        // ...
   }
}

@ashishmusale @jkasten2 Danke jetzt funktioniert es. Es wird jedoch nicht bei One Signal registriert

das ist meine app.js

import React from 'react';
import { StyleSheet, Text, View } from 'react-native';
import OneSignal from 'react-native-onesignal'; // Import package from node modules

export default class App extends React.Component {
  state = {
    device : ''
  }
  componentWillMount() {
      OneSignal.init("206a6513-b453-4807-89c1-040389fa8dea");

      OneSignal.addEventListener('received', this.onReceived);
      OneSignal.addEventListener('opened', this.onOpened);
      OneSignal.addEventListener('ids', this.onIds);
  }
  componentWillUnmount() {
      OneSignal.removeEventListener('received', this.onReceived);
      OneSignal.removeEventListener('opened', this.onOpened);
      OneSignal.removeEventListener('ids', this.onIds);
  }
  onReceived(notification) {
      console.log("Notification received: ", notification);
  }
  onOpened(openResult) {
    console.log('Message: ', openResult.notification.payload.body);
    console.log('Data: ', openResult.notification.payload.additionalData);
    console.log('isActive: ', openResult.notification.isAppInFocus);
    console.log('openResult: ', openResult);
  }
  onIds(device) {
        this.setState({device: device})
  }
  render() {
    return (
      <View style={styles.container}>
        <Text>Open up App.js to start working on your app!</Text>
        <Text>Changes you make will automatically reload.</Text>
        <Text>Shake your phone to open the developer menu.</Text>
        <Text>Device Info : {this.state.device}</Text>
      </View>
    );
  }
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    backgroundColor: '#fff',
    alignItems: 'center',
    justifyContent: 'center',
  },
});

@ashishmusale Ich habe die endgültige kompilierte Version übergeben, wenn Sie nachsehen können

Alles erfolgreich gemacht Danke euch allen

Froh das zu hören!

Kann mir jemand ein vollständig konfiguriertes Projekt geben, das gut funktioniert .... ich stecke seit 2 Tagen fest. bei mir funktioniert nichts.....................plz

@nahidmbstu sag mir, wo du feststeckst, es gibt sehr seltsame Probleme mit jedem, lass uns versuchen, es für dich zu lösen

ich bin ein gcm lincence error on 3.1.4 und wenn ich das Beispielprojekt aus diesem Repository versuche, funktioniert es nicht ..... ich brauche ein konfiguriertes Projekt mit funktionierender Benachrichtigung ...

Push-Token null abrufen............ auf Geräte-ID. @davekedar . Es wird auch ein Fehler bei der Initialisierung des Google Play-Dienstes auf einem Signal-Dashboard angezeigt.

@nahidmbstu haben Sie versucht, ein neues, frisches Projekt zu erstellen?

Danke, ich hatte ein Problem mit dem Google Play-Dienst, das ist der Grund dafür. Ich habe es gelöst, indem ich folge
https://github.com/geektimecoil/react-native-onesignal/issues/387

@nahidmbstu wunderbar

War diese Seite hilfreich?
0 / 5 - 0 Bewertungen