I am struggling to implement Google's Firebase push notifications in a mature MVVMcross application. We are being forced to seek a new solution to our current one because it appears that the functionality is about to be deprecated in AppCenter.
We've placed the code inside the RootActivity file (at the bottom of the method)
protected override void OnCreate(Bundle bundle)
When I run the app in a USB/debug scenario on my Android Galaxy I get the current error "Default FirebaseApp is not initialized in this process"
I tried to use the approach that was recommended in the error message to no avail:
FirebaseApp.InitializeApp(RootActivity.Context);
FirebaseMessaging.Instance.GetToken().AddOnCompleteListener(new OnCompleteListener());
In case anyone is wondering here is the code for the method that is mentioned above was setup for testing purposes using a breakpoint:
public class OnCompleteListener : Java.Lang.Object, IOnCompleteListener
{
public void OnComplete(Android.Gms.Tasks.Task task)
{
var token = task.Result.ToString();
}
}
We initially tested this in a standard Xamarin Forms Android app for testing and didn't have any problem with getting the token but we hit the wall when we played with it in our client's MVVMcross app.
I would also like to mention that I have tried the following solution with no luck as well:
var setupSingleton = MvxAndroidSetupSingleton.EnsureSingletonAvailable(Context);
setupSingleton.EnsureInitialized();
FirebaseMessaging.Instance.GetToken().AddOnCompleteListener(new OnCompleteListener());
I found that I had two problems. The first one was the fact that my project name did not match in my manifest and google services key. I was using my own key that I setup for testing. After I realized this I switched back to my client's key and double checked that it was part of the build. As soon as I resolved that issue I found that I needed to install the nuget package for Xamarin.Google.Dagger to resolve the reflection issues. After taking care of that I did a clean/rebuild and ran the debug on my Galaxy S20 test device. This fix allowed me to hit my test break point that I setup for testing the token reception from FCM.
I am trying to set up the Flutter sign_in_with_apple package but run into problems with the android side.
What I have done so far, following the package README to the letter:
Set up the glitch.me server. The server is up and listening at https://MYSERVER.glitch.me/callbacks/sign_in_with_apple I've added a bit of console logging to make sure I know when the server is hit.
Set up appid and serviceid on the apple developer console. Service identifier is com.company.foobar.dev.signin
Added the glitch callback https://MYSERVER.glitch.me/callbacks/sign_in_with_apple as the return url on the service configuration.
Copied the activity block from the readme into my android manifest. NOTE: I didn't know what to set the name. Leave it referring to the package or change it to my app id? It's currently android:name="com.aboutyou.dart_packages.sign_in_with_apple.SignInWithAppleCallback"
Add this block to my flutter service:
"https://MYSERVER.glitch.me/callbacks/sign_in_with_apple";
final appleIdCredential = await SignInWithApple.getAppleIDCredential(
scopes: [
AppleIDAuthorizationScopes.email,
AppleIDAuthorizationScopes.fullName,
],
webAuthenticationOptions: WebAuthenticationOptions(
clientId: "com.company.foobar.dev.signin",
redirectUri: Uri.parse(redirectURL)));
Unfortunately, the call to SignInWithApple.getAppleIDCredential in step 5 throws an exception and I am seeing invalid_request invalid web redirect url. The glitch server is never even hit, which makes me think that even if I messed up at Step 4 (the intent name in the android manifest) the problem is more likely in the apple developer console setup. However, I am pretty sure I've followed the README and I am running out of ideas.
Hmmm, I threw away the apple developer console service setup for the dev package (with applicationIdSuffix '.dev' and bundleid 'com.company.foobar.dev') and set up the same for the production flavor. This one works as expected.
I am now wondering if apple doesn't even redirect the request to the glitch server for android unless the package has as playstore presence. Comments?
Implemented in-app update feature, using the following code snippet:
private void showInAppUpdateDialog(boolean isMandatoryUpdate) {
Task<AppUpdateInfo> appUpdateInfoTask = appUpdateManager.getAppUpdateInfo();
appUpdateInfoTask.addOnSuccessListener(appUpdateInfo -> {
if (appUpdateInfo.updateAvailability() == UpdateAvailability.UPDATE_AVAILABLE
|| appUpdateInfo.updateAvailability() == UpdateAvailability.DEVELOPER_TRIGGERED_UPDATE_IN_PROGRESS) {
int appUpdateType = isMandatoryUpdate ? IMMEDIATE : AppUpdateType.FLEXIBLE;
int requestCode = isMandatoryUpdate ? REQUEST_APP_UPDATE_IMMEDIATE : REQUEST_APP_UPDATE_FLEXIBLE;
if (appUpdateInfo.isUpdateTypeAllowed(appUpdateType)) {
// start the app update
try {
appUpdateManager.startUpdateFlowForResult(appUpdateInfo, appUpdateType, targetActivity, requestCode);
} catch (IntentSender.SendIntentException e) {
e.printStackTrace();
}
}
}
}).addOnFailureListener(e -> {
e.printStackTrace();
});
}
I am testing in-app update on the device which has Android 9. Still, it is giving me following an error (ERROR_API_NOT_AVAILABLE):
com.google.android.play.core.install.InstallException: Install Error(-3): The API is not available on this device. (https://developer.android.com/reference/com/google/android/play/core/install/model/InstallErrorCode#ERROR_API_NOT_AVAILABLE)
at com.google.android.play.core.appupdate.i.a(Unknown Source:24)
at com.google.android.play.core.internal.o.a(Unknown Source:13)
at com.google.android.play.core.internal.j.onTransact(Unknown Source:22)
at android.os.Binder.execTransact(Binder.java:731)
It is saying that check the following link:
https://developer.android.com/reference/com/google/android/play/core/install/model/InstallErrorCode#ERROR_API_NOT_AVAILABLE)
Using Play core library version: 1.6.5
Latest core library version:
implementation 'com.google.android.play:core:1.7.0'
However, I am not able to get why it is saying that ERROR_API_NOT_AVAILABLE. Any help would be appreciated!
Firstly, please check that you are using the latest version of the play library.
Secondly, understated fact: Please check the app you are testing has the same package name which is available on the play store.
Example:
You have an app on the play store with package name com.example.app but you are testing your app with package name com.example.app.debug. You will get this error: ERROR_API_NOT_AVAILABLE
Note: You need to have at least one version of your app on the play store when you are testing.
On top of what Vipal suggested, the issue may be due to a signature mismatch between the version you have installed on the device and the one that Play Store would deliver (this is a common issue if you try to test it with debug builds). See https://developer.android.com/guide/playcore/in-app-updates#troubleshoot
Recently the Play Core API started returning an API_NOT_AVAILABLE error if the app is not owned by the user or the signatures mismatch, while before it used to return a successful UPDATE_NOT_AVAILABLE Task.
The recommendation is:
if you use the Kotlin Extension, make sure that you are catching the exception thrown by requestAppUpdateInfo
if you use PlayCore Java, make sure you have an onFailureListener that handles failures from getAppUpdateInfo
in order to test a debug build, you can use Internal App Sharing, as explained here: https://developer.android.com/guide/playcore/in-app-updates#internal-app-sharing
Source: I work on the Play Core team
My app was working fine before today, but I started getting this error today. One temporary workaround is to clear your Google Play Store cache and storage and then try launching the app. For me, it works only the first time, but fails afterwards. Before launching the app again, I have to clear the cache and storage again. I think there is something wrong on Google Play Store side due to which this issue is happening because everything was fine for me before today.
Got the same error, tried all solutions described here, nothing works.
App installed from Play Store Internal Test track with Version Code 267, then submitted new update to the same track with Version Code 268.
Play Store shows available update but the application still says ERROR_API_NOT_AVAILABLE
Clear Play Store data and cache does not help.
Description of ERROR_API_NOT_AVAILABLE say that it means “API is not available on device”
After carefully reading again this page, I have noticed that “in-app updates support apps running on only Android mobile devices and tablets, and Chrome OS devices”
Android TV not mentioned, I think it’s the reason in my case.
Temporary workaround for the moment is to surround the OnCompleteListener with a :
try {...} catch(e: RuntimeExecutionException) {...}
Just to avoid having to clear the PlayStore cache everytime I relaunch the app
After long time of debugging. I found, this is because of we are testing the app directly in mobile. Even though we generate and use signed apk, this error will occur.
The only way to get rid of this error is, we need to download the app from google play.
We can use Internal app sharing to test or simply publish our app.
Well, in my case we've cleared Google Play app cache and we didn't launch the Google Play before our app. You have to do it to download fresh data from the store, which is necessary for the SDK.
I recently released an application for some users to use my newly made Android Application. However, they are having trouble when they perform the Facebook Login feature that I have made.
It seems to work fine on my phone, but on other phones it seems to crash. I would like to know what is causing the application to crash so I can further debug this. Is there anywhere or anything that I can use to debug this problem further?
I have looked at both the Facebook Developer Console and Google Play Developer Console and neither seem to show or point me to where my error is. If anyone could help that would be great. Thanks!
Use any Crashlytics/Analytics tools to not only get error logs but also usage statictics which can be pretty useful insight during pre-release tests. Some of them like Crashlytics by Fabric are even free and are very easy to integrate. But, there are many others too.
There are plenty of cloud hosted solutions.These might be paid, and require signing up.
If you want to roll you own simple reporting mechanism, then there is an Android library: ARCA . You can set it up to send crash reports to an email address.
First, you'll need to include the library in app's build.gradle file:
compile 'ch.acra:acra:4.9.0'
Then declare extent the Application class (or modify if you already have) as :
import org.acra.*;
import org.acra.annotation.*;
#ReportsCrashes(mailTo = "reports#yourdomain.com",
mode = ReportingInteractionMode.TOAST,
resToastText = R.string.crash_toast_text)
public class MyApplication extends Application {
#Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
// The following line triggers the initialization of ACRA
ACRA.init(this);
}
}
The two thing necessary are:
Add #ReportsCrashes annotation to app's application class, with recipient mail address.
Override attachBaseContext() and include ACRA.init() in it.
Official docs:
Setting up ARCA.
Advanced configuration.
I am trying to run the AWS android samples from https://github.com/awslabs/aws-sdk-android-samples
I have included the following jars in libs:
aws-android-sdk-2.0.4-cognito.jar
aws-android-sdk-2.0.4-core.jar
aws-android-sdk-2.0.4-s3.jar
Also I have added the AWS_ACCOUNT_ID, COGNITO_POOL_ID, COGNITO_ROLE_UNAUTH, BUCKET_NAME
this is the logcat
When im runnig this sample, action and then program shuts down.
What is problem?
I don't know what to do.
The stacktrace shows accountId is malformed. The accountId isn't your login email of your AWS account. Instead, it should be a 12 digit account number. One way to find it is to go to console -> My Account (top right corner).
PS: consider use the latest SDK version v2.2.2. It has lots of improvements compared to v2.0.4. You can find it at http://aws.amazon.com/mobile/sdk/.