Android: ActivityCompat.requestPermissions does not show a popup (Android 13, targetSdkVersion=33) - android

EDITS BELOW =)
There are many many many questions on this topic on SO already, I know. However, none of the answers I have found so far resolves the issue for me.
The problem:
That the ActivityCompat.requestPermissions does not trigger a popup, asking the user to give permission for notifications.
Setup:
Testing on physical device (Android 13, Pixel 6)
Targeting SDK version 33 (targetSdkVersion=33)
minSdkVersion = 29
AndroidManifest has permission: <uses-permission android:name="android.permission.POST_NOTIFICATION" />
in onCreate in an otherwise working Activity, I do:
if (ContextCompat.checkSelfPermission(this, Manifest.permission.POST_NOTIFICATIONS) == PackageManager.PERMISSION_DENIED)
{
ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.POST_NOTIFICATIONS}, 1);
}
and the callback is like so:
#Override
public void onRequestPermissionsResult(int requestCode, String[] permissions,int[] grantResults) {
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
switch (requestCode) {
case 1:
if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
Toast.makeText(MainScreenActivity.this, "Woho, you have enabled notifications!", Toast.LENGTH_SHORT).show();
} else {
Toast.makeText(MainScreenActivity.this, "Ouch, this is gonna hurt without notifications", Toast.LENGTH_SHORT).show();
}
return;
}
}
Here are the build.gradle files:
TheApp\build.gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
maven { url 'https://raw.github.com/xujiaao/mvn-repository/master/releases' }
maven {
url 'https://jitpack.io'
}
maven { url 'http://dl.bintray.com/ahmedrizwan/maven'
allowInsecureProtocol = true
}
google()
}
dependencies {
classpath 'com.google.gms:google-services:4.3.10' // Google Services plugin
classpath 'com.google.firebase:firebase-crashlytics-gradle:2.5.2'
classpath 'com.android.tools.build:gradle:7.3.1'
classpath "io.realm:realm-gradle-plugin:10.0.0"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
maven { url 'http://oss.jfrog.org/artifactory/oss-snapshot-local'
allowInsecureProtocol = true
}
google()
jcenter()
flatDir {
dirs 'src/main/libs'
}
}
}
TheApp\app\build.gradle
apply plugin: 'com.android.application'
apply plugin: 'realm-android'
apply plugin: 'com.google.firebase.crashlytics'
android {
compileSdkVersion 33
lintOptions {
abortOnError false
}
buildFeatures{
dataBinding = true
}
defaultConfig {
applicationId "test.myapp"
minSdkVersion 29
targetSdkVersion 33
versionCode 60
versionName "1.60"
}
buildTypes {
debug {
signingConfig signingConfigs.debug_keystore
aaptOptions.setProperty("cruncherEnabled", false)
}
release {
signingConfig signingConfigs.release_keystore
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
aaptOptions.setProperty("cruncherEnabled", false)
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
namespace 'test.myapp'
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'com.google.android.material:material:1.2.1'
implementation 'androidx.cardview:cardview:1.0.0'
implementation 'com.google.firebase:firebase-core:17.5.1'
implementation 'com.google.firebase:firebase-messaging:20.3.0'
implementation 'com.google.code.gson:gson:2.8.6'
implementation 'androidx.recyclerview:recyclerview:1.1.0'
implementation 'com.google.android.gms:play-services-gcm:17.0.0'
implementation 'com.google.android.gms:play-services-location:17.1.0'
implementation 'com.google.android.gms:play-services-maps:17.0.0'
implementation "androidx.lifecycle:lifecycle-extensions:2.2.0"
implementation "androidx.preference:preference-ktx:1.1.1"
implementation 'com.google.firebase:firebase-crashlytics:17.2.2'
implementation 'com.google.firebase:firebase-analytics:17.6.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.2'
implementation 'com.google.android.play:app-update:2.0.1'
def fragment_version = "1.5.4"
// Java language implementation
implementation "androidx.fragment:fragment:$fragment_version"
// Kotlin
implementation "androidx.fragment:fragment-ktx:$fragment_version"
// Testing Fragments in Isolation
debugImplementation "androidx.fragment:fragment-testing:$fragment_version"
}
apply plugin: 'com.google.gms.google-services' // Google Play services Gradle plugin
I have stepped through the code via the debugger, and can confirm that the requestPermissions is executed, but that the onRequestPermissionsResult is triggered immediately with no popup on device.
I also read this, but I figured that it was down to developers not implementing the opt-in model as described here, but maybe, this is an issue after all? Cause I cannot make sense of this...
UPDATE
I ask for other permissions in other parts of the app, and this line works well - I get the popup to grant permission:
ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.READ_PHONE_STATE}, BaseActivity.PHONE_STATE_PERMISSION_CODE);
UPDATE 2
In another part of the code base, I have the same requestPermission call, but for another permission, and this works like a charm:
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_splash);
ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.READ_PHONE_STATE}, BaseActivity.PHONE_STATE_PERMISSION_CODE);
}
When this is executed, I get this:
But, if I change the requestPermissions call so it looks like this, nothing happens and I get to the callback immediately, with a "rejected":
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_splash);
ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.POST_NOTIFICATIONS}, BaseActivity.PHONE_STATE_PERMISSION_CODE);
}
Picture:
UPDATE 3
I have also tried using the new ActivityResultLauncher, but the behaviour is the same - it goes directly to the callback without showing any popup.

