React-native-onesignal: Fehler in der Bibliothek der Google Play-Dienste

Erstellt am 21. Mai 2018  ·  37Kommentare  ·  Quelle: OneSignal/react-native-onesignal

Beschreibung:

Das registrierte Gerät gibt einen Fehler im OneSignal-Dashboard zurück und kann daher keine Push-Benachrichtigungen empfangen.

Umfeld

react-native -v
react-native-cli: 2.0.1
react-native: 0.55.4

Paket.json

"dependencies": {
    "react": "16.3.1",
    "react-native": "0.55.4",
    "react-native-onesignal": "^3.2.3"
  }

Schritte zum Reproduzieren des Problems:

  1. React-native init OneSignalTest
  2. CD OneSignalTest
  3. Garn installieren
  4. garn hinzufügen reagieren-native-einsignal
  5. React-nativer Link
  6. Folgen Sie: https://documentation.onesignal.com/docs#section -android-specific-instructions
  7. Fügen Sie auf android/app/build.gradle compile project(':react-native-onesignal') für Abhängigkeiten ein. Es kann ohne diese Abhängigkeit nicht kompiliert werden.
  8. Fügen Sie in der App.js-Klasse die Listener ein: https://documentation.onesignal.com/docs#section -usage
  9. Fügen Sie auf ComponentWillMount dieses OneSignal.configure(); um eine Rückgabe von onIds zu erzwingen.
    Löschen Sie im Ids Listener die Klassenmethode und erstellen Sie eine lokale Methode, damit wir die ID sehen können.
    Wenn wir es nicht taten, würde das Es nie zurückkehren
OneSignal.addEventListener('ids', device => {
      console.log('[OneSignal]>>ids: ', device);
    });

Geben Sie auf Init Ihre App-ID ein.

  1. dann: Reagieren-natives Ausführen-Android.
    (Auf adb logcat wird ein Fehler zurückgegeben, aber Sie sehen die ID im Debug-Modus.)
  2. Suchen Sie die ID auf dem OneSignal Dashboard und da ist sie.

Noch etwas:

E/OneSignal(31234): Unknown error getting FCM Token
E/OneSignal(31234): java.lang.NoSuchMethodError: No static method isDeviceProtectedStorage(Landroid/content/Context;)Z in class Landroid/support/v4/content/ContextCompat; or its super classes (declaration of 'android.support.v4.content.ContextCompat' appears in /data/app/com.onesignaltest-1/base.apk)
E/OneSignal(31234):     at com.google.firebase.FirebaseApp.zza(Unknown Source)
E/OneSignal(31234):     at com.google.firebase.FirebaseApp.initializeApp(Unknown Source)
E/OneSignal(31234):     at com.onesignal.PushRegistratorFCM.initFirebaseApp(PushRegistratorFCM.java:64)
E/OneSignal(31234):     at com.onesignal.PushRegistratorFCM.getToken(PushRegistratorFCM.java:50)
E/OneSignal(31234):     at com.onesignal.PushRegistratorAbstractGoogle.attemptRegistration(PushRegistratorAbstractGoogle.java:97)
E/OneSignal(31234):     at com.onesignal.PushRegistratorAbstractGoogle.access$100(PushRegistratorAbstractGoogle.java:37)
E/OneSignal(31234):     at com.onesignal.PushRegistratorAbstractGoogle$1.run(PushRegistratorAbstractGoogle.java:84)
E/OneSignal(31234):     at java.lang.Thread.run(Thread.java:818)

googleplayserviceserror

Bearbeiten 1:
Ich habe versucht, dies zu tun, aber ohne Erfolg:

Hilfreichster Kommentar

@brunoandradebr @DaniloCouto @ifanfaizal Ich repariere, ich ändere sdkVersion und Version appcompat

Änderungen:
app/build.gradle

compileSdkVersion 26
buildToolsVersion "26.0.2"

In Abhängigkeiten
Veränderung
compile "com.android.support:appcompat-v7:23.0.1"
zu
compile "com.android.support:appcompat-v7:26.0.1"

Mein build.gradle (Android)

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

