OneSignal / OneSignal-Android-SDK

OneSignal is a free push notification service for mobile apps. This plugin makes it easy to integrate your native Android or Amazon app with OneSignal. https://onesignal.com
Other
591 stars 367 forks source link

app_id not found. You may be missing a Content-Type: application/json header #519

Closed Ebraheemb closed 6 years ago

Ebraheemb commented 6 years ago

Hi I'm trying to get OneSignal user id, but I get this error: {"errors":["app_id not found. You may be missing a Content-Type: application/json header."]}

This is the prompt error: whatsapp image 2018-04-30 at 15 07 45

This is my build.gradle: `apply plugin: 'com.android.application' apply plugin: 'realm-android'

buildscript { repositories { maven { url 'https://plugins.gradle.org/m2/'} } dependencies { classpath 'gradle.plugin.com.onesignal:onesignal-gradle-plugin:0.8.1' } } apply plugin: 'com.onesignal.androidsdk.onesignal-gradle-plugin'

repositories { maven { url 'https://maven.google.com' } }

android { compileSdkVersion 27 buildToolsVersion '27.0.3' defaultConfig {

    manifestPlaceholders = [

            onesignal_app_id: 'xxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxx',
            // Project number pulled from dashboard, local value is ignored.
            onesignal_google_project_number: 'Xxxxxxxxxx'
    ]

    applicationId "xxxxxxxx"
    minSdkVersion 17
    targetSdkVersion 27
    versionCode 1
    versionName "1.0"
    testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    multiDexEnabled true

}
dexOptions {
    // Prevent OutOfMemory with MultiDex during the build phase
    javaMaxHeapSize "4g"
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}

}

repositories { maven { url 'https://github.com/uPhyca/stetho-realm/raw/master/maven-repo' } maven { url "https://jitpack.io" } maven { url "https://jitpack.io" } maven { url "https://oss.sonatype.org/content/repositories/snapshots" } maven { url 'https://maven.fabric.io/public' } jcenter() google() maven { url 'https://maven.google.com' } }

def supportVirsion = '27.1.1' def playServicesVirsion = '12.0.0'

dependencies { implementation fileTree(dir: 'libs', include: ['*.jar'])

configurations {
    all*.exclude group: 'com.android.support', module: 'support-v13'
}
implementation 'com.github.bumptech.glide:glide:4.7.1'
annotationProcessor 'com.github.bumptech.glide:compiler:4.7.1'

// implementation 'com.github.bumptech.glide:glide:3.7.0' implementation'com.facebook.stetho:stetho:1.5.0' implementation 'com.uphyca:stetho_realm:2.1.0' implementation 'org.greenrobot:eventbus:3.1.1' implementation 'com.greysonparrelli.permiso:permiso:0.3.0'

implementation 'com.jakewharton:butterknife:8.8.1'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1'
implementation 'uk.co.chrisjenx:calligraphy:2.3.0'
implementation 'com.wdullaer:materialdatetimepicker:3.2.0'
implementation 'com.onesignal:OneSignal:[3.8.3,4.0.0)'
implementation 'io.nlopez.smartlocation:library:3.3.3'
implementation 'com.github.lovetuzitong:MultiImageSelector:1.2'
implementation 'de.hdodenhof:circleimageview:2.2.0'
implementation 'com.squareup.retrofit2:retrofit:2.4.0'
implementation 'com.squareup.retrofit2:converter-gson:2.4.0'
implementation 'com.google.code.gson:gson:2.8.2'
implementation 'com.wang.avi:library:2.1.3'
implementation 'com.daimajia.easing:library:2.0@aar'
implementation 'com.daimajia.androidanimations:library:2.2@aar'
implementation 'com.pusher:pusher-java-client:1.6.0'
implementation 'com.github.hani-momanii:SuperNova-Emoji:1.1'
implementation 'com.loopj.android:android-async-http:1.4.9'
implementation 'com.theartofdev.edmodo:android-image-cropper:2.4.+'
implementation 'net.yslibrary.keyboardvisibilityevent:keyboardvisibilityevent:2.1.0'
implementation 'it.sephiroth.android.library.targettooltip:target-tooltip-library:1.3.15'

implementation 'io.michaelrocks:libphonenumber-android:8.7.0'

implementation "com.google.android.gms:play-services-maps:$playServicesVirsion"

implementation "com.android.support:recyclerview-v7:$supportVirsion"
implementation "com.android.support:support-v4:$supportVirsion"
implementation "com.android.support:appcompat-v7:$supportVirsion"
implementation "com.android.support:design:$supportVirsion"
implementation "com.android.support:cardview-v7:$supportVirsion"
implementation "com.android.support:customtabs:$supportVirsion"
implementation "com.android.support:multidex:1.0.3"
implementation "com.android.support:appcompat-v7:$supportVirsion"
implementation 'com.github.florent37:fiftyshadesof:1.0.0'
implementation 'gun0912.ted:tedbottompicker:1.1.0'
debugImplementation 'com.readystatesoftware.chuck:library:1.1.0'

}

`

this is my maniefist:

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

<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.READ_CONTACTS"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>

