Firebase Messaging component is not present - android studio - android-studio

Caused by: java.lang.NullPointerException: Firebase Messaging component is not present at com.google.android.gms.common.internal.Preconditions.checkNotNull(com.google.android.gms:play-services-basement##18.0.0:2) at com.google.firebase.messaging.FirebaseMessaging.getInstance(FirebaseMessaging.java:158) at com.google.firebase.messaging.FirebaseMessaging.getInstance(FirebaseMessaging.java:137)
project level gradle: classpath 'com.google.gms:google-services:4.3.13'
app level gradle: implementation platform('com.google.firebase:firebase-bom:30.2.0') implementation 'com.google.firebase:firebase-messaging' // Declare the dependencies for the Crashlytics and Analytics libraries // When using the BoM, you don't specify versions in Firebase library dependencies implementation 'com.google.firebase:firebase-crashlytics' implementation 'com.google.firebase:firebase-analytics' implementation 'com.google.firebase:firebase-messaging'

Related

Android cash : UnsatisfiedLinkError: dlopen failed: cannot locate symbol "pthread_cond_clockwait"

I am trying to import native libraries(.so files) into the android studio.
I created a jniLibs folder and directory with ABI name and respective .so files in it.
made changes in build.gradle and tried to load them.
Then, the error occurs of java.lang.UnsatisfiedLinkError: dlopen failed: cannot locate symbol "pthread_cond_clockwait"
can someone give idea how to solve this issue?
That API is only available on API 30+ devices (note the __INTRODUCED_IN(30)):
int pthread_cond_clockwait(pthread_cond_t* __cond,
pthread_mutex_t* __mutex,
clockid_t __clock,
const struct timespec* __timeout) __INTRODUCED_IN(30);
You're probably seeing the problem on an older device.
As per the Android documentation, it is important to realize that the NDK API level is your app's minimum supported API level:
The API level you build against with the NDK has a very different meaning than compileSdkVersion does for Java. The NDK API level is your app's minimum supported API level. In ndk-build, this is your APP_PLATFORM setting. With CMake, this is -DANDROID_PLATFORM.
So you need to compile the library with the correct NDK API level:
Problem: Your NDK API level is higher than the API supported by your device.
Solution: Set your NDK API level (APP_PLATFORM) to the minimum version of Android your app supports.

Android studio - Unable to add library from outside folder

I am trying to develop an android library and an app using Android Studio. For this, I need to use the library directly in my app project, so I can modify both the library sources and app sources easily.
I am using versions: Android Studio 3.1.2 and Gradle 4.4
First of all, I have tried both methods described in the documentation, but both methods duplicate the library.
Second, I tried to add the library from outside folder as described here, but I get the error:
Unable to find module with Gradle path ':mytestlibrary3-release' (needed by module 'app'.)
My test structure is like this:
In "Workspace" folder I have the app folder "MyApplication4" and library folder "MyTestLib3" containing the library module "mytestlibrary3" (I attached screens)
The application settings.gradle:
include ':app'
include ':mytestlibrary3-release'
project(':mytestlibrary3-release').projectDir = new File(settingsDir, '../MyTestLib3/mytestlibrary3')
and the application build.gradle:
...
dependencies {
...
implementation project(':mytestlibrary3-release')
}
What am I doing wrong here? My purpose is to use the code directly (similar to Eclipse "Add Project to Build Path" or link src folder to source) or to build and use the library as simple and elegant as possible.

How to use releaseImplementation in a library

I am using Android Studio 3.0 with the updated gradle plugin.
I need to use the releaseImplementation keyword in my build.gradle file as I only want the library specified (ACRA) to be built in release. The reason I only want to build ACRA in release is that I've read that Android Studio instant run does not work well with ACRA.
releaseImplementation 'ch.acra:acra:4.9.2'
The problem is, however, that it's a library so I also need to use the api key so I can transitively export in apis to the modules using the library.
api 'ch.acra:acra:4.9.2'
Is it possible to use both keywords or is there a composite keyword to use?
releaseImplementation 'ch.acra:acra:4.9.2'
api 'ch.acra:acra:4.9.2'
In Android Studio 3.0 and newer, the Android Gradle Plugin supports the new Java Library plugin configurations that allow more granular control of dependencies.
As described here, the new Gradle Dependency configurations are available for flavor- or build-type-specific dependencies.
If you wish to use the api dependency configuration for the release build Type, you would add the following:
releaseApi 'ch.acra:acra:4.9.2'
This is the "composite keyword" that you are describing. No additional dependency needs to be specified.

In Android Studio, building an Android Wear project, how can I include the same file in both modules

I am successfully building an Android Wear watch face and connected app on the mobile device. The problem is that I have several resource and class files that are referenced in both the mobile and wear modules. The skeleton app I built this from also created a (non-building) DigitalWatch module and I'm guessing I could move these common files in there and then reference them from my Gradle build files. I've reviewed some of the ideas on Stackoverflow, but the comments suggest they don't work.
Here's my project structure. Common files include res/strings.xml, a utility class, and the google json files.
I've successfully moved both common java utility classes and strings/drawables into a seperate module called "Common" and reference it in both the mobile and wear gradle files as follows
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile project(':common')
...
}
You will have to add imports to reference your java classes in the common module and resources work if you add xmlns:app="http://schemas.android.com/apk/res-auto" to the top element in your layouts.
The google-services.json I have not been able to move as there is a fixed relative reference to this within the Google libraries.

Navigating full Android source code

How can I create and Android project that links to complete android source code, including classes in "android.annotation" ?
More precisely:
Create a new android project in Android Studio 1.5.1, Minimum SDK = API 23. Template: Add no activity.
Add this fix to resolve junit dependency: https://stackoverflow.com/a/32566057/4182868
gradle sync, make project
open class android.app.Activity
Result: a number of import statements are not resolved:
That's because those classes are actually marked as #hide, and are stripped out of the Android SDK at build time. The SDK android.jar that your project is linked with simply doesn't contain those methods and classes, which is why the IDE gets confused when it looks up the source code for the SDK classes.
(Note: We include the same annotations in the support library, but with a different package prefix: android.support.annotation.*. Those are the annotations applications should be using. But the framework itself doesn't depend on the support library, the dependency is in the other direction.)

Resources