buildscript {
    repositories {
        jcenter()
        maven {  // <-- THIS
            url 'https://maven.google.com/' // <-- THIS
            name 'Google' // <-- THIS
        } // <-- THIS
    }
    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 { // <-- THIS
            url 'https://maven.google.com/' // <-- THIS
            name 'Google' // <-- THIS
        } // <-- THIS
    }
}

In cmd: cd android && gradlew clean

App von meinem AVD deinstallieren und mit React-Native kompilieren

Alle 37 Kommentare

@DaniloCouto Dies ist definitiv ein Problem mit der Version der Android-Supportbibliothek. Kannst du deine app/build.gradle posten?

@DaniloCouto überprüfen Sie die neue Version 3.2.4, sie beheben es.

@adirzoari , passiert immer noch auf 3.2.4, mit den gleichen Fehlern auf Adb logcat und auf Onesignal User Dashboard.
yarn add [email protected]
Paket.json

"dependencies": {
    "react": "16.3.1",
    "react-native": "0.55.4",
    "react-native-onesignal": "3.2.4"
  },

@ Nightsd01 Klar, hier ist es:
app/build.gradle (Ich habe die generierten Kommentare gelöscht)

apply plugin: "com.android.application"

import com.android.build.OutputFile

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

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

def enableSeparateBuildPerCPUArchitecture = false

def enableProguardInReleaseBuilds = false

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.1"

    defaultConfig {
        applicationId "com.onesignaltest"
        minSdkVersion 16
        targetSdkVersion 22
        versionCode 1
        versionName "1.0"
        ndk {
            abiFilters "armeabi-v7a", "x86"
        }
    }
    splits {
        abi {
            reset()
            enable enableSeparateBuildPerCPUArchitecture
            universalApk false 
            include "armeabi-v7a", "x86"
        }
    }
    buildTypes {
        release {
            minifyEnabled enableProguardInReleaseBuilds
            proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
        }
    }
    applicationVariants.all { variant ->
        variant.outputs.each { output ->
            def versionCodes = ["armeabi-v7a":1, "x86":2]
            def abi = output.getFilter(OutputFile.ABI)
            if (abi != null) { 
                output.versionCodeOverride =
                        versionCodes.get(abi) * 1048576 + defaultConfig.versionCode
            }
        }
    }
}

dependencies {
    compile project(':react-native-onesignal') // I just added this line 
    compile fileTree(dir: "libs", include: ["*.jar"])
    compile "com.android.support:appcompat-v7:23.0.1"
    compile "com.facebook.react:react-native:+" 
}

task copyDownloadableDepsToLibs(type: Copy) {
    from configurations.compile
    into 'libs'
}

Bearbeiten 1:
Ich habe diese am Anfang der Datei hinzugefügt. Nichts hat sich verändert:

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'
...
...
...
android {
    compileSdkVersion 26
    buildToolsVersion "26.0.1"
    ...
    ...
}

Natürlich habe ich das Android-Projekt mit gradlew clean gesäubert und versucht neu zu erstellen.

@DaniloCouto Verwenden Sie nur das Projekt „react-native-onesignal example “ …?

Kannst du auch deine AndroidManifest.xml Datei posten? Danke

@ Nightsd01 Ich habe ein neues React-Native-Projekt erstellt und das React-Native-Onesignal-Paket über Yarn hinzugefügt.

Hier ist es:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.onesignaltest">

    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/> <!-- Onesignal Instruction -->
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/> <!-- Onesignal Instruction -->

    <application
      android:name=".MainApplication"
      android:label="@string/app_name"
      android:icon="@mipmap/ic_launcher"
      android:allowBackup="false"
      android:theme="@style/AppTheme"
      > <!-- android:launchMode="singleTop" I Was wrong at this line-->
      <activity
        android:name=".MainActivity"
        android:label="@string/app_name"
        android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
        android:windowSoftInputMode="adjustResize"
        android:launchMode="singleTop"> <!-- brunoandradebr made a pretty nice observation right here -->
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
      </activity>
      <activity android:name="com.facebook.react.devsupport.DevSettingsActivity" />
    </application>

</manifest>

Bearbeiten 1:
Nach Lösung Nr. 387 habe ich diese Zeile hinzugefügt. Nichts hat sich verändert

<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE"/>

