OneSignal / react-native-onesignal

React Native Library for OneSignal Push Notifications Service
Other
1.57k stars 374 forks source link

manifestPlaceholders Initialization is Broken in Android #639

Closed Nightsd01 closed 5 years ago

Nightsd01 commented 6 years ago

I have noticed that in the most recent version of the OneSignal react-native SDK, the old method of initializing on Android (placing the OneSignal app ID in build.gradle manifest placeholders) no longer appears to work.

We will be investigating this issue this week.

freysie commented 6 years ago

When building for Android I’m getting these “requires a placeholder substitution” errors:

> Task :react-native-onesignal:processDebugAndroidTestManifest FAILED
…/node_modules/react-native-onesignal/android/build/intermediates/tmp/manifest/androidTest/debug/manifestMerger2995308312281659017.xml Error:
        Attribute meta-data#onesignal_app_id@value at manifestMerger2995308312281659017.xml requires a placeholder substitution but no value for <onesignal_app_id> is provided.
…/node_modules/react-native-onesignal/android/build/intermediates/tmp/manifest/androidTest/debug/manifestMerger2995308312281659017.xml Error:
        Attribute meta-data#onesignal_google_project_number@value at manifestMerger2995308312281659017.xml requires a placeholder substitution but no value for <onesignal_google_project_number> is provided.

Does anyone have a temporary workaround for this?

I tried adding the following to build.gradle as suggested by the OneSignal Android SDK setup documentation, but this doesn’t seem to work either:

android {
   defaultConfig {
      manifestPlaceholders = [
          onesignal_app_id: 'PUT YOUR ONESIGNAL APP ID HERE',
          onesignal_google_project_number: 'REMOTE'
      ]
    }
 }
tommyluohk01 commented 6 years ago

have any updates? seems i use appIdFromManifest this function, and only get the empty string

BatDroid commented 5 years ago

anyone could find a solution for this?

gusy126 commented 5 years ago

@BatDroid I'm not having this problem anymore, I think maybe one of the newer updates fixed the issue. However when I did have this issue a few months ago it would only happen when I built through Android Studio. The workaround was to just make builds through the terminal instead.

rgomezp commented 5 years ago

Closing due to no response. Feel free to reply if you wish to reopen

rochapablo commented 5 years ago

The problem persist

android {
    compileSdkVersion rootProject.ext.compileSdkVersion

    defaultConfig {
        applicationId ...
        minSdkVersion rootProject.ext.minSdkVersion
        targetSdkVersion rootProject.ext.targetSdkVersion
        versionCode ...
        versionName ...

        // Enabling multidex support.
        multiDexEnabled true

        manifestPlaceholders = [
            onesignal_app_id: ...,
            onesignal_google_project_number: 'REMOTE'
        ]
    }
    ...
> Task :react-native-onesignal:processDebugAndroidTestManifest FAILED
/react-native-onesignal/android/build/intermediates/tmp/manifest/androidTest/debug/manifestMerger8819906485659168097.xml Error:
    Attribute meta-data#onesignal_app_id@value at manifestMerger8819906485659168097.xml requires a placeholder substitution but no value for <onesignal_app_id> is provided.
/react-native-onesignal/android/build/intermediates/tmp/manifest/androidTest/debug/manifestMerger8819906485659168097.xml Error:
    Attribute meta-data#onesignal_google_project_number@value at manifestMerger8819906485659168097.xml requires a placeholder substitution but no value for <onesignal_google_project_number> is provided.

See http://g.co/androidstudio/manifest-merger for more information about the manifest merger.

getting-gradle-error-with-onesignal-in-android-studio how-to-use-librarys-manifestplaceholders-in-the-app nativescript-onesignal-fails-android-build

rgomezp commented 5 years ago

@rochapablo , it looks like that solution worked for you. I will close this issue if that's okay with you. If you continue seeing issues, let me know and I will reopen

Summary:

I came across this problem in unrelated project, but I found a solution that works for me: disabling Gradle feature "Only sync the active variant". In Android Studio: File > Settings > Experimental > Gradle -> uncheck "Only sync the active variant" checkbox.