hi i'm trying to use OneSignal in android and i'm following this tutorial to install the SDK in Android Studio. here
i was able to compile the dependencies and sync the gradle file. but when i want to import com.onesignal.OneSignal;
it says: Cannot resolve symbol!
here is my dependencies in app.gradle file
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.0.1'
compile 'com.android.support:design:23.0.1'
compile 'com.onesignal:OneSignal:1.10.+@aar'
compile 'com.google.android.gms:play-services-gcm:+'
compile 'com.google.android.gms:play-services-analytics:+'
compile project(':gson-2.2.2')
compile project(':java_websocket')
compile project(':signalr-client-sdk')
compile project(':signalr-client-sdk-android')
}
thing i done:
1. File > Synchronize
2. File > Invalidate Cashes and Restart
UPDATE:
i did the steps in a new project and that was ok! why i can't do it in this specific project?
EDIT:
whole build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
useLibrary 'org.apache.http.legacy'
defaultConfig {
applicationId "ir.irsapardaz.sina.gamev01"
manifestPlaceholders = [manifestApplicationId:"${applicationId}"]
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.0.1'
compile 'com.android.support:design:23.0.1'
compile 'com.onesignal:OneSignal:1.10.+@aar'
compile 'com.google.android.gms:play-services-gcm:+'
compile 'com.google.android.gms:play-services-analytics:+'
compile project(':gson-2.2.2')
compile project(':java_websocket')
compile project(':signalr-client-sdk')
compile project(':signalr-client-sdk-android')
}
Use the following in your gradle file to get the latest OneSignal SDK 3.X version.
compile 'com.onesignal:OneSignal:[3.8.3, 3.99.99]'
The error you're are seeing is normally due to Android Studio either not pulling in the SDK from Maven Central or you haven't synced your .gradle
since you added OneSignal to it.
In your case going to Tool
> Android
> Sync Project
should fix the following error
com.onesignal.OneSignal; Cannot resolve symbol!
See OneSignal's documentation for a few more things to try if that doesn't work. https://documentation.onesignal.com/docs/troubleshooting-android
if anyone comes across this for ReactNative v0.37, i had a similar issue, but my code was newer in general. the following solved it:
for android be sure to use:
import com.geektime.reactnativeonesignal.ReactNativeOneSignalPackage;
and NOT import com.geektime.rnonesignal.ReactNativeOneSignalPackage;
some old documentation had the rnonesignal and that's since been updated.
YMMV if you are using something lower than v0.37 of RN. good luck.
In your Build gradel file
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
useLibrary 'org.apache.http.legacy'
defaultConfig {
applicationId "ir.irsapardaz.sina.gamev01"
manifestPlaceholders = [manifestApplicationId:"${applicationId}"]
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
Under
default Config{
}
add this :
manifestPlaceholders = [onesignal_app_id: " Your app ID as provided by OneSignal ",
onesignal_google_project_number: " Your Sender Id as provided by Google firebase "
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With