Android Azure notification hub SDK is not working in Android Pie.
Below are the SDK details:
mavel url: "http://dl.bintray.com/microsoftazuremobile/SDK"
dependencies:
compile 'com.microsoft.azure:notification-hubs-android-sdk:0.4#aar'
compile 'com.microsoft.azure:azure-notifications-handler:1.0.1#aar'
Steps to reproduce:
Receive GCM/FCM token
Create instance of NotificationHub
Call method "registerTemplate" using the instance of NotificationHub along with the required parameters.
Error:
Caused by: java.lang.NoClassDefFoundError: Failed resolution of: Landroid/net/http/AndroidHttpClient;
at com.microsoft.windowsazure.messaging.Connection.executeRequest(Connection.java:217)
at com.microsoft.windowsazure.messaging.Connection.executeRequest(Connection.java:178)
at com.microsoft.windowsazure.messaging.Connection.executeRequest(Connection.java:134)
at com.microsoft.windowsazure.messaging.NotificationHub.refreshRegistrationInformation(NotificationHub.java:296)
at com.microsoft.windowsazure.messaging.NotificationHub.registerInternal(NotificationHub.java:390)
at com.microsoft.windowsazure.messaging.NotificationHub.registerTemplate(NotificationHub.java:196)
Update your Android Support Library to the latest version will fix the problem. Along with that, a clean and rebuild of the project and a restart of Android Studio could also help.
Currently in Android Pie the reference for httpclient has removed completly from system ClassLoader. Above issue can be fixed if we add the httpclient as a part of application ClassLoader. I have added
<uses-library android:name="org.apache.http.legacy" android:required="false" />
inside application tag of manifest file, it's working now.
For more information please refer below link:
https://developer.android.com/about/versions/pie/android-9.0-changes-28#apache-p
This has been fixed in the 0.5 version of Azure Notification Hub Android SDK.
Update your Azure dependency to:
implementation 'com.microsoft.azure:notification-hubs-android-sdk:0.5#aar'
This version uses HttpUrlConnection instead of the legacy HttpClient. See pull request: https://github.com/Azure/azure-notificationhubs/pull/48
i just update google play services package, but its not working for me.Also i add
<meta-data
android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version" />
to manifiset and compile 'com.google.android.gms:play-services:6.1.+' to build. gradle but its not working for me.
You are still using an old version of PLAY Service because Places was added in version v.9.4 as mention in the official docs releases too
so simply update your gms dependencies to latest one i.e.
compile 'com.google.android.gms:play-services:11.6.0'
You can also add individual API using appropriate version as mention under Table 1 here
So use individual API if you can because this will avoid the need of Multudex in future although there is no Individual APP INDEXING API build.gradle description mention in the docs
My Android app has been successfully using maps by including the following in my gradle ...
compile project(':googleplayservices_lib')
My SDK manager says I have rev 32 which appears to be the latest. So with this, everything has been working just fine.
Now I'm enhancing the app and I saw some posts that says I can now use zIndex parameter when adding a marker to control the Z Index. But to do this I must add the following to my gradle . . .
compile 'com.google.android.gms:play-services-maps:9.2.0'
So now my gradle file has this dependencies section . . .
dependencies {
compile project(':library')
compile project(':googleplayservices_lib')
compile files('libs/gson-2.2.4.jar')
compile 'com.android.support:appcompat-v7:22.0.0'
compile 'com.android.support:design:22.2.1'
compile 'com.google.android.gms:play-services-maps:9.2.0'
}
Now I'm able to set zIndex but this new version apparently comes with breaking changes. For instance the following no longer works . . .
map = ((SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map))
.getMap();
map is a GoogleMap. The compiler cannot resolve the getMap() method. My problem is that I can't seem to locate the documentation on this new maps revision where it discusses breaking changes for this new version. Does anyone know where I can find such information?
My Android app has been successfully using maps by including the following in my gradle
Presumably, that is an in-project copy of the old Eclipse library project edition of the Play Services SDK. Ideally, you would have moved off of that to the Play Services SDK artifacts back when you moved to Android Studio.
My SDK manager says I have rev 32 which appears to be the latest
Since you are using a local in-project copy, what the SDK Manager reports is not directly relevant.
Also, Google has not been maintaining that library project for at least the past several months, so "latest" of that library is meaningless with respect to using the latest version of the Play Services SDK.
So now my gradle file has this dependencies section . . .
I am surprised that compiles. Remove compile project(':googleplayservices_lib'). If you are using parts of the Play Services SDK beyond Maps V2, use appropriate and compatible artifacts for those APIs as well.
The compiler cannot resolve the getMap() method.
getMap() was deprecated about 20 months ago, in favor of getMapAsync().
My problem is that I can't seem to locate the documentation on this new maps revision where it discusses breaking changes for this new version.
Maps V2 release notes are in the Play Services documentation. A subset of Maps V2 release notes are incorporated in the overall Play Services release notes.
I am attempting to run some sample Android Pay API code following the guide here:
https://developers.google.com/android-pay/android/tutorial#setup
I'm using the sample Bikestore project provided in the link above. I followed the instructions to setup credentials/client ID for my app:
Google Developers Console
Created an Android Client ID for OAuth 2.0 using SHA1 fingerprint and entering the app's package name.
The app installs/runs successfully on my cell phone (Lollipop), however when attempting to "Login", it displays "An error occurring while contacting Google. Please try again later"
I believe I've found a solution. In the sample project, the following dependencies were defined in build.gradle:
dependencies {
compile 'com.android.support:support-v4:22.2.0'
compile 'com.google.android.gms:play-services-plus:7.8.0'
compile 'com.google.android.gms:play-services-wallet:7.8.0'
}
I added the following line and this seems to have fixed the connection issue:
compile 'com.google.android.gms:play-services:7.8.0'
Im working on simple map app, I added google-play-services.jar and its reference to gradle
dependencies {
compile files('libs/android-support-v4.jar', 'libs/google-play-services.jar')
}
The main activity:
setContentView(R.layout.activity_mapui);
GoogleMap map = ((MapFragment) getFragmentManager().findFragmentById(R.id.map)).getMap();
layout file
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:name="com.google.android.gms.maps.MapFragment"/>
But the app crashes on the device
E/AndroidRuntime﹕ FATAL EXCEPTION: main
java.lang.NoClassDefFoundError: com.google.android.gms.R$styleable at
com.google.android.gms.maps.GoogleMapOptions.createFromAttributes(Unknown
Source) at com.google.android.gms.maps.MapFragment.onInflate(Unknown
Source)
I tried several ways, same issue, I just want to add google services to Android Studio 0.3 with Gradle 0.6+
Add this line in the dependencies section of your build.gradle file:
compile 'com.google.android.gms:play-services:3.2.+'
You don't need to add a .jar to your libs folder.
Edit
As Varun pointed out, you also need to update the SDK to contain the most recent version of the play services.
You can do this by opening up the Android SDK Manager (under the Window tab) from Eclipse+ADT, checking the box next to Google Play services in the Extras folder, and clicking install.
Hit check on all tools, to be safe
Hit check on API you are working with
Hit check on all extras to be safe
Go to file -> project structure
Finally go to build at the top of the screen and hit rebuild project
As #Matt said, it is correct, I am here covered also which I did not find in the answer.
To add the Google Play Service library in your application project, follow below steps :-
1) Open the build.gradle file of your application module directory. See screenshot
2) Add new in your dependecies, here you to update the version number whenever you update the Google Play Service.
dependencies {
...
compile 'com.google.android.gms:play-services:4.2.42'
compile files('src/main/libs/gson-2.2.4.jar')
}
3) Now Lastly important save your file and click on Sync with Gradle Files in the toolbar.
This didn't work for me, I had to download the Goople Repository in the Android SDK Manager - Extras, to fix it.
Try to avoid including entire google play services, when you use more library then you get Multidex exception:
The number of method references in a .dex file cannot exceed 64k
So best way to use:
compile 'com.google.android.gms:play-services-maps:9.8.0'
if you wish to include other services, please refer here:
https://developers.google.com/android/guides/setup (scroll down)
Go to Android SDK Manager, go to Extras, select Google Play Services and Google Repository and then click on 'Install Packages...' button.
Click on 'build.gradle' file, in the code window in editor, then click on 'try again' link button...
Wait until gradle build finish.
Go to the setting -> apps in your android testing phone and search for google play services and click on it, there you will find the version number installed on your device.
For me it was 9.6.83
then just add your version number to this command below :-
compile 'com.google.android.gms:play-services:9.6.83'
Add this to you build.gradle(app)
Gradle sync
Later you may get a gradle error saying that the particular repository needs to be installed, Go ahead and download it ! Voila your next gradle sync is successfull.
Add this line to your app gradle
in dependency block
implementation 'com.google.android.gms:play-services-maps:15.0.1'
Add Google Play Service ads and their feature in your android Project
Open your Android Studio build.gradle file
In Dependency add Google Play Service
implementation 'com.google.android.gms:play-services-ads:20.5.0'
sync your build.gradle file