Bearbeiten 2:
Wie auch von @brunoandradebr beobachtet, müssen die android:launchMode="singleTop" auf dem Aktivitäts-Tag und nicht auf dem Anwendungs-Tag stehen.
Aber es geht immer noch nicht..

Dasselbe Problem hier, @DaniloCouto , hast du es behoben???

Ich habe das gleiche Problem. @DaniloCouto hast du es geschafft, es zu beheben? Ich habe überall danach gesucht und immer noch keine Werke :(

@ifanfaizal , @lahed Tut mir leid, das zu hören, aber ich bin auch hier, um eine Lösung zu finden ...
Ich habe versucht, denen zu folgen, ohne Erfolg:

Danilo, du sollst einfügen
android:launchMode="singleTop"
Innerhalb des Aktivitätskontexts nicht in der Anwendung als Einsignalanweisung.
Übrigens funktioniert es nicht so gut =[

@brunoandradebr Gut beobachtet mein Landsmann.
Wie gesagt, es funktioniert immer noch nicht.

compile "com.google.android.gms:play-services-gcm:+"

Nach der Installation des Google Play Service vom Android Studio SDK Manager zur Abhängigkeit hinzugefügt und irgendwie funktioniert, aber die App ist abgestürzt, dann habe ich die Onesignal-Benutzerliste aktualisiert und der Fehler bleibt bestehen =[

Ich denke, es funktioniert jetzt! Ich habe Google Play Service von Android Studio installiert, es soll keine Zeile einfügen, Sie müssen das Bundle schließen und erneut kompilieren. Abonniert wird mit einem Häkchen angezeigt! Ich habe nicht einmal zusätzliche Zeilen von onesignal eingefügt, es ist die gleiche Art und Weise, wie React Native erstellt hat.

@brunoandradebr @DaniloCouto @ifanfaizal Ich repariere, ich ändere sdkVersion und Version appcompat

Änderungen:
app/build.gradle

compileSdkVersion 26
buildToolsVersion "26.0.2"

In Abhängigkeiten
Veränderung
compile "com.android.support:appcompat-v7:23.0.1"
zu
compile "com.android.support:appcompat-v7:26.0.1"

Mein build.gradle (Android)

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

buildscript {
    repositories {
        jcenter()
        maven {  // <-- THIS
            url 'https://maven.google.com/' // <-- THIS
            name 'Google' // <-- THIS
        } // <-- THIS
    }
    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 { // <-- THIS
            url 'https://maven.google.com/' // <-- THIS
            name 'Google' // <-- THIS
        } // <-- THIS
    }
}

In cmd: cd android && gradlew clean

App von meinem AVD deinstallieren und mit React-Native kompilieren

@lahed Aaahhh es funktioniert Bruder!! 💃 vielen Dank für deine Lösung.. Ich habe 3 Tage damit verbracht, es zum Laufen zu bringen, aber überhaupt keine Ergebnisse.. und heute rettest du mir einfach das Leben 😃

@lahed , funktioniert wie ein Zauber, danke.
Ich schätze, es ist geschlossen ...?
Welches OneSignal-Team könnte dagegen vorgehen?
Ein verbesserter React-Native-Link ?

@lahed ty, seine Arbeit

Ich habe 2 Projekte mit einem Signal
Projekt 1 benötigt keine OneSignal.init
aber Projekt 2 muss OneSignal.init
jeder kann es erklären?

@stevanus1997 Vielleicht haben Sie die Init-Datei bereits in build.gradle in Projekt 2 (?) definiert (mit anderen Worten, Sie haben die OneSignal-Init-Datei auf eine ältere Weise definiert), sodass Sie in App.js nicht erneut initieren mussten

Projekt 1

defaultConfig {
        applicationId "com.xxxxx"
        minSdkVersion 16
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
        ndk {
            abiFilters "armeabi-v7a", "x86"
        }
        manifestPlaceholders = [
               onesignal_app_id: "xxxxxxxxx",
               onesignal_google_project_number: "xxxxxxxxx"
       ]
    }

Projekt 2

defaultConfig {
        applicationId "com.xxxx"
        minSdkVersion 16
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
        ndk {
            abiFilters "armeabi-v7a", "x86"
        }
        manifestPlaceholders = [
                onesignal_app_id               : "xxxxx",
                onesignal_google_project_number: "xxxxx"
        ]
        multiDexEnabled true
    }

@ifanfaizal das ist mein build.gradle

@lahed vielen Dank. Jetzt funktioniert es wie am Schnürchen...!!!

Ich habe die Lösung von @lahed befolgt , aber ich erhalte immer noch den gleichen Fehler vom Dashboard von OneSignal ... könnte mir jemand seine festen android/build.gradle und android/app/build.gradle zeigen?

Versuchen Sie, den Compiler zu schließen und erneut zu kompilieren.

Schon mehrfach gemacht 😕

Haben Sie Google Play Service mit Android Studio installiert?

Yup, die neueste Version davon, ich laufe auf Android 8.0

android/app/build.gradle :

apply plugin: "com.android.application"
apply plugin: 'com.onesignal.androidsdk.onesignal-gradle-plugin'

import com.android.build.OutputFile

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

def enableSeparateBuildPerCPUArchitecture = false
def enableProguardInReleaseBuilds = false

android {
    compileSdkVersion 27
    buildToolsVersion "27.0.2"

    defaultConfig {
        applicationId "xxx"
        minSdkVersion 16
        targetSdkVersion 27
        versionCode 31
        versionName "0.3.0"
        multiDexEnabled true
        vectorDrawables.useSupportLibrary = true
        ndk {
            abiFilters "armeabi-v7a", "x86"
        }
        manifestPlaceholders = [manifestApplicationId: "${applicationId}",
                                onesignal_google_project_number: "xxx"]
    }
    signingConfigs {
        release {
            if (project.hasProperty('MYAPP_RELEASE_STORE_FILE')) {
                storeFile file(MYAPP_RELEASE_STORE_FILE)
                storePassword MYAPP_RELEASE_STORE_PASSWORD
                keyAlias MYAPP_RELEASE_KEY_ALIAS
                keyPassword MYAPP_RELEASE_KEY_PASSWORD
            }
        }
    }
    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"
            signingConfig signingConfigs.release
        }
    }
    // 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
            }
        }
    }
}

