I want to connect my app (written in Kotlin) with Firebase Cloud Messaging but I cannot get it to receive messages from firebase...
Code:
Manifest
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="kubacki.com.expiryassistant">
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:roundIcon="#mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity
android:name=".MainActivity"
android:configChanges="orientation|screenSize|keyboardHidden"
android:label="#string/app_name"
android:theme="#style/AppTheme.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<service
android:name=".MyFirebaseMessaging"
android:enabled="true"
android:exported="true">
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT" />
</intent-filter>
</service>
</application>
</manifest>
Message Receiver class:
package kubacki.com.expiryassistant
import android.app.Service
import android.content.Intent
import android.os.IBinder
import android.util.Log
import com.google.firebase.iid.FirebaseInstanceId
import com.google.firebase.messaging.FirebaseMessagingService
import com.google.firebase.messaging.RemoteMessage
class MyFirebaseMessaging : FirebaseMessagingService() {
private val TAG = "FIREBASE"
override fun onMessageReceived(p0: RemoteMessage?) {
super.onMessageReceived(p0)
Log.d(TAG, "From: " + p0?.from)
Log.d(TAG, "Message: " + p0?.notification)
}
override fun onNewToken(p0: String?) {
super.onNewToken(p0)
Log.d(TAG, p0)
}
}
build.grade (Project)
buildscript {
ext.kotlin_version = '1.2.30'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.3'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
// FIREBASE
classpath 'com.google.gms:google-services:4.0.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
build.gradle (module)
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'
android {
compileSdkVersion 27
defaultConfig {
applicationId "kubacki.com.expiryassistant"
minSdkVersion 21
targetSdkVersion 27
versionCode 1
versionName "1.0"
testInstrumentationRunner
"android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'),
'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.android.support:design:27.1.1'
implementation 'com.android.support:support-v4:27.1.1'
implementation 'com.android.support:recyclerview-v7:27.1.1'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-
core:3.0.2'
// ButterKnife
implementation 'com.jakewharton:butterknife:8.8.1'
kapt 'com.jakewharton:butterknife-compiler:8.8.1'
// RxJava
implementation "io.reactivex.rxjava2:rxjava:2.1.16"
// RxAndroid
implementation 'io.reactivex.rxjava2:rxandroid:2.0.2'
// FIREBASE
implementation 'com.google.firebase:firebase-core:16.0.4'
implementation 'com.google.firebase:firebase-messaging:17.3.4'
}
apply plugin: 'com.google.gms.google-services'
In the console I can see that Firebase in initalized successfully but I cannot see any messages received after sending them via console.
I might have forgotten about some steps of configuration but I have already went through all tutorials and I believe that my code should work.
Thank you for all help on this case.
give the internet permission to your app in Android Manifest.
I think it will help you
Add this code line for enable internet connection
<uses-permission android:name="android.permission.INTERNET" />
Related
I have an error concerning Hilt, I"ve been trying to inject a retrofit interface I created using Hilt,
Here is the error:
java.lang.ClassNotFoundException: Didn't find class "com.kotlin20test.Hilt_MyApp" on path: DexPathList[[zip file "/data/app/com.example.kotlin20test-hKFhgE2D6vBE-1ZkVY-UOA==/base.apk"],nativeLibraryDirectories=[/data/app/com.example.kotlin20test-hKFhgE2D6vBE-1ZkVY-UOA==/lib/x86, /system/lib, /system/product/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:196)
at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
... 16 more
and Here are my files:
MyApp
#HiltAndroidApp
class MyApp : Application()
build.gradle
plugins {
id 'com.android.application'
id 'kotlin-android'
id 'dagger.hilt.android.plugin'
}
android {
//View Binding
buildFeatures {
viewBinding true
}
compileSdkVersion 30
defaultConfig {
applicationId "com.example.kotlin20test"
minSdkVersion 26
targetSdkVersion 30
versionCode 1
multiDexEnabled true
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
}
dexOptions {
javaMaxHeapSize "4g"
}
packagingOptions {
exclude 'META-INF/gradle/incremental.annotation.processors'
}
}
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'com.google.android.material:material:1.3.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
testImplementation 'junit:junit:4.+'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
//Room
def room_version = "2.2.6"
def lifecycle_version = "2.3.1"
// ViewModel
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:$lifecycle_version"
// Saved state module for ViewModel
implementation "androidx.lifecycle:lifecycle-viewmodel-savedstate:$lifecycle_version"
// Annotation processor
annotationProcessor "androidx.lifecycle:lifecycle-compiler:$lifecycle_version"
// alternately - if using Java8, use the following instead of lifecycle-compiler
implementation "androidx.lifecycle:lifecycle-common-java8:$lifecycle_version"
apply plugin: 'kotlin-kapt'
implementation "androidx.room:room-runtime:$room_version"
annotationProcessor "androidx.room:room-compiler:$room_version"
implementation 'androidx.room:room-ktx:2.3.0'
annotationProcessor "androidx.room:room-compiler:2.3.0"
//Coroutines
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.4.3'
def multidex_version = "2.0.1"
implementation "androidx.multidex:multidex:$multidex_version"
//Activity Result API
implementation "androidx.activity:activity-ktx:1.3.0-alpha07"
implementation 'androidx.fragment:fragment-ktx:1.3.3'
//Retrofit and Gson
implementation "com.squareup.retrofit2:converter-gson:2.9.0"
implementation 'com.squareup.retrofit2:retrofit:2.9.0'
//Dagger Hilt
implementation 'com.google.dagger:hilt-android:2.35.1'
implementation 'com.google.dagger:hilt-compiler:2.35.1'
implementation 'com.google.android.gms:play-services:12.0.1'
implementation 'androidx.multidex:multidex:2.0.0'
}
buildscript {
ext.kotlin_version = "1.3.50"
repositories {
google()
jcenter()
}
ext.hilt_version = '2.35'
dependencies {
classpath 'com.android.tools.build:gradle:4.2.1'
classpath "com.google.dagger:hilt-android-gradle-plugin:$hilt_version"
classpath 'com.google.dagger:hilt-android-gradle-plugin:2.35.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
AndroidManifest
<?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="com.example.kotlintest">
<application
tools:remove="android:appComponentFactory"
android:name=".Hilt_MyApp"
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:roundIcon="#mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="#style/Theme.KotlinTest">
<activity android:name=".MainActivity2"
></activity>
<activity android:name=".MainActivity" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<receiver android:name=".ExampleBroadcast"/>
</application>
</manifest>
I tried hilt in another application using Kotlin but still the same error is produced, I've also read
a couple of questions on the subject her on Stack Overflow, and tries some Answers, including
MultiDexApplication.
Edit: Sorry I wrote the wrong AndroidManifest, the previous app one was of an
app that had the same error(I'm trying two apps), and I changed the second one's
Application class to Hilt_MyApp class before that error showed up in hopes of
trying to solve the error.
Here is the real manifest related to this app:
<?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="com.example.kotlin20test">
<application
android:name="com.kotlin20test.MyApp"
tools:remove="android:appComponentFactory"
tools:targetApi="p"
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:roundIcon="#mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="#style/Theme.Kotlin20Test">
<activity android:name="com.kotlin20test.MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
'''
I solved it, it turns out that I did not provide the kapt,
id 'kotlin-kapt'
and used used implementation instead of kapt so instead of:
implementation 'com.google.dagger:hilt-compiler:2.35.1'
I provided:
kapt 'com.google.dagger:hilt-compiler:2.35.1'
hope this helps someone someone
i had the same problem today, and I saw that it in your gradle too
packagingOptions {
exclude 'META-INF/gradle/incremental.annotation.processors'
}
this is how you should do the hilt implementation to avoid using it and fix the problem
//Hilt
implementation "com.google.dagger:hilt-android:2.42"
kapt "com.google.dagger:hilt-android-testing:2.42"
kapt "com.google.dagger:hilt-compiler:2.42"
Renamed the application name in manifest.xml to
android:name=".MyApp"
In your manifest rename the atributte:
android:name=".Hilt_MyApp" to android:name=".MyApp"
so I want to use Anko library on my apps by use Androidx, and I want to add Anko library inside of my apps on android studio, I use API version 30, android 10.0+ (R), but when I Add Anko library on my project I get the error :
Manifest merger failed : uses-sdk:minSdkVersion 14 cannot be smaller than version 15 declared in library [org.jetbrains.anko:anko-design:0.10.8] /Users/anjay/.gradle/caches/transforms-2/files-2.1/1d0aabee6b3e238a89acc21f650d01a8/jetified-anko-design-0.10.8/AndroidManifest.xml as the library might be using APIs not available in 14
Suggestion: use a compatible library with a minSdk of at most 14,
or increase this project's minSdk version to at least 15,
or use tools:overrideLibrary="org.jetbrains.anko.generated.design" to force usage (may lead to runtime failures)
This is my build.gradle (Module level):
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
android {
compileSdkVersion 30
buildToolsVersion "30.0.1"
defaultConfig {
applicationId "com.example.apithemoviedb"
minSdkVersion 14
targetSdkVersion 30
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation 'androidx.core:core-ktx:1.1.0'
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
// implementasi atau library androidx design
implementation 'com.google.android.material:material:1.0.0-alpha3'
// implementasi atau library androidx anko
implementation "org.jetbrains.anko:anko-design:$anko_version"
implementation "org.jetbrains.anko:anko:$anko_version"
// RecyclerView-v7
implementation "org.jetbrains.anko:anko-recyclerview-v7:$anko_version"
implementation "org.jetbrains.anko:anko-recyclerview-v7-coroutines:$anko_version"
//implementasi atau library picasso
implementation 'com.squareup.picasso:picasso:2.71828'
//implementasi atau library Gson
implementation 'com.google.code.gson:gson:2.8.6'
}
This is my build.gradle (project level):
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext.kotlin_version = "1.3.72"
ext.anko_version='0.10.8'
repositories {
google()
jcenter()
}
dependencies {
classpath "com.android.tools.build:gradle:4.0.1"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
This is my AndroidManifest.xml :
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.apithemoviedb">
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:roundIcon="#mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
I don't understand... How about just increase minSdkVersion as the error log said and see what's gonna happen?
Context:
Implementing Cloud Push Notifications on Android via Parse Server
as Backend and Firebase Cloud Messaging Service
Goal: Sending a push notification from Parse to the subject Android Application
Problem:
When injecting class com.parse.fcm.ParseFirebaseInstanceIdService into AndroidManifest.xml file, it goes unresolved.
Already-tried Solutions:
Changing the Firebase and Parse packages versions in build.gradle (App File) as well as changing the dependencies versions in build.gralde (Project File)
Project files:
AndroidManifest.xml
(Portion of the file where the error occurs)
<service
android:name="com.parse.fcm.ParseFirebaseInstanceIdService"
android:exported="true">
<intent-filter>
<action android:name="com.google.firebase.INSTANCE_ID_EVENT" />
</intent-filter>
</service>
build.gradle (Project)
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.1'
classpath 'com.google.gms:google-services:4.0.1'
}
}
allprojects {
repositories {
google()
jcenter()
maven { url "https://jitpack.io" }
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
build.gradle (Module)
apply plugin: 'com.android.application'
android {
compileSdkVersion 29
buildToolsVersion "29.0.1"
defaultConfig {
applicationId "com.sytech.uber"
minSdkVersion 24
targetSdkVersion 29
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'com.google.android.gms:play-services-maps:16.1.0'
implementation 'com.google.firebase:firebase-analytics:17.2.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
//Parse
implementation "com.github.parse-community.Parse-SDK-Android:parse:1.20.0"
implementation "com.github.parse-community.Parse-SDK-Android:fcm:1.20.0"
implementation 'com.parse.bolts:bolts-android:1.4.0'
//Toasty https://github.com/GrenderG/Toasty
implementation 'com.github.GrenderG:Toasty:1.4.2'
//Firebase
implementation'com.google.firebase:firebase-auth:19.1.0'
implementation 'com.google.firebase:firebase-messaging:17.6.0'
implementation 'com.google.firebase:firebase-core:16.0.8'
}
apply plugin: 'com.google.gms.google-services'
com.google.gms.googleservices.GoogleServicesPlugin.config.disableVersionCheck = true
FirebaseInstanceIdService is no longer usable. Use latest version of parse and FirebaseMessagingService
implementation "com.github.parse-community.Parse-SDK-Android:fcm:1.21.0"
And use ParseFirebaseMessagingService
<service
android:name="com.parse.fcm.ParseFirebaseMessagingService">
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT"/>
</intent-filter>
</service>
Just to add to Md. Asaduzzaman's answer, make sure to override the onNewToken() method in your custom FirebaseMessagingService, like in this tutorial. (I just found the tutorial and thought it would be nice to share it if others are stuck with the same problem).
#Override
public void onNewToken(String s) {
super.onNewToken(s);
Log.i("NEW_TOKEN", s);
}
We need to override it because:
"FirebaseInstanceIdService: This class was deprecated. In favour of overriding onNewToken in FirebaseMessagingService.
Once that has been implemented, this service can be safely removed."
Below is the unexpected error. How can I debug this?
Merging Errors: Error: Attribute meta-data#onesignal_app_id#value at AndroidManifest.xml:50:9-52:51 requires a placeholder substitution but no value for is provided. app main manifest (this file), line 49 Error: Attribute meta-data#onesignal_google_project_number#value at AndroidManifest.xml:54:9-56:70 requires a placeholder substitution but no value for is provided. app main manifest (this file), line 53
Code:
?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.muhammadtehmoor.my_fyp">
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.CAMERA"/>
<uses-feature android:name="android.hardware.camera2" />
<uses-feature android:name="android.hardware.camera" />
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:roundIcon="#mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
This is my build.gradle (app level). I have imported most of the dependencies from the Firebase plugin in Android Studio.
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
// buildToolsVersion '26.0.1'
defaultConfig {
applicationId "com.muhammadtehmoor.my_fyp"
minSdkVersion 19
targetSdkVersion 28
versionCode 1
versionName "1.0"
multiDexEnabled true
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
//noinspection GradleCompatible
implementation 'androidx.appcompat:appcompat:1.0.0'
implementation 'com.google.android.material:material:1.0.0'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'com.google.firebase:firebase-auth:11.0.4'
implementation 'com.google.firebase:firebase-database:11.0.4'
implementation 'com.google.firebase:firebase-storage:11.0.4'
testImplementation 'junit:junit:4.12'
implementation 'com.hbb20:ccp:2.1.9'
implementation 'uk.co.chrisjenx:calligraphy:2.3.0'
implementation 'androidx.multidex:multidex:2.0.0'
implementation 'com.alimuzaffar.lib:animated-edit-text:2.0.2'
implementation 'de.hdodenhof:circleimageview:3.0.0'
implementation 'com.google.android.gms:play-services-maps:11.0.4'
implementation 'com.google.android.gms:play-services-gcm:11.0.4'
implementation 'com.google.android.gms:play-services-location:11.0.4'
implementation 'com.rengwuxian.materialedittext:library:2.1.4'
implementation 'com.github.d-max:spots-dialog:1.1#aar'
implementation 'com.onesignal:OneSignal:3.+#aar'
androidTestImplementation 'androidx.test:runner:1.1.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0'
implementation 'me.spark:submitbutton:1.0.1'
//glidle
implementation 'com.github.bumptech.glide:glide:4.9.0'
implementation 'com.github.Mahfa:DayNightSwitch:1.2'
annotationProcessor 'com.github.bumptech.glide:compiler:4.9.0'
//firebase ui
// implementation 'com.firebaseui:firebase-ui-auth:3.1.0'
// implementation 'com.google.android.gms:play-services-auth:11.0.4'
}
//apply plugin: 'com.google.gms.google-services'
apply plugin: 'com.google.gms.google-services'
This is my build.gradle (project :my_Fyp). I have imported most of the dependencies from the Firebase plugin in Android Studio.
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
mavenCentral()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.4.2'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
//classpath 'com.google.gms:google-services:3.1.0'
classpath 'com.google.gms:google-services:4.2.0'
}
}
//configurations.all {
// resolutionStrategy.force 'com.android.support:support-v4:27.1.0'
//}
allprojects {
repositories {
google()
jcenter()
maven { url 'https://jitpack.io'}
maven {url 'https://dl.bintray.com/spark/maven'}
maven {
url 'https://maven.google.com/'
name 'Google'
}
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
The error message suggests that the OneSignal library is not configured correctly. Looking trough their setup instructions it seems like you missed point 1.3.
Add this to the app level build.gradle; inside the android/defaultConfig tag:
manifestPlaceholders = [
onesignal_app_id: 'PUT YOUR ONESIGNAL APP ID HERE',
// Project number pulled from dashboard, local value is ignored.
onesignal_google_project_number: 'REMOTE'
]
This might help...
Try going to your
android/app/build.gradle
find defaultConfig and add the following
manifestPlaceholders = [
onesignal_app_id: 'ONE SIGNAL APP ID',
// Project number pulled from dashboard, local value is ignored.
onesignal_google_project_number: 'REMOTE'
]
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.app.android"
...
manifestPlaceholders = [
onesignal_app_id: 'ONE SIGNAL APP ID HERE',
// Project number pulled from dashboard, local value is ignored.
onesignal_google_project_number: 'REMOTE'
]
}
Your Onesignal Google project number is your Firebase Sender ID.
I want to show ad in my app using Admob. But when I add google mobile ad dependency to my build.gradle file and sync project, it is showing red underline. It is showing "All gms/firebase libraries must use the exact same version specification" How to solve it? I add google() to my build.gradle(project) file and tried to add updated version of dependency.
build.gradle file, project level gradle file, manifest file:
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
defaultConfig {
applicationId "com.example.nabil.drawerlayout"
minSdkVersion 19
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support:cardview-v7:26.1.0'
implementation 'com.android.support:recyclerview-v7:26.1.0'
implementation 'com.android.support:design:26.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.android.support:support-v4:26.1.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation 'com.google.android.gms:play-services-ads:17.2.0'
}
```
project level gradle:
```
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
```
manifest file:
```
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.nabil.drawerlayout">
<uses-permission android:name="android.permission.INTERNET" />
<application
android:allowBackup="true"
android:icon="#mipmap/logo"
android:label="#string/app_name"
android:roundIcon="#mipmap/logo"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity android:name=".MainActivity" />
<activity
android:name=".AfterSearchActivity"
android:parentActivityName=".MainActivity" />
<activity android:name=".AfterallBusFragmentActivity" />
<activity
android:name=".SplashScreenActivity"
android:theme="#style/Theme.AppCompat.Light.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".FaqActivity" />
<activity android:name=".AboutAppActivity" />
<meta-data
android:name="com.google.android.gms.ads.APPLICATION_ID"
android:value="#string/admob_app_id"/>
</application>
</manifest>
```