Firebase InstanceId: binding to the service failed: Kotlin - android

App successfully lanches but get this error message in debugging. FirebaseInstanceId: binding to the service failed
App Build Gradle:
android {
compileSdkVersion 29
buildToolsVersion "29.0.2"
defaultConfig {
applicationId ""
minSdkVersion 16
targetSdkVersion 29
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
multiDexEnabled true // enable mun
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
Android manifest:
<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"
tools:ignore="GoogleAppIndexingWarning">
<activity android:name=".FilterPage"></activity>
<activity android:name=".filterdashboard" />
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>

I have added
<uses-permission android:name="android.permission.INTERNET"/>
In my manifest file and got rid of Firebase InstanceId: binding to the service failed. Hope it will help.

I downloaded the newest version of google-service.json (can be done via Firebase Settings). In my case there was a new entry added to oauth_client. After syncing with the file system and rebuilding my app the warning does not seem to appear anymore.
EDIT 20-02-2020: After testing this a bit more it unfortunately doesn't seem to help in the end. In my case the error message only for sure occur when starting the app the first time after an uninstall of the app - in most other cases it does not happen.

Please try to use an actual device. Per my observation, you'll get this kind of error when you use an emulator even though you've already downloaded all the required libraries related to Google Services. I was also able to see other errors from FirebaseInstanceId.

In my case, login to Google Play on emulator (API: R) is fixed the problem. I think it's about Play Services.

Add service tag inside application tag
<application>
....
<activity
....
</activity>
<service
android:name=".MyFirebaseMessagingService"
android:exported="false">
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT" />
</intent-filter>
</service>
</application>
Then add a new kotlin file - MyFirebaseMessagingService.kt
import com.google.firebase.messaging.FirebaseMessagingService;
public class MyFirebaseMessagingService extends FirebaseMessagingService {
#Override
public void onNewToken(String s) {
super.onNewToken(s);
System.out.println("NEW_TOKEN :::::::::::::::::::::::::: "+s);
}
}
Uninstall the App manually and reinstall. This will work.

Related

Getting error when trying to run debugger in Android Studio

What currently happens: when I make a breakpoint on a method and right click to select Debug VendorMapsActivity it gives me an error saying "Error running VendorMapsActivity: this activity must be exported or contain an intent-filter."
What needs to happen: I need to be able to debug a method that is supposed to be called when the user swipe closes the app and deletes their data from Firebase Auth and Firebase Database Uid. I need to see if the method is running the way it needs to. Because as of now, the method itself is not removing any data from the Firebase Database.
What I have done: I have selected the debug variant in my build. I have added a build type of debug in my gradle. I also have the VendorMapsActivity in my Manifest file.
Manifest code:
<?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.zzyzj.man">
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
<application
android:allowBackup="true"
android:icon="#drawable/logo"
android:label="#string/app_name"
android:roundIcon="#drawable/logo"
android:supportsRtl="true"
android:theme="#style/AppTheme"
tools:ignore="GoogleAppIndexingWarning">
<activity android:name=".login.EatLoginActivity"
android:screenOrientation="portrait"
android:label="#string/app_name"/>
<activity android:name=".login.VendorLoginActivity"
android:screenOrientation="portrait"
android:label="#string/app_name" />
<activity
android:name=".WelcomeActivity"
android:screenOrientation="portrait"
android:label="#string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="#string/google_maps_key" />
<meta-data
android:name="com.google.android.gms.ads.APPLICATION_ID"
android:value="#string/testAppId"/>
<activity
android:name=".MapsActivity"
android:label="#string/title_activity_eater_maps"
android:screenOrientation="portrait">
</activity>
<activity
android:name=".VendorMapsActivity"
android:label="#string/title_activity_vendor_maps"
android:screenOrientation="portrait"/>
</application>
</manifest>
Gradle code:
android {
compileSdkVersion 27
defaultConfig {
applicationId "com.example.zzyzj.man"
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'
signingConfig signingConfigs.config
}
debug {
debuggable true
}
}
}
What I am actually trying to debug:
#Override
protected void onDestroy() {
super.onDestroy();
//TODO: Remove me. Debug only!
while (!Debug.isDebuggerConnected()) {
try {
Log.d(TAG, "Waiting for debugger");
Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
//TODO: Figure out how to delete UID and user when they sign out
removeAnonymousVendorUser();
FirebaseAuth.getInstance().signOut();
finish();
}
Not going too deep, try checking for updates in Android Studio. If there are any please do them and then restart 'Android Studio'
It worked for me :)

How can solve Manifest merger failed with multiple errors?

I'm beginner in android and get this error when try to build project:
Manifest merger failed with multiple errors, see logs
read some answer in stack over flow but can not solve my problem,my gradle is this:
android {
compileSdkVersion 25
buildToolsVersion "25.0.0"
defaultConfig {
applicationId "com.example.behineh.seaapp"
minSdkVersion 14
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
and this is my manifest file:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.example.behineh.seaapp">
<application
android:allowBackup="true"
tools:replace="android:allowBackup"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:supportsRtl="false"
android:roundIcon="#mipmap/ic_launcher_round"
android:theme="#style/AppTheme">
<activity
android:name=".MainActivity"
android:screenOrientation="portrait"></activity>
<activity android:name=".LoginActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
how can i solve problem?thanks all.
my full error log:
Error:Execution failed for task ':app:processDebugManifest'.
> Manifest merger failed with multiple errors, see logs
Your APK file can contain just one AndroidManifest.xml file, but your Android Studio project may contain several—provided by the main source set, build variants, and imported libraries. So when building your app, the Gradle build merges all manifest files into a single manifest file
You can merge manifest like this
<application
tools:node="merge"
tools:replace="android:label, android:icon, android:theme,
android:allowBackup">
</application>
Check android developer documentation for further detail
https://developer.android.com/studio/build/manifest-merge.html

ActionBar is not being displayed anymore after migration from Eclipse to Android Studio

I recently tried to edit my 4 year old android application in the recently appeared Android Studio 2.3.1.
After importing the code I can launch it on my mobile phone. However the action bar seems to have disappeared. What has gone wrong?
How can I tell android to display the action bar?
I have implemented the action bar activity like this:
public class MainActivity extends ActionBarActivity
My build.gradle looks like this:
apply plugin: 'com.android.application'
android {
compileSdkVersion 17
buildToolsVersion "25.0.0"
defaultConfig {
applicationId "de.my.app"
minSdkVersion 8
targetSdkVersion 17
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile 'com.android.support:appcompat-v7:18.0.0'
}
I also tried to replace the compile command with something newer one:
compile 'com.android.support:appcompat-v7:25.3.1'
but already the syncing in android studio fails like this, throwing the following error:
Error:Execution failed for task ':app:processDebugManifest'.
> Manifest merger failed : uses-sdk:minSdkVersion 8 cannot be smaller than version 9 declared in library [com.android.support:appcompat-v7:25.3.1] /home/user/.android/build-cache/815cafa5312f1d889eb1134b2184a62b3f88d8a3/output/AndroidManifest.xml
Suggestion: use tools:overrideLibrary="android.support.v7.appcompat" to force usage
I haven't done much android coding in the last 4 years so I assume the ActionBar stuff has changed profoundly but shouldn't there be a way to compile the old code as it is using android studio?
Edit:
This is the manifest.xml:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="de.myApp.myAppDemo"
android:versionCode="1"
android:versionName="1.0" >
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
<application
android:allowBackup="true"
android:icon="#drawable/icon_app"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="de.myApp.myAppDemo.Splash"
android:label="#string/app_name"
android:screenOrientation="landscape" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="de.myApp.myAppDemo.MainActivity"
android:label="#string/app_name"
android:screenOrientation="landscape"
android:theme="#style/Theme.AppCompat.Light">
<intent-filter>
<action android:name="de.myApp.myAppDemo.MAINACTIVITY" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name="de.myApp.myAppDemo.PropertiesAssign"
android:label="#string/app_name"
android:screenOrientation="landscape" >
<intent-filter>
<action android:name="de.myApp.myAppDemo.PROPERTIESASSIGN" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name="de.myApp.myAppDemo.PropertiesView"
android:label="#string/app_name"
android:screenOrientation="landscape" >
<intent-filter>
<action android:name="de.myApp.myAppDemo.PROPERTIESVIEW" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
</application>
</manifest>
Meanwhile I got at least the ActionBar to be displayed. However I had to increase the MinSDK and targetSdkVersion / compileSdkVersion bigly: From 8,17 to 15,23. Moreover I had to look in the SDK-Manager to see which exact version of Android Support Library was installed on my system (23.2.0) and adapt the corresponding line in build.gradle.
apply plugin: 'com.android.application'
android {
compileSdkVersion 23 //->modified
buildToolsVersion "25.0.0"
defaultConfig {
applicationId "de.Geo.geodraw"
minSdkVersion 15 //->modified
targetSdkVersion 23 //->modified
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile "com.android.support:appcompat-v7:23.2.0" //->modified
}
Not sure whether it was relevant or necessary but following this page I also added
allprojects {
repositories {
jcenter()
maven { //->modified
url "https://maven.google.com" //->modified
} //->modified
}
}
in another build.gradle file.
If there is another solution without drastically changing minSdk and targetSdk I will accept that answer.

How to resolve INSTALL_FAILED_MISSING_SHARED_LIBRARY on Android Things Project

I try to control a GPIO Port on Android App using the Android Things Project.
But when I run this app through ADB(on Android Studio), the following message is issued..
Installation failed with message
INSTALL_FAILED_MISSING_SHARED_LIBRARY. It is possible that this issue
is resolved by uninstalling an existing version of the apk if it is
present, and then re-installing.
WARNING: Uninstalling will remove the application data!
Do you want to uninstall the existing application?
How can I resolve this problem?
Android version is Android 5.1.1(API 22)
My Android App is coded according to the web site which explains the Android Things Project(https://developer.android.com/things/sdk/pio/gpio.html#managing_the_connection)
The build.gradle for app is the following.
apply plugin: 'com.android.application'
android {
compileSdkVersion 24
buildToolsVersion "24.0.3"
defaultConfig {
applicationId "kr.iges.wallpad.gpiotest"
minSdkVersion 15
targetSdkVersion 25
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:25.1.0'
provided 'com.google.android.things:androidthings:0.1-devpreview'
}
And AndroidManifest.xml is
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="kr.iges.wallpad.gpiotest">
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<uses-library android:name="com.google.android.things"/>
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.IOT_LAUNCHER"/>
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
</activity>
</application>
</manifest>
And JAVA Code is
package kr.iges.wallpad.gpiotest;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import com.google.android.things.pio.PeripheralManagerService;
import java.util.List;
public class MainActivity extends AppCompatActivity {
private static final String TAG = "GpioTest";
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
PeripheralManagerService manager = new PeripheralManagerService();
List<String> portList = manager.getGpioList();
if (portList.isEmpty()) {
Log.i(TAG, "No GPIO port available on this device.");
} else {
Log.i(TAG, "List of available ports: " + portList);
}
setContentView(R.layout.activity_main);
}
}
Do you know the solution for this problem?
Thanks for your reading.
Add the things shared library entry to your app's manifest file:
This worked for me. Make sure you add uses-library within the application tag only.
...

Failed to run Google I/O 2014 Android app

Google has released I/O 2014 android app, since it must be an valuable android app demo, so I decided to download it and tried to debug it. But, unfortunately, while I was trying to run it after compiling, it said "This app won't run unless you update google play services", actually the google play services on my phone(Nexus 5, Kitkat 4.4.4) is already the newest. So, in my perspective, I thought it was related to the server configurations, because the I/O app uses some google services, like google plus, google map, etc. I followed the official instructions, but instantly I stuck at the first step:After I renamed the package name in the manifest file(using Android Studio refactoring feature, it will change the activity names accordingly) and refactored the R class imports in the java classes(refactoring by moving the old generated R.java to the new package, it will rearrange the corresponding “.R” imports in all related classes), the app failed to run and complained as followings:
Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=com.google.samples.apps.iosched/.ui.BrowseSessionsActivity }
Error type 3
Error: Activity class {com.google.samples.apps.iosched/com.google.samples.apps.iosched.ui.BrowseSessionsActivity} does not exist.
My new package name is “com.enlangtech.samples.apps.iosched”. I have tried to build a trial app and I am sure now that the app package name can be different with the package that activity classes belong to. So I can’t understand where is the problem. Any one could help me? Thanks for advance!
I had the same error after renaming/refactoring. What I did was add the applicationId property attribute to my build.gradle file, and set its value to the application package.
Like this:
build.gradle file:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.12.+'
}
}
apply plugin: 'com.android.application'
repositories {
mavenCentral()
}
dependencies {
compile 'com.android.support:support-v4:19.1.+'
compile 'com.google.android.gms:play-services:4.3.23'
}
android {
compileSdkVersion 19
buildToolsVersion "19.1"
defaultConfig {
applicationId "packageName"
minSdkVersion 16
targetSdkVersion 19;
}
buildTypes {
release{
runProguard true
proguardFile file('path_to_proguard_file\\proguard-project.txt')
proguardFile getDefaultProguardFile('proguard-android.txt')
}
debug{
runProguard false
}
}
}
androidmanifest.xml:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="myfullpackagename"
android:versionCode="1"
android:versionName="1.0" >
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.MANAGE_ACCOUNTS"/>
<uses-permission android:name="android.permission.GET_ACCOUNTS"/>
<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"/>
<application
android:allowBackup="true"
android:icon="#drawable/launcher_icon"
android:label="#string/app_name"
android:name="mypackagename">
<meta-data
android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version"/>
<activity
android:name="package.Activity"
android:label="#string/app_name"
android:configChanges="orientation|screenSize">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="package.SettingsActivity"
android:configChanges="orientation|screenSize">
<intent-filter>
<action android:name="android.intent.action.MANAGE_NETWORK_USAGE"/>
<action android:name="android.intent.category.DEFAULT"/>
</intent-filter>
</activity>
<activity android:name=".AboutScreen"/>
<service android:name="package.Service"
android:exported="false"/>
<receiver android:name="package.Alarm"/>
<receiver android:name="package.MyBroadcastReceiver">
<intent-filter>
<action android:name="package.MY_BROADCAST_RECEIVER"/>
</intent-filter>
</receiver>
<receiver android:name="package.MyBroadcastReceiver2">
<intent-filter>
<action android:name="package.MY_BROADCAST_RECEIVER_2"/>
</intent-filter>
</receiver>
</application>
</manifest>

Categories

Resources