Stupid me. In the Q above, I did post what the AndroidManifest contained, and I wrote:
<uses-permission android:name="android.permission.POST_NOTIFICATION" />
This is not correct. I am missing an s, it shoul be:
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
Oops! :-)

update your AndroidX dependency, as only newest ones will have code handling freshly introduced permission.
replace
implementation 'androidx.appcompat:appcompat:1.2.0'
with
implementation 'androidx.appcompat:appcompat:1.5.1'
generally try to update (and consolidate) AndroidX libs version

Related

Unable to resolve Mapbox dependencies

I have been trying to integrate some on new features from Mapbox into my app but gradle is. unable to resolve the. newly added dependencies.
these. are. the dependencies that are not getting resolved
implementation 'com.mapbox.maps:android:10.0.0-rc.8'
implementation 'com.mapbox.plugin:maps-annotation:10.0.0-rc.8'
implementation 'com.mapbox.plugin:maps-locationcomponent:10.0.0-rc.8'
implementation 'com.mapbox.plugin:maps-gestures:10.0.0-rc.8'
implementation 'com.mapbox.plugin:maps-compass:10.0.0-rc.8'
implementation 'com.mapbox.plugin:maps-animation:10.0.0-rc.8'
implementation 'com.mapbox.plugin:maps-scalebar:10.0.0-rc.8'
implementation 'com.mapbox.plugin:maps-logo:10.0.0-rc.8'
implementation 'com.mapbox.plugin:maps-attribution:10.0.0-rc.8'
this is my. build.gradle file app level
plugins {
id 'com.android.application'
id 'kotlin-android'
id 'kotlin-kapt'
}
android {
compileSdk 31
defaultConfig {
applicationId "com.example.a3dmapbox"
minSdk 21
targetSdk 31
versionCode 1
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'
}
buildFeatures{
dataBinding true
}
}
dependencies {
implementation 'androidx.core:core-ktx:1.6.0'
implementation 'androidx.appcompat:appcompat:1.3.1'
implementation 'com.google.android.material:material:1.4.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.1'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
// Mapbox
implementation 'com.mapbox.mapboxsdk:mapbox-android-sdk:9.2.0'
implementation "com.gorisse.thomas.sceneform:sceneform:1.20.1"
implementation 'com.mapbox.mapboxsdk:mapbox-sdk-services:5.6.0'
implementation 'com.mapbox.mapboxsdk:mapbox-android-plugin-building-v9:0.7.0'
implementation 'com.mapbox.mapboxsdk:mapbox-android-plugin-annotation-v9:0.9.0'
implementation 'com.mapbox.mapboxsdk:mapbox-android-plugin-markerview-v9:0.4.0'
implementation 'com.mapbox.mapboxsdk:mapbox-android-plugin-locationlayer:0.11.0'
implementation("com.google.android.gms:play-services-location:18.0.0")
implementation 'com.mapbox.maps:android:10.0.0-rc.8'
implementation 'com.mapbox.plugin:maps-annotation:10.0.0-rc.8'
implementation 'com.mapbox.plugin:maps-locationcomponent:10.0.0-rc.8'
implementation 'com.mapbox.plugin:maps-gestures:10.0.0-rc.8'
implementation 'com.mapbox.plugin:maps-compass:10.0.0-rc.8'
implementation 'com.mapbox.plugin:maps-animation:10.0.0-rc.8'
implementation 'com.mapbox.plugin:maps-scalebar:10.0.0-rc.8'
implementation 'com.mapbox.plugin:maps-logo:10.0.0-rc.8'
implementation 'com.mapbox.plugin:maps-attribution:10.0.0-rc.8'
}
this is my. project. level build.gradle file
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
mavenCentral()
maven {
url 'https://api.mapbox.com/downloads/v2/releases/maven'
authentication {
basic(BasicAuthentication)
}
credentials {
// Do not change the username below.
// This should always be `mapbox` (not your username).
username = 'mapbox'
// Use the secret token you stored in gradle.properties as the password
password = project.properties['MAPBOX_DOWNLOADS_TOKEN']
}
}
}
dependencies {
classpath "com.android.tools.build:gradle:7.0.3"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.20"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
I have configured the download token mapboxsdk is downloaded perfectly only the. newly added dependencies are making the issue
They won't resolve because you are using old references, chamge them to the new sdk implementations. For example for anotations:
implementation
'com.mapbox.mapboxsdk:mapbox-android-plugin-annotation-v9:0.9.0'
Reference
https://docs.mapbox.com/android/plugins/guides/annotation/
The issue here was that I was not specifying the repositories for all projects, in my build.gradle project level it should be like this
buildscript {
repositories {
google()
mavenCentral()
}
dependencies {
classpath "com.android.tools.build:gradle:7.0.3"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.20"
}
}
allprojects {
repositories {
google()
mavenCentral()
maven {
url 'https://api.mapbox.com/downloads/v2/releases/maven'
authentication {
basic(BasicAuthentication)
}
credentials {
// Do not change the username below.
// This should always be `mapbox` (not your username).
username = 'mapbox'
// Use the secret token you stored in gradle.properties as the password
password = project.properties['MAPBOX_DOWNLOADS_TOKEN']
}
}
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}

Azure spatial anchors integration issues. Missing NativeLibrary implementations

I've been tinkering with Azure's spatial anchors API. I followed the docs and examples provided by Microsoft without many issues until I tried to make my own project from it. When I try to run a custom project using the Spatial anchors API it crashes looking for some functions that should be provided by the libraries specified in the gradle. The error log says this:
2019-05-28 10:32:10.642 28982-28982/com.azurelib.azureanchorsclean E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.azurelib.azureanchorsclean, PID: 28982
java.lang.UnsatisfiedLinkError: No implementation found for com.microsoft.azure.spatialanchors.status com.microsoft.azure.spatialanchors.NativeLibrary.ssc_cloud_spatial_anchor_session_create(com.microsoft.azure.spatialanchors.Out) (tried Java_com_microsoft_azure_spatialanchors_NativeLibrary_ssc_1cloud_1spatial_1anchor_1session_1create and Java_com_microsoft_azure_spatialanchors_NativeLibrary_ssc_1cloud_1spatial_1anchor_1session_1create__Lcom_microsoft_azure_spatialanchors_Out_2)
at com.microsoft.azure.spatialanchors.NativeLibrary.ssc_cloud_spatial_anchor_session_create(Native Method)
...
The relevant ssc_cloud... functions can be found in the spatialanchors_java dependency specified in the gradle build:
For the cloud session, I start a new activity in my MainActivity's onResume():
#Override
protected void onResume(){
super.onResume();
Intent intent = new Intent(this, AzureSpatialAnchorsActivity.class);
intent.putExtra("BasicDemo", true);
startActivity(intent);
}
And on AzureSpatialAnchorsActivity I create the ArCore Session and start the anchor manager:
#Override
protected void onResume() {
super.onResume();
if (session == null) {
try {
...
// Create the session.
session = new Session(/* context= */ this);
... //Required catch statements
} catch (Exception e) {
message = "Failed to create AR session";
exception = e;
}
}
try {
session.resume();
startNewSession();
} catch (CameraNotAvailableException e) {
...
}
}
private void startNewSession() {
destroySession();
cloudAnchorManager = new AzureSpatialAnchorsManager(session);
cloudAnchorManager.addAnchorLocatedListener(this::onAnchorLocated);
cloudAnchorManager.addLocateAnchorsCompletedListener(this::onLocateAnchorsCompleted);
cloudAnchorManager.addSessionUpdatedListener(this::onSessionUpdated);
cloudAnchorManager.start();
}
The error happens because when I try to create a CloudSpatialAnchorSession object
public AzureSpatialAnchorsManager(Session arCoreSession) {
spatialAnchorsSession = new CloudSpatialAnchorSession();
...
}
the constructor calls a function from NativeLibrary
public CloudSpatialAnchorSession() {
Out<Long> result_handle = new Out();
status resultStatus = NativeLibrary.ssc_cloud_spatial_anchor_session_create(result_handle);
this.handle = (Long)result_handle.value;
NativeLibraryHelpers.checkStatus(this.handle, resultStatus);
CookieTracker.add(this);
}
The problem seems to be that what I previously showed on the the jar screenshot is all there is. ssc_cloud_spatial_anchor_session_create gets called, the application lands on an dead end:
class NativeLibrary {
NativeLibrary() {
}
...
static native status ssc_cloud_spatial_anchor_session_create(Out<Long> var0);
...
}
The gradle and other configs are copy/paste from the original Microsoft sample. I can't find what I'm missing that's causing my custom project not to find the implementations of NativeLibrary. For reference, here's the Microsoft project that I'm using to base my own project of
Here's my actual gradle files just for reference:
Project gradle
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.3.2'
}
}
allprojects {
repositories {
mavenLocal()
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Module gradle:
apply plugin: 'com.android.application'
def azureSpatialAnchorsSdkVersion = '1.1.0'
android {
compileSdkVersion 27
defaultConfig {
applicationId "com.azurelib.azureanchorsclean"
minSdkVersion 24
targetSdkVersion 27
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.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
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.google.ar:core:1.7.0'
implementation "com.microsoft.azure.spatialanchors:spatialanchors_jni:[${azureSpatialAnchorsSdkVersion}]"
implementation "com.microsoft.azure.spatialanchors:spatialanchors_java:[${azureSpatialAnchorsSdkVersion}]"
implementation 'de.javagl:obj:0.2.1'
implementation 'com.microsoft.aad:adal:1.16.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'
}
Thanks!
Since you are creating your own project are you calling the initialize method inside your OnCreate in the application class?
#Override
public void onCreate() {
super.onCreate();
// Use application's context to initialize CloudServices!
CloudServices.initialize(this);
}

Unable to authenticate with Firebase

I am trying to sign in to Firebase on an emulator using credentials I added via the console.
Here is the code:
val auth = FirebaseAuth.getInstance()
auth.signInWithEmailAndPassword(email, password)
.addOnCompleteListener(this) { task ->
if (task.isSuccessful) {
// ...
} else {
// ...
}
}
The OnCompleteListener callback is never triggered.
I have followed the guidelines from the Firebase documentation
google-services json file
Project dependencies
App dependencies
Enabled email/password sign in method
Any idea what I am doing wrong?
Gradle file - project:
buildscript {
ext.kotlin_version = '1.2.60'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.3'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.google.gms:google-services:4.0.2'
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Gradle file - app
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
android {
compileSdkVersion 27
defaultConfig {
applicationId "..."
minSdkVersion 23
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-jre7:$kotlin_version"
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support:design:27.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.1.2'
implementation 'com.google.firebase:firebase-auth:16.0.2'
implementation 'com.google.firebase:firebase-database:16.0.1'
implementation 'com.google.firebase:firebase-core:16.0.1'
}
apply plugin: 'com.google.gms.google-services'
Is your email or password are valid?
You can add 'addOnFailureListener' to see what really happened.
auth.signInWithEmailAndPassword(email, password)
.addOnCompleteListener(this) { task ->
if (task.isSuccessful) {
// ...
} else {
// ...
}
}).addOnFailureListener(new OnFailureListener() {
#Override
public void onFailure(#NonNull Exception e) {
Toast.makeText(context, e.getMessage(),Toast.LENGTH_SHORT).show();
}
});
Try to add the following dependency in the build.gradle file:-
implementation 'com.google.firebase:firebase-core:16.0.1'
And I also recommend you to use the latest firebase dependencies.
I solved the issue by
Adding a new emulator
Enabling Identity Toolkit API in developer console (error visible in logcat on new emulator only)
This solution may be helpful for those of you who are using an emulator and have tried all the suggested answers...

com.google.firebase:firebase-config:16.0.0 not working

I did everything by following the instructions. But mFirebaseRemoteConfig.fetch(cacheExpiration) haven't been working.
But when I changed a version to the earlier in my app build gradle file from
implementation 'com.google.firebase:firebase-config:16.0.0'
to
implementation 'com.google.firebase:firebase-config:11.0.4'
it's become working..
Do you have any idea, what can be the reason of it?
Also I checked in my previous projects. I changed the version from 11.0.4 to 16.0.0 and fetching stoped working...
my app build gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 27
defaultConfig {
applicationId "com.bestworldgames.bestwordgame"
minSdkVersion 15
targetSdkVersion 27
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
android.defaultConfig.vectorDrawables.useSupportLibrary = true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.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.android.support:recyclerview-v7:27.1.1'
implementation 'com.android.support:cardview-v7:27.1.1'
implementation 'com.android.support:design:27.1.1'
implementation 'com.inkapplications.viewpageindicator:library:2.4.3'
implementation 'com.startapp:inapp-sdk:3.8.4'
implementation 'com.google.firebase:firebase-config:16.0.0'
implementation 'com.google.firebase:firebase-core:16.0.0'
implementation('cn.trinea.android.view.autoscrollviewpager:android-auto-scroll-view-pager:1.1.2') {
exclude module: 'support-v4'
}
}
apply plugin: 'com.google.gms.google-services'
my project gradle file:
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.2'
classpath 'com.google.gms:google-services:4.0.1'
}
}
allprojects {
repositories {
google()
jcenter()
maven {
url "https://maven.google.com"
}
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Added:
mFirebaseRemoteConfig.fetch(cacheExpiration) not working is mean that public void onComplete(#NonNull Task<Void> task) haven't been called.
mFirebaseRemoteConfig.fetch(cacheExpiration)
.addOnCompleteListener(this, new OnCompleteListener<Void>() {
#Override
public void onComplete(#NonNull Task<Void> task) {
if (task.isSuccessful()) {
Toast.makeText(MainActivity.this, "Fetch Succeeded",
Toast.LENGTH_SHORT).show();
// After config data is successfully fetched, it must be activated before newly fetched
// values are returned.
mFirebaseRemoteConfig.activateFetched();
} else {
Toast.makeText(MainActivity.this, "Fetch Failed",
Toast.LENGTH_SHORT).show();
}
displayWelcomeMessage();
}
});
logcat:
06-04 17:39:55.966 10786-10826/com.bestwordgame W/GooglePlayServicesUtil: Google Play services out of date. Requires 12451000 but found 11509470
06-04 17:39:55.966 10786-10786/com.bestwordgame W/FA: Service connection failed: ConnectionResult{statusCode=SERVICE_VERSION_UPDATE_REQUIRED, resolution=null, message=null}
The promlem is in emulator, I guess.. But now I can't find Google Play settings in the emulator's extanded window.. If I'm right, Is there another way to update Google Play Services on emulator?
This is my SDK Settings
with 'Show package details':
Yes, the problem is in emulator. But also I've found out that it's better to check the device for a compatible Google Play services by GoogleApiAvailability.makeGooglePlayServicesAvailable() method.
See the link.
It's my verification method, wich I call at onCreate():
private void checkGooglePlayServices() {
GoogleApiAvailability api = GoogleApiAvailability.getInstance();
int status = api.isGooglePlayServicesAvailable(this);
Log.i("TAG", "AppController checkGooglePlayServices status " + status);
if (status != ConnectionResult.SUCCESS) {
api.makeGooglePlayServicesAvailable(this);
}
}
You need to add:
implementation 'com.google.firebase:firebase-core:16.0.0'
Your app gradle file now has to explicitly list com.google.firebase:firebase-core as a dependency for Firebase services to work as expected.
more info here:
https://firebase.google.com/support/release-notes/android
Faced the same problem. I just replaced the google() by maven { url 'https://maven.google.com' }, then it started working.
Refer the quickstart app here.

Android Studio "Unable to merge dex"

I keep getting this error. I cleaned everything, build, Rebuild, jumbomode, MultidexApplication I tried everything as possible I can, but everything didn't work out.
Sometimes it is necessary to remove the dependency one by one, but now it is useless.
I got stuck on this error from this error more than a week. anybody knows how to fix it out?
There's my config files below.
app.gradle
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
repositories {
maven {
url 'https://maven.fabric.io/public'
}
}
android {
compileSdkVersion 26
buildToolsVersion '26.0.2'
defaultConfig {
applicationId ""
minSdkVersion 21
targetSdkVersion 26
versionCode 6
versionName "1.0.5"
multiDexEnabled true
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
/*manifestPlaceholders = [ onesignal_app_id: "",
onesignal_google_project_number: "REMOTE" ]*/
manifestPlaceholders = [
manifestApplicationId : "${applicationId}",
onesignal_app_id : "",
onesignal_google_project_number: ""
]
}
dexOptions {
// jumboMode true
javaMaxHeapSize "4g"
preDexLibraries = false
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
debug {
ext.enableCrashlytics = false
}
}
dataBinding {
enabled = true
}
}
dependencies {
//noinspection GradleCompatible
implementation 'com.android.support:design:26.1.0'
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:support-v4:26.1.0'
androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
//noinspection GradleCompatible
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support:cardview-v7:26.1.0'
// implementation 'com.android.support:customtabs:26.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
testImplementation 'junit:junit:4.12'
// one signal
implementation 'com.onesignal:OneSignal:3.7.1#aar'
// zendesk
implementation 'com.zendesk:sdk:1.10.0.1'
implementation('com.zendesk:sdk:1.10.0.1#aar') {
transitive = true
}
// UnifyID
implementation 'id.unify.sdk:sdk:0.8.1'
implementation 'com.android.support:multidex:1.0.2'
// circle ImageView
implementation 'de.hdodenhof:circleimageview:2.1.0'
// fabric
implementation('com.crashlytics.sdk.android:crashlytics:2.6.8#aar') {
transitive = true
}
// fitChart
implementation 'com.txusballesteros:FitChart:1.0'
// retrofit2
implementation 'com.squareup.retrofit2:retrofit:2.3.0'
implementation 'com.squareup.retrofit2:converter-gson:2.3.0'
// google play services(google fit, google map, location)
//noinspection GradleCompatible,UseOfBundledGooglePlayServices
// implementation 'com.google.android.gms:play-services:11.8.0'
//noinspection GradleCompatible
implementation 'com.google.android.gms:play-services-fitness:11.8.0'
implementation 'com.google.android.gms:play-services-maps:11.8.0'
// implementation 'com.google.android.gms:play-services-location:11.8.0'
// implementation 'com.google.android.gms:play-services-places:11.8.0'
// firebase
implementation 'com.google.firebase:firebase-core:11.8.0'
implementation 'com.google.firebase:firebase-auth:11.8.0'
// facebook
implementation 'com.facebook.android:facebook-android-sdk:4.25.0'
implementation 'com.twitter.sdk.android:twitter:3.1.1'
// glide
implementation 'com.github.bumptech.glide:glide:4.5.0'
annotationProcessor 'com.github.bumptech.glide:compiler:4.5.0'
}
project.gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules.
//apply plugin: 'com.jfrog.artifactory'
//apply plugin: 'maven-publish'
buildscript {
repositories {
jcenter()
mavenCentral()
maven { url 'https://maven.fabric.io/public' }
maven { url "https://maven.google.com" }
//maven { url "https://artifacts.unify.id" }
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
classpath 'com.google.gms:google-services:3.1.0'
classpath 'io.fabric.tools:gradle:1.25.1'
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
// classpath 'io.fabric.tools:gradle:1.22.1'
//classpath "org.jfrog.buildinfo:build-info-extractor-gradle:latest.release"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
maven { url "https://jitpack.io" }
maven {
url "http://gradle.unify.id/artifactory/gradle-release"
credentials {
username = ""
password = ""
}
}
maven { url 'https://zendesk.jfrog.io/zendesk/repo' }
maven { url "https://maven.google.com" }
google()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Try the different version combinations of gms:play-services:X.X.X library and also try by adding this code in your app module build.gradle file
android {
defaultConfig {
multiDexEnabled true
}
}
If u overridinig your Application class you need to do this
public class MyApplication extends SomeOtherApplication {
#Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
MultiDex.install(this);
}
}
if that is not the case than u should in your manifest file in your application tag add this
<application
android:name="android.support.multidex.MultiDexApplication" >
...
</application>
Hope this will help you,in my app I have multidex and everything is working fine.

Categories

Resources