repositories {
    maven { url "https://jitpack.io" }
}

dependencies {
    compile project(':react-native-image-picker')
    compile(project(':react-native-maps')){
        exclude group: 'com.google.android.gms', module: 'play-services-base'
        exclude group: 'com.google.android.gms', module: 'play-services-maps'
    }
    compile 'com.google.android.gms:play-services-base:+'
    compile 'com.google.android.gms:play-services-maps:+'
    compile project(':react-native-svg')
    compile project(':react-native-dialogs')
    compile project(':react-native-onesignal')
    compile fileTree(dir: "libs", include: ["*.jar"])
    compile project(':react-native-vector-icons')
    compile project(':react-native-i18n')
    compile project(':react-native-fetch-blob')
    compile (project(':react-native-camera')) {
        exclude group: "com.android.support"
        exclude group: "com.google.android.gms"
    }
    compile ("com.google.android.gms:play-services-vision:+") {
        force = true;
    }
    compile ('com.android.support:exifinterface:27.0.2') {
        force = true;
    }
    compile "com.android.support:appcompat-v7:27.0.2"
    compile 'com.android.support:support-vector-drawable:27.0.2'
    compile 'com.android.support:animated-vector-drawable:27.0.2'
    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()
        maven {
            url 'https://maven.google.com/'
            name 'Google'
        }
        maven { url 'https://plugins.gradle.org/m2/' }
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.2.3'
        classpath 'gradle.plugin.com.onesignal:onesignal-gradle-plugin:[0.10.1, 0.99.99]'
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        mavenLocal()
        jcenter()
        maven { url "$rootDir/../node_modules/react-native/android" }
        maven {
            url "https://maven.google.com"
            name 'Google'
        }
        maven { url "https://jitpack.io" }
    }
}

Entfernen Sie in einer Signalliste das tatsächliche Gerät Option > Löschen, deinstallieren Sie die Debug-App und kompilieren Sie sie erneut.

+1 keine OnIds mit Init-Aufruf von React Native js erhalten

@ congnguyen91 Das wird erwartet. Das Ereignis onIds wird nur ausgelöst, wenn sich der Abonnementstatus (IDs) tatsächlich ändert.