<application
    android:name=".AppController"
    android:allowBackup="true"
    android:icon="@drawable/launcher"
    android:label="@string/app_name"
    android:roundIcon="@drawable/launcher"
    android:supportsRtl="false"
    android:theme="@style/AppTheme">
    <service
        android:name=".services.MyNotificationService"
        android:exported="false"
        android:permission="android.permission.BIND_JOB_SERVICE">
        <intent-filter>
            <action android:name="com.onesignal.NotificationExtender"/>
        </intent-filter>
    </service>

    <meta-data
        android:name="com.onesignal.NotificationOpened.DEFAULT"
        android:value="DISABLE"
        tools:replace="android:value"/>
    <meta-data
        android:name="com.onesignal.BadgeCount"
        android:value="DISABLE"/>

    <activity android:name=".activities.MainActivity">

        <!-- <intent-filter> -->
        <!-- <action android:name="android.intent.action.MAIN"/> -->

        <!-- <category android:name="android.intent.category.LAUNCHER"/> -->
        <!-- </intent-filter> -->
    </activity>

    <service
        android:name=".services.LocationService"
        android:enabled="true"
        android:exported="true">
    </service>

    <activity android:name=".activities.ExamplesActivity">

        <!-- <intent-filter> -->
        <!-- <action android:name="android.intent.action.MAIN"/> -->

        <!-- <category android:name="android.intent.category.LAUNCHER"/> -->
        <!-- </intent-filter> -->
    </activity>
    <activity android:name=".activities.CreateGroupActivity"
        android:screenOrientation="portrait">
    </activity>
    <activity
        android:name=".activities.GroupActivity"
        android:label="@string/title_activity_group"
        android:screenOrientation="portrait"
        android:windowSoftInputMode="adjustResize">
    </activity>
    <!--
         The API key for Google Maps-based APIs is defined as a string resource.
         (See the file "res/values/google_maps_api.xml").
         Note that the API key is linked to the encryption key used to sign the APK.
         You need a different API key for each encryption key, including the release key that is used to
         sign the APK for publishing.
         You can define the keys for the debug and release targets in src/debug/ and src/release/. 
    -->
    <meta-data
        android:name="com.google.android.geo.API_KEY"
        android:value="@string/google_maps_key"/>

    <activity
        android:name=".activities.MapsActivity"
        android:screenOrientation="portrait"
        android:label="@string/title_activity_maps">
    </activity>
    <activity
        android:name="me.nereo.multi_image_selector.MultiImageSelectorActivity"
        android:screenOrientation="portrait"
        android:configChanges="orientation|screenSize"/>
    <activity android:name=".activities.LoginActivity"
              android:screenOrientation="portrait">
    </activity>
    <activity android:name=".activities.AddContactActivity"
              android:screenOrientation="portrait">
    </activity>
    <activity android:name=".activities.AddGroupParticipantsActivity"
              android:screenOrientation="portrait">

        <!-- <intent-filter> -->
        <!-- <action android:name="android.intent.action.MAIN"/> -->
        <!-- <category android:name="android.intent.category.LAUNCHER"/> -->
        <!-- </intent-filter> -->
    </activity>
    <activity android:name=".activities.ProfileActivity"
              android:screenOrientation="portrait">
    </activity>

    <service
        android:name=".services.UpdateLocationService"
        android:enabled="true"
        android:exported="true">
    </service>

    <receiver
        android:name=".services.RestartUpdateLocationReceiver"
        android:enabled="true">
        <intent-filter>
            <action android:name=".RestartUpdateLocationReceiver.ACTION_UPDATE_LOCATION_SERVICE_STOPED"/>
            <action android:name="android.intent.action.BOOT_COMPLETED"/>
        </intent-filter>
    </receiver>

    <meta-data
        android:name="io.fabric.ApiKey"
        android:value="d014c688774b6e0d103d8babf2f26dc17e036211"/>

    <activity
        android:name="com.theartofdev.edmodo.cropper.CropImageActivity"
        android:screenOrientation="portrait"
        android:theme="@style/Base.Theme.AppCompat"/>
    <activity android:name=".activities.SplashActivity">
        <intent-filter>
            <action android:name="android.intent.action.MAIN"/>

            <category android:name="android.intent.category.LAUNCHER"/>
        </intent-filter>
    </activity>
    <activity
        android:name=".activities.ChooseCountryActivity"
        android:screenOrientation="portrait"
        android:theme="@style/SeachCountryTheme">
    </activity>
    <activity
        android:name=".activities.GroupInfoActivity"
        android:screenOrientation="portrait"
        android:theme="@style/InfoGroupActivityTheme">
    </activity>
    <activity
        android:name=".activities.PrivateChatActivity"
        android:screenOrientation="portrait"
        android:label="chat">

    </activity>
    <activity android:name=".activities.ImageToSendActivity"
              android:screenOrientation="portrait">
    </activity>
</application>

`

Ebraheemb commented 6 years ago

Fixed

After many tries, I changed the dependency from: implementation 'com.onesignal:OneSignal:[3.8.3,4.0.0)' to: implementation 'com.onesignal:OneSignal:[3.8.3, 3.99.99]' image

I don't know why this happens.

in case of "implementation 'com.onesignal:OneSignal:[3.8.3,4.0.0)'" I get this error: image

in case of "implementation 'com.onesignal:OneSignal:[3.8.3, 3.99.99]'" I get something like this : image

image

jkasten2 commented 6 years ago

Using [3.8.3,4.0.0) will cause gradle to pull in 4.0.0-SNAPSHOT versions if you including the snapshot repo which I see you have

repositories {
  maven {
    url "https://oss.sonatype.org/content/repositories/snapshots"
  }
}

Using [3.8.3, 3.99.99] ensures a 4.0.0 version is never fetched.