Recently i have used Fused Location API
for location purpose.
Before applying google play service library com.google.android.gms:play-services:8.3.0
the app size was 4.3MB
(4,499,239 bytes) but after using this api it increased to 5.8 MB
(6,085,932 bytes). Only one class has been added to the project. i.e LocationService.java
where i am calling it from service class and here is the code.
LocationService.java
public class LocationServiceRACE implements
GoogleApiClient.ConnectionCallbacks, GoogleApiClient.OnConnectionFailedListener, LocationListener {
private GoogleApiClient mGoogleApiClient;
private LocationRequest mLocationRequest;
public LocationServiceRACE(Context serviceContext) {
mGoogleApiClient = new GoogleApiClient.Builder(serviceContext)
.addApi(LocationServices.API)
.addConnectionCallbacks(this)
.addOnConnectionFailedListener(this)
.build();
}
public GoogleApiClient getmGoogleApiClient() {
return this.mGoogleApiClient;
}
@Override
public void onConnected(Bundle bundle) {
if (mGoogleApiClient.isConnected())
startLocationUpdates();
}
@Override
public void onConnectionSuspended(int i) {
}
@Override
public void onLocationChanged(Location location) {
}
@Override
public void onConnectionFailed(ConnectionResult connectionResult) {
}
protected void startLocationUpdates() {
mLocationRequest = LocationRequest.create();
mLocationRequest.setPriority(LocationRequest.PRIORITY_BALANCED_POWER_ACCURACY);
mLocationRequest.setInterval(60000); // Update location every 60 second
mLocationRequest.setSmallestDisplacement(100);
LocationServices.FusedLocationApi.requestLocationUpdates(
mGoogleApiClient, mLocationRequest, this);
}
}
I am not using no other api's other than Fused Location and nothing is added/changed in ProGuard after adding google play services.
How can i reduce the app size where i just need fused location
api?.
How about using only location dependency?
com.google.android.gms:play-services-location:8.3.0