Wenn Sie onIds zum Auslösen zwingen möchten, können Sie nach der Initialisierung OneSignal.configure() aufrufen. Das ist verwirrend, ich weiß, es ist ein Vermächtnis. Wir werden in der nächsten Hauptversion umgestalten, um dies weniger verwirrend zu machen.

Hi @lahed , sehe ich deine vorgeschlagenen Änderungen richtig https://github.com/geektimecoil/react-native-onesignal/issues/525#issuecomment -392224930, die min. erforderlich compileSdkVersion und buildToolsVersion ist jetzt 26 (was Android 8.0 bedeutet)? (was mit den Hinweisen in der Einrichtungsanleitung übereinstimmt: https://documentation.onesignal.com/v5.0/docs/react-native-sdk-setup#section-adding-the-gradle-plugin).

Bedeutet dies, dass Android 6.x nicht mehr unterstützt wird, weil meine aktuellen compileSdkVersion und buildToolsVersion 23 und 23.0.2 sind.

Danke für Ihre Hilfe!

@natterstefan Bin ich ziemlich sicher nicht. Diejenige, die die niedrigeren Geräte definiert, ist minSdkVersion, also sollte alles perfekt funktionieren, es sei denn, eine native API wird nicht unterstützt. Ich habe es auf Android 4.4 getestet und es funktioniert gut

habe ich hier gelöst....
Ich habe die Google Play Services-Pakete und Onesignal nacheinander deinstalliert.
Danach habe ich onesignal installiert und alles funktioniert jetzt.
Ps: Schauen Sie in den Archiven nach, die nach dem Build erstellt wurden, und überprüfen Sie, ob die Google Play Services-DLL dort ist.
P2s: Ich verwende Onesignal mit xamarin-Anwendungen.

Wir haben unsere Dokumentation aktualisiert, um sicherzustellen, dass compileSdkVersion und buildToolsVersion 26+ sind.
https://documentation.onesignal.com/docs/react-native-sdk-setup#section -adding-the-gradle-plugin

Dies ist eines der Dinge, die @lahed in https://github.com/geektimecoil/react-native-onesignal/issues/525#issuecomment -392224930 vorgeschlagen hat.

Der andere neue Teil ist das Hinzufügen des OneSignal Gradle-Plugins zu Ihrem Projekt. Damit müssen Sie appcompat-v7 in Ihrem app/build.gradle nicht manuell aktualisieren und lösen Probleme mit widersprüchlichen Versionen in anderen Plugins.

Stellen Sie sicher, dass Sie dem neuen Adding the Gradle Plugin -Abschnitt gefolgt sind, bevor Sie ein neues Problem erstellen oder hier antworten, wenn Sie dasselbe Problem sehen

@lahed vielen Dank, ich habe 2 Tage lang versucht, dieses Problem zu lösen, und endlich hier ein sehr hilfreiches gefunden, danke.

Ich hatte das gleiche, aber es funktionierte, indem ich onesignal.configure() wie folgt aufrief:

OneSignal.init("meine-onesignal-id");
OneSignal.configure();

Das war mit:
"react-native": "~0.56.0",
"react-native-onesignal": "^3.2.6",

folgte der onesignal Dokumentation zur Klingel und hatte
Plugin anwenden: 'com.onesignal.androidsdk.onesignal-gradle-plugin'

andere Information:
Klasse 3.1.3
Nebenstelle {
compileSdkVersion = 27
buildToolsVersion = "27.0.3"
minSdkVersion = 16
targetSdkVersion = 27
supportLibVersion = "27.1.1"
googlePlayServicesVersion = "12.0.1"
playServicesVersion = googlePlayServicesVersion
}

In meinem Fall habe ich nie irgendwelche Fehler auf dem OneSignal-Dashboard bekommen; Das Gerät wurde problemlos bei OneSignal registriert. Die onIds feuerten einfach nicht.

Das Hinzufügen direkt nach OneSignal.init() hat mein Problem behoben:

    OneSignal.configure();

Hoffe das hilft anderen.

Dasselbe Problem hier

Paket.json:

