Android Studio doesn't recognize InstanceID class - android-studio

I want to implement GCM Client on Android.
Following the guide here
https://developers.google.com/cloud-messaging/android/client
I have downloaded the configuration file and copied the google-services.json file into the app/ directory of the project.
I have also added the dependencies in the project's build.gradle
classpath 'com.google.gms:google-services:1.3.0-beta1'
and plugin in the app level build.gradle
apply plugin: 'com.google.gms.google-services'
I have also included the Google Play Services SDK
compile 'com.google.android.gms:play-services:6.+'
I have also updated the AndroidManifest.xml file as shown here
https://developers.google.com/cloud-messaging/android/client
To get the Registration Token, when I use the following code
InstanceID instanceID = InstanceID.getInstance(this);
Android Studio does not recognize the class. I get a "Cannot resolve symbol 'InstaceID'". Any reason as to why this is happening?

Update your Play services SDK to
compile 'com.google.android.gms:play-services:7.5.0'
Then clean your Project.
Worked for me. Hope it works for you too!

you are missing the gcm
add on your gradle:
compile "com.google.android.gms:play-services-gcm:10.2.6"

Basically, you have to use the latest version of the Google Play Services, Android Support Repository and Google Repository for this to work, and then include the latest version of the Google Play Services
compile 'com.google.android.gms:play-services:7.5.0'

Checks an official firebase documentation and imports the latest version om.google.firebase:firebase-messaging
eg: implementation 'com.google.firebase:firebase-messaging:17.3.3'

Related

Android Studio - Cannot resolve com.google.firebase.analytics

I am using Android Studio and (tried) to add firebase.analytics via the menu (tools->firebase). I added the analytics function but
import com.google.firebase.analytics.FirebaseAnalytics;
results in an error since "analytics" cannot be resolved.
What is missing?
Many thanks!
Please make sure you've compiled all needed firebase libraries for analytics in your gradle app file.
dependencies {
// ...
compile 'com.google.firebase:firebase-core:11.8.0'
// Getting a "Could not find" error? Make sure you have
// added the Google maven respository to your root build.gradle
}
Check this for more information : https://firebase.google.com/docs/analytics/android/start/

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.

React-native Google Cast Library

(this is probably a stupid question, but here goes..)
I've been trying for some days now at having a go at creating a integrated cast that works with react-native, but can't get it working.
Is there any easy way of integrating the cast library with react-native, any go-to examples like the CastHelloText-Android for example?
You may check this react-native-google-cast library that unifies both android and iOS chromecast sdk.
For iOS
This library requires Cocoapods to manage Chromecast SDK.
Add pod google-cast-sdk to your Podfile. This is the easier way to have the SDK up to date.
For Android
This library requires Google Play Services, Media Router and Google Cast dependencies to manage Chromecast SDK.
You need to add compile 'com.google.android.gms:play-services-cast:9.4.0' and compile 'com.android.support:mediarouter-v7:23.0.1' into your your app's build.gradle dependencies. mediarouterversion must match with your appcompat version.
Refer to the example folder to find an implementation of this project. Use pod install and react-native link react-native-google-cast to try it.

Dependencies search result ended up in no result but when hardcored; it worked. Why?

I tried to add jackson dependancies in android studio, the dependencies search within the android studio returned some other libraries, but when i hardcored these dependencies it synced successfully. So basically the results came from rather than bintray.com ?
compile 'com.fasterxml.jackson.core:jackson-databind:2.8.5'
compile 'com.fasterxml.jackson.core:jackson-core:2.8.5'
compile 'com.fasterxml.jackson.core:jackson-annotations:2.8.5'
It seems that all the dependencies exist in JCenter (under bintray.com).
Here are the links in Jcenter to each of the dependencies you were looking for:
jackson-databind
jackson-core
jackson-annotations
You can also see that the JCenter is updated until version 2.8.6.
Please check if your Android Studio is configured to get all its dependencies from JCenter.
I assume that maybe there is a mistake in the basic search you have made, so if you can provide us with more information it will be much more helpful.
In any case you can contact JFrog Support to get more helpful details.
I am with JFrog, the company behind bintray and artifactory.

Unable to use #Entity ,#Id annotations in android studio

I am a newbie in using google loud endpoints in m android app.
I followed several tutorials on developing a GAE back-end for my android app in android studio.
I made an android app and then auto-generated back-end for it.
In back-end module I created a bean and auto-generated end point class for it. But when I try to add annotations like #Entity,#Id etc then they are not recogniZed.
I have added objectify-4.0b1 jar to WEB-INF/lib in api project.
What am I missing?
Please advise.
Manish
The IDE needs to know about the objectify library. Did you use the Google Cloud Module generation built into Android Studio to create your endpoint? If so you should have your backend configured through Gradle. This would give you two options:
option 1) is add the following line to your dependencies clause in your backend build.gradle:
compile 'com.googlecode.objectify:objectify:4.0b1'
Although the latest version is 5.1.4 so if you can you should just use that.
option 2) is to go to file -> project structure, then select your backend module and add a library dependency. That will popup a search dialog where you can search for the objectify dependency and automatically add it to your module. This will update your build.gradle for you.

Resources