{
  "name": "smartial",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "android": "react-native run-android",
    "ios": "react-native run-ios",
    "start": "react-native start",
    "test": "jest",
    "lint": "eslint .",
    "android-linux": "npx react-native run-android --terminal \"$PWD/shkonsole\""
  },
  "dependencies": {
    "@react-native-community/google-signin": "^4.0.3",
    "react-native-onesignal": "^3.7.3",
    "@sentry/react-native": "^1.4.1",
    "react-native-code-push": "^6.2.1",
    "react-native-google-places": "^3.1.2",
    "@react-native-community/datetimepicker": "^2.4.2",
    "@react-native-community/masked-view": "^0.1.10",
    "@react-navigation/material-bottom-tabs": "^5.2.12",
    "@react-navigation/native": "^5.4.3",
    "@react-navigation/stack": "^5.4.0",
    "react-native-gesture-handler": "^1.6.1",
    "native-base": "^2.13.12",
    "react-native-paper": "^3.10.1",
    "react-native-safe-area-context": "^2.0.3",
    "react-native-reanimated": "^1.9.0",
    "react-native-screens": "^2.8.0",
    "apisauce": "^1.1.1",
    "react-native-config": "^1.2.1",
    "react-native-easy-app": "^1.7.3",
    "react-native-vector-icons": "^6.6.0",
    "@thallyssonklein/border-layout-react-native": "^1.0.14",
    "recoil": "github:eveningkid/Recoil#react-native",
    "react": "16.13.1",
    "react-native": "0.63.2"
  },
  "devDependencies": {
    "@babel/core": "^7.10.0",
    "@babel/runtime": "^7.10.0",
    "@bam.tech/react-native-make": "^3.0.0",
    "@react-native-community/eslint-config": "^1.1.0",
    "babel-jest": "^26.0.1",
    "eslint": "^7.1.0",
    "jest": "^26.0.1",
    "metro-react-native-babel-preset": "^0.59.0",
    "react-test-renderer": "16.11.0"
  },
  "jest": {
    "preset": "react-native"
  }
}

android/build.gradle

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

buildscript {
    ext {
        buildToolsVersion = "28.0.3"
        minSdkVersion = 16
        compileSdkVersion = 28
        targetSdkVersion = 28

        googlePlayServicesAuthVersion = "16.0.1"
    }
    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath('com.android.tools.build:gradle:3.6.3')
        classpath 'com.google.gms:google-services:4.1.0'
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

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

        google()
        jcenter()
        maven { url 'https://www.jitpack.io' }
    }
}

android/app/build.gradle

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. If none specified and
 *   // "index.android.js" exists, it will be used. Otherwise "index.js" is
 *   // default. Can be overridden with ENTRY_FILE environment variable.
 *   entryFile: "index.android.js",
 *
 *   // https://facebook.github.io/react-native/docs/performance#enable-the-ram-format
 *   bundleCommand: "ram-bundle",
 *
 *   // 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 = [
    enableHermes: false,  // clean and rebuild if changing
]

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

/**
 * The preferred build flavor of JavaScriptCore.
 *
 * For example, to use the international variant, you can use:
 * `def jscFlavor = 'org.webkit:android-jsc-intl:+'`
 *
 * The international variant includes ICU i18n library and necessary data
 * allowing to use e.g. `Date.toLocaleString` and `String.localeCompare` that
 * give correct results when using with locales other than en-US.  Note that
 * this variant is about 6MiB larger per architecture than default.
 */
def jscFlavor = 'org.webkit:android-jsc:+'

/**
 * Whether to enable the Hermes VM.
 *
 * This should be set on project.ext.react and mirrored here.  If it is not set
 * on project.ext.react, JavaScript will not be compiled to Hermes Bytecode
 * and the benefits of using Hermes will therefore be sharply reduced.
 */
def enableHermes = project.ext.react.get("enableHermes", false);

android {
    compileSdkVersion rootProject.ext.compileSdkVersion

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    defaultConfig {
        applicationId "com.smartial"
        minSdkVersion rootProject.ext.minSdkVersion
        targetSdkVersion rootProject.ext.targetSdkVersion
        versionCode 24
        versionName "3.0.9"
        multiDexEnabled true
    }
    splits {
        abi {
            reset()
            enable enableSeparateBuildPerCPUArchitecture
            universalApk false  // If true, also generate a universal APK
            include "armeabi-v7a", "x86", "arm64-v8a", "x86_64"
        }
    }
    signingConfigs {
        debug {
            storeFile file('debug.keystore')
            storePassword 'android'
            keyAlias 'androiddebugkey'
            keyPassword 'android'
        }
        release {
            storeFile file('smartial-app.jks')
            storePassword KEYSTORE_PASSWORD
            keyAlias KEY_ALIAS
            keyPassword KEY_PASSWORD
        }
    }
    buildTypes {
        debug {
            signingConfig signingConfigs.debug
        }
        release {
            // Caution! In production, you need to generate your own keystore file.
            // see https://facebook.github.io/react-native/docs/signed-apk-android.
            signingConfig signingConfigs.release
            minifyEnabled enableProguardInReleaseBuilds
            proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
        }
    }

    packagingOptions {
        pickFirst "lib/armeabi-v7a/libc++_shared.so"
        pickFirst "lib/arm64-v8a/libc++_shared.so"
        pickFirst "lib/x86/libc++_shared.so"
        pickFirst "lib/x86_64/libc++_shared.so"
    }

    // 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:
            // https://developer.android.com/studio/build/configure-apk-splits.html
            def versionCodes = ["armeabi-v7a": 1, "x86": 2, "arm64-v8a": 3, "x86_64": 4]
            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 {
    implementation fileTree(dir: "libs", include: ["*.jar"])
    // implementation 'com.google.android.gms:play-services-auth:18.0.0'
    // implementation "com.google.android.gms:play-services-base:16.0.1"
    // implementation "com.google.firebase:firebase-core:16.0.6"
    // implementation "com.google.firebase:firebase-messaging:17.3.4"
    //noinspection GradleDynamicVersion
    implementation "com.facebook.react:react-native:+"  // From node_modules

    implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.0.0"
    compile 'com.android.support:multidex:1.0.1' //enter the latest version

    debugImplementation("com.facebook.flipper:flipper:${FLIPPER_VERSION}") {
      exclude group:'com.facebook.fbjni'
    }

    debugImplementation("com.facebook.flipper:flipper-network-plugin:${FLIPPER_VERSION}") {
        exclude group:'com.facebook.flipper'
    }

    debugImplementation("com.facebook.flipper:flipper-fresco-plugin:${FLIPPER_VERSION}") {
        exclude group:'com.facebook.flipper'
    }

    if (enableHermes) {
        def hermesPath = "../../node_modules/hermes-engine/android/";
        debugImplementation files(hermesPath + "hermes-debug.aar")
        releaseImplementation files(hermesPath + "hermes-release.aar")
    } else {
        implementation jscFlavor
    }

    implementation project(':react-native-config')
    compile project(':react-native-onesignal') // I just added this line 
}

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

apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project)
apply from: "../../node_modules/react-native-code-push/android/codepush.gradle"
apply from: "../../node_modules/react-native-vector-icons/fonts.gradle"

apply from: project(':react-native-config').projectDir.getPath() + "/dotenv.gradle"

apply plugin: 'com.google.gms.google-services' // <--- this should be the last line

src/main/AndroidManifest.xml

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
  package="com.smartial">

    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
    <uses-permission android:name="com.google.android.c2dm.permission.RECEIVE"/>


    <application
      android:name=".MainApplication"
      android:label="@string/app_name"
      android:icon="@mipmap/ic_launcher"
      android:allowBackup="false"
      android:theme="@style/AppTheme">
      <activity
        android:name=".MainActivity"
        android:label="@string/app_name"
        android:configChanges="keyboard|keyboardHidden|orientation|screenSize|uiMode"
        android:launchMode="singleTask"
        android:windowSoftInputMode="adjustResize">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
      </activity>
      <activity android:name="com.facebook.react.devsupport.DevSettingsActivity" />
    </application>

</manifest>

src/debug/AndroidManifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools">

    <uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
    <uses-permission android:name="com.google.android.c2dm.permission.RECEIVE"/>

    <application android:usesCleartextTraffic="true" tools:targetApi="28" tools:ignore="GoogleAppIndexingWarning" />
</manifest>

War diese Seite hilfreich?
0 / 5 - 0 Bewertungen