Use date to manage subscriptions. Android. Firebase - java

My problem is with this activity. I want to get the time, compare it to the time on the database, and then if the subscription hasnt expired show a button, if it has hide it. Plus i want to show the credits a user has, and image and his name on top. I have tried many things, but it keeps crashing for some reason.
public void getthedate(){
calendar = Calendar.getInstance();
final SimpleDateFormat mdformat = new SimpleDateFormat("yyyy / MM / dd ");
// strDate = "Current Date : " + mdformat.format(calendar.getTime());
// futurecal = Calendar.getInstance();
// futurecal.add(Calendar.DATE, 30);
// futuredate = mdformat.format(futurecal.getTime());
DatabaseReference subtime = mDatabase.child("users").child(univ).child(uid);
subtime.addListenerForSingleValueEvent(new ValueEventListener() {
#Override
public void onDataChange(#NonNull DataSnapshot dataSnapshot) {
subtimedate = dataSnapshot.child("subdate").getValue().toString();
String username = dataSnapshot.child("Full name").getValue().toString();
String coinstring = dataSnapshot.child("coins").getValue().toString();
coinview.setText(coinstring);
String imglink = dataSnapshot.child("imageuri").getValue().toString();
Glide.with(c).load(imglink).into(userthing);
hellostring.setText("Hey" + username + "!");
Date subdatecal = null;
try {
subdatecal = mdformat.parse(subtimedate);
} catch (ParseException e) {
e.printStackTrace();
}
Calendar newestcal = Calendar.getInstance();
newestcal.setTime(subdatecal);
if (newestcal.after(mdformat.format(calendar.getTime()))){
substat.setText("Active");
substat.setBackgroundColor(Color.GREEN);
//do something if subscription hasnt expired
}else{
gotonotes.setVisibility(View.GONE);
substat.setText("Expired");
substat.setBackgroundColor(Color.RED);
}
}
#Override
public void onCancelled(#NonNull DatabaseError databaseError) {
}
});
/*
DatabaseReference subtime = mDatabase.child("users").child(univ).child(uid).child("subdate");
subtime.setValue(futuredate);
set new subscription
*/
/* if (calendar.after(futurecal)){
use this to check if date has passed
}*/
}
In the oncreate i have setup everything.
substat = (TextView) findViewById(R.id.substat);
hellostring = (TextView) findViewById(R.id.hellostring);
coinview = (TextView) findViewById(R.id.coinview);
userthing = (ImageView) findViewById(R.id.userimagething);
mDatabase = FirebaseDatabase.getInstance().getReference();
friendbtn = (Button) findViewById(R.id.friendsbtn);
uid = FirebaseAuth.getInstance().getCurrentUser().getUid();
Thanks for any suggestions!
this is logcat from my phone on android studio when the activity crashes
10-22 19:00:46.363 20227-20227/? I/art: Late-enabling -Xcheck:jni
10-22 19:00:46.473 20227-20227/com.studybuddy.mixal.android W/System: ClassLoader referenced unknown path: /data/app/com.studybuddy.mixal.android-2/lib/arm64
10-22 19:00:46.592 20227-20227/com.studybuddy.mixal.android I/FirebaseInitProvider: FirebaseApp initialization successful
10-22 19:00:46.635 20227-20227/com.studybuddy.mixal.android W/art: Before Android 4.1, method android.graphics.PorterDuffColorFilter android.support.graphics.drawable.VectorDrawableCompat.updateTintFilter(android.graphics.PorterDuffColorFilter, android.content.res.ColorStateList, android.graphics.PorterDuff$Mode) would have incorrectly overridden the package-private method in android.graphics.drawable.Drawable
10-22 19:00:46.639 20227-20261/com.studybuddy.mixal.android I/FA: App measurement is starting up, version: 12780
To enable debug logging run: adb shell setprop log.tag.FA VERBOSE
To enable faster debug mode event logging run:
adb shell setprop debug.firebase.analytics.app com.studybuddy.mixal.android
10-22 19:00:46.703 20227-20261/com.studybuddy.mixal.android I/FA: Tag Manager is not found and thus will not be used
10-22 19:00:46.705 20227-20227/com.studybuddy.mixal.android I/HwSecImmHelper: mSecurityInputMethodService is null
10-22 19:00:46.718 20227-20227/com.studybuddy.mixal.android E/HAL: load: id=gralloc != hmi->id=gralloc
10-22 19:00:46.899 20227-20284/com.studybuddy.mixal.android I/DynamiteModule: Considering local module com.google.android.gms.firebase_database:4 and remote module com.google.android.gms.firebase_database:6
Selected remote version of com.google.android.gms.firebase_database, version >= 6
10-22 19:00:46.949 20227-20284/com.studybuddy.mixal.android W/System: ClassLoader referenced unknown path: /data/data/com.google.android.gms/app_chimera/m/00000086/n/arm64-v8a
10-22 19:00:46.960 20227-20272/com.studybuddy.mixal.android E/HAL: load: id=gralloc != hmi->id=gralloc
10-22 19:00:46.961 20227-20272/com.studybuddy.mixal.android I/OpenGLRenderer: Initialized EGL, version 1.4
10-22 19:00:46.971 20227-20272/com.studybuddy.mixal.android W/OpenGLRenderer: load: so=/system/lib64/libhwuibp.so
dlopen failed: library "/system/lib64/libhwuibp.so" not found
Initialize Binary Program Cache: Load Failed
10-22 19:00:46.971 20227-20272/com.studybuddy.mixal.android E/HAL: load: id=gralloc != hmi->id=gralloc
10-22 19:00:47.058 20227-20299/com.studybuddy.mixal.android I/System: core_booster, getBoosterConfig = false
10-22 19:00:48.781 20227-20227/com.studybuddy.mixal.android I/Process: Sending signal. PID: 20227 SIG: 9

Related

Google Maps API Key Error when launching Activity

I am trying to build an application that uses a Google maps activity using Android Studio.
I am facing issue: every time I try to launch the activity the app crashes. When I am using an emulator with SDK 24, the activity launches, it requires my permission and then it gives me an authentication error, even though I placed the correct API key.
On an emulator with SDK 26 the activity doesn't even launch and it crashes instantly.
Can you please help with this?
MapsActivity
import android.Manifest;
import android.content.pm.PackageManager;
import android.location.Location;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.app.ActivityCompat;
import android.support.v4.content.ContextCompat;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.widget.Toast;
import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.OnMapReadyCallback;
import com.google.android.gms.location.FusedLocationProviderClient;
import com.google.android.gms.location.LocationServices;
import com.google.android.gms.maps.SupportMapFragment;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.tasks.OnCompleteListener;
import com.google.android.gms.tasks.Task;
import java.util.ArrayList;
#SuppressWarnings("unchecked")
public class MapsActivity extends AppCompatActivity implements OnMapReadyCallback {
#Override
public void onMapReady(GoogleMap googleMap) {
Toast.makeText(this, "Map is Ready", Toast.LENGTH_SHORT).show();
Log.d(TAG, "onMapReady: map is ready");
mMap = googleMap;
if (mLocationPermissionsGranted) {
getDeviceLocation();
if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION)
!= PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(this,
Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
return;
}
mMap.setMyLocationEnabled(true);
mMap.getUiSettings().setMyLocationButtonEnabled(false);
}
}
private static final String TAG = "MapsActivity";
private static final String FINE_LOCATION = Manifest.permission.ACCESS_FINE_LOCATION;
private static final String COURSE_LOCATION = Manifest.permission.ACCESS_COARSE_LOCATION;
private static final int LOCATION_PERMISSION_REQUEST_CODE = 1234;
private static final float DEFAULT_ZOOM = 15f;
//vars
private Boolean mLocationPermissionsGranted = false;
private GoogleMap mMap;
private FusedLocationProviderClient mFusedLocationProviderClient;
#Override
protected void onCreate(#Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_maps);
getLocationPermission();
}
private void getDeviceLocation(){
Log.d(TAG, "getDeviceLocation: getting the devices current location");
mFusedLocationProviderClient = LocationServices.getFusedLocationProviderClient(this);
try{
if(mLocationPermissionsGranted){
final Task location = mFusedLocationProviderClient.getLastLocation();
location.addOnCompleteListener(new OnCompleteListener() {
#Override
public void onComplete(#NonNull Task task) {
if(task.isSuccessful()){
Log.d(TAG, "onComplete: found location!");
Location currentLocation = (Location) task.getResult();
moveCamera(new LatLng(currentLocation.getLatitude(), currentLocation.getLongitude()),
DEFAULT_ZOOM);
}else{
Log.d(TAG, "onComplete: current location is null");
Toast.makeText(MapsActivity.this, "unable to get current location", Toast.LENGTH_SHORT).show();
}
}
});
}
}catch (SecurityException e){
Log.e(TAG, "getDeviceLocation: SecurityException: " + e.getMessage() );
}
}
private void moveCamera(LatLng latLng, float zoom){
Log.d(TAG, "moveCamera: moving the camera to: lat: " + latLng.latitude + ", lng: " + latLng.longitude );
mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(latLng, zoom));
}
private void initMap(){
Log.d(TAG, "initMap: initializing map");
SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map);
mapFragment.getMapAsync(MapsActivity.this);
}
private void getLocationPermission(){
Log.d(TAG, "getLocationPermission: getting location permissions");
String[] permissions = {Manifest.permission.ACCESS_FINE_LOCATION,
Manifest.permission.ACCESS_COARSE_LOCATION};
if(ContextCompat.checkSelfPermission(this.getApplicationContext(),
FINE_LOCATION) == PackageManager.PERMISSION_GRANTED){
if(ContextCompat.checkSelfPermission(this.getApplicationContext(),
COURSE_LOCATION) == PackageManager.PERMISSION_GRANTED){
mLocationPermissionsGranted = true;
initMap();
}else{
ActivityCompat.requestPermissions(this,
permissions,
LOCATION_PERMISSION_REQUEST_CODE);
}
}else{
ActivityCompat.requestPermissions(this,
permissions,
LOCATION_PERMISSION_REQUEST_CODE);
}
}
#Override
public void onRequestPermissionsResult(int requestCode, #NonNull String[] permissions, #NonNull int[] grantResults) {
Log.d(TAG, "onRequestPermissionsResult: called.");
mLocationPermissionsGranted = false;
switch(requestCode){
case LOCATION_PERMISSION_REQUEST_CODE:{
if(grantResults.length > 0){
for(int i = 0; i < grantResults.length; i++){
if(grantResults[i] != PackageManager.PERMISSION_GRANTED){
mLocationPermissionsGranted = false;
Log.d(TAG, "onRequestPermissionsResult: permission failed");
return;
}
}
Log.d(TAG, "onRequestPermissionsResult: permission granted");
mLocationPermissionsGranted = true;
//initialize our map
initMap();
}
}
}
}
}
Error from the logcat for an emulator with SDK 24:
06-21 16:52:53.625 13392-13392/com.example.raluca.geoloc.feature E/art: The String#value field is not present on Android versions >= 6.0
06-21 16:52:55.011 1314-1321/? E/SurfaceFlinger: ro.sf.lcd_density must be defined as a build property
06-21 16:52:55.452 13392-13560/com.example.raluca.geoloc.feature E/Google Maps Android API: Authorization failure. Please see https://developers.google.com/maps/documentation/android-api/start for how to correctly set up the map.
06-21 16:52:55.454 13392-13560/com.example.raluca.geoloc.feature E/Google Maps Android API: In the Google Developer Console (https://console.developers.google.com)
Ensure that the "Google Maps Android API v2" is enabled.
Ensure that the following Android Key exists:
API Key: XXX_Key
Android Application (<cert_fingerprint>;<package_name>): D3:DF:7B:C7:09:CA:00:9F:32:DD:93:98:D6:E2:09:A1:18:B1:F6:6B;com.example.raluca.geoloc.feature
06-21 16:53:01.866 13392-13392/com.example.raluca.geoloc.feature E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.raluca.geoloc.feature, PID: 13392
java.lang.RuntimeException: Failure delivering result ResultInfo{who=#android:requestPermissions:, request=1234, result=-1, data=Intent { act=android.content.pm.action.REQUEST_PERMISSIONS (has extras) }} to activity {com.example.raluca.geoloc.feature/com.example.raluca.geoloc.feature.MapsActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'void com.google.android.gms.maps.SupportMapFragment.getMapAsync(com.google.android.gms.maps.OnMapReadyCallback)' on a null object reference
at android.app.ActivityThread.deliverResults(ActivityThread.java:4053)
at android.app.ActivityThread.handleSendResult(ActivityThread.java:4096)
at android.app.ActivityThread.-wrap20(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1516)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6077)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:866)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:756)
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void com.google.android.gms.maps.SupportMapFragment.getMapAsync(com.google.android.gms.maps.OnMapReadyCallback)' on a null object reference
at com.example.raluca.geoloc.feature.MapsActivity.initMap(MapsActivity.java:110)
at com.example.raluca.geoloc.feature.MapsActivity.onRequestPermissionsResult(MapsActivity.java:154)
at android.app.Activity.dispatchRequestPermissionsResult(Activity.java:7067)
at android.app.Activity.dispatchActivityResult(Activity.java:6919)
at android.app.ActivityThread.deliverResults(ActivityThread.java:4049)
at android.app.ActivityThread.handleSendResult(ActivityThread.java:4096) 
at android.app.ActivityThread.-wrap20(ActivityThread.java) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1516) 
at android.os.Handler.dispatchMessage(Handler.java:102) 
at android.os.Looper.loop(Looper.java:154) 
at android.app.ActivityThread.main(ActivityThread.java:6077) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:866) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:756) 
06-21 16:53:02.076 1314-1322/? E/SurfaceFlinger: ro.sf.lcd_density must be defined as a build property
06-21 16:53:05.957 8187-8220/? E/InputDispatcher: channel '65bcf76 com.example.raluca.geoloc.feature/com.example.raluca.geoloc.feature.LoginActivity (server)' ~ Channel is unrecoverably broken and will be disposed!
06-21 16:53:05.957 8187-8220/? E/InputDispatcher: channel '23dfb3a com.example.raluca.geoloc.feature/com.example.raluca.geoloc.feature.MapsActivity (server)' ~ Channel is unrecoverably broken and will be disposed!
06-21 16:53:26.978 8543-12462/? E/NetworkScheduler: Unrecognised action provided: android.intent.action.PACKAGE_REMOVED
06-21 16:53:27.653 8543-11730/? E/NetworkScheduler: Unrecognised action provided: android.intent.action.PACKAGE_REPLACED
06-21 16:53:28.495 8906-13710/? E/FontsPackageChangeOp: Error adding manifest dependency for newly downloaded font {Press Start 2P, wdth 100.0, wght 400, ital 0.0, bestEffort false}
06-21 16:53:28.507 8906-13053/? E/FontDisk: Error inserting metadata for Press Start 2P
java.lang.IllegalStateException: attempt to re-open an already-closed object: SQLiteDatabase: /data/user/0/com.google.android.gms/databases/metadata.db
at android.database.sqlite.SQLiteClosable.acquireReference(SQLiteClosable.java:55)
at android.database.sqlite.SQLiteDatabase.insertWithOnConflict(SQLiteDatabase.java:1442)
at vdo.run(Unknown Source)
at ovb.run(:com.google.android.gms#12685026#12.6.85 (040700-197041431):27)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
at pbc.run(:com.google.android.gms#12685026#12.6.85 (040700-197041431))
at java.lang.Thread.run(Thread.java:761)
06-21 16:53:29.228 13637-13764/? E/art: The String#value field is not present on Android versions >= 6.0
06-21 16:53:29.611 13637-13764/? E/Finsky: [464] com.google.android.finsky.am.c.a(34): Unable to build selector: /storage/emulated/0/Download/marketenvs.csv (No such file or directory)
06-21 16:53:30.423 13637-13637/? E/Finsky: [1] com.google.android.finsky.wear.y.a(3): onConnectionFailed: ConnectionResult{statusCode=API_UNAVAILABLE, resolution=null, message=null}
06-21 16:53:35.484 13637-13828/? E/Finsky: [483] com.google.android.finsky.splitinstallservice.ad.a(3): Can't schedule deferred install. No modules found.
06-21 16:53:36.939 13637-13637/? E/Finsky: [1] com.google.android.finsky.wear.y.a(3): onConnectionFailed: ConnectionResult{statusCode=API_UNAVAILABLE, resolution=null, message=null}
06-21 16:53:37.759 13836-13836/? E/art: The String#value field is not present on Android versions >= 6.0
06-21 16:53:38.320 8906-8965/? E/AsyncOpDispatcher: Unable to get current module info in ModuleManager created with non-module Context
06-21 16:53:39.373 8543-13891/? E/BluetoothAdapter: Bluetooth binder is null
06-21 16:53:39.503 8543-13891/? E/GCoreUlr: java.lang.IllegalStateException: Missing location or location status: 3016643, -1, 3781840, 7160153
at awot.a(:com.google.android.gms#12685026#12.6.85 (040700-197041431):387)
at awos.a(:com.google.android.gms#12685026#12.6.85 (040700-197041431):12)
at awos.handleMessage(:com.google.android.gms#12685026#12.6.85 (040700-197041431):7)
at oup.run(:com.google.android.gms#12685026#12.6.85 (040700-197041431):6)
at ovb.run(:com.google.android.gms#12685026#12.6.85 (040700-197041431):27)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
at pbc.run(:com.google.android.gms#12685026#12.6.85 (040700-197041431))
at java.lang.Thread.run(Thread.java:761)
06-21 16:53:40.868 12038-13901/? E/art: The String#value field is not present on Android versions >= 6.0
06-21 16:58:10.742 8543-13895/? E/BluetoothAdapter: Bluetooth binder is null
06-21 16:58:10.743 8543-13895/? E/GCoreUlr: java.lang.IllegalStateException: Missing location or location status: 3016643, -1, 3781840, 7431479
at awot.a(:com.google.android.gms#12685026#12.6.85 (040700-197041431):387)
at awos.a(:com.google.android.gms#12685026#12.6.85 (040700-197041431):12)
at awos.handleMessage(:com.google.android.gms#12685026#12.6.85 (040700-197041431):7)
at oup.run(:com.google.android.gms#12685026#12.6.85 (040700-197041431):6)
at ovb.run(:com.google.android.gms#12685026#12.6.85 (040700-197041431):27)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
at pbc.run(:com.google.android.gms#12685026#12.6.85 (040700-197041431))
at java.lang.Thread.run(Thread.java:761)
06-21 17:07:17.957 8543-9125/? E/WakeLock: release without a matched acquire!
06-21 17:07:18.371 14053-14083/? E/SQLiteLog: (1) no such table: mmsconfig
06-21 17:07:18.376 14053-14083/? E/Babel_SMS: canonicalizeMccMnc: invalid mccmnc nullnull
Error from the logcat for an emulator with SDK 26:
06-21 17:13:05.646 1744-1775/system_process E/memtrack: Couldn't load memtrack module
06-21 17:13:14.440 1929-2545/com.android.systemui E/ResourcesManager: failed to add asset path /data/app/com.example.raluca.geoloc.feature-sqq-lfGT9yN1ITtLhodWNA==/base.apk
06-21 17:13:14.440 1929-2545/com.android.systemui E/ResourcesManager: failed to add asset path /data/app/com.example.raluca.geoloc.feature-sqq-lfGT9yN1ITtLhodWNA==/base.apk
06-21 17:13:14.441 1929-2545/com.android.systemui E/ResourcesManager: failed to add asset path /data/app/com.example.raluca.geoloc.feature-sqq-lfGT9yN1ITtLhodWNA==/base.apk
06-21 17:13:14.441 1929-2545/com.android.systemui E/ResourcesManager: failed to add asset path /data/app/com.example.raluca.geoloc.feature-sqq-lfGT9yN1ITtLhodWNA==/base.apk
06-21 17:13:14.443 1929-2545/com.android.systemui E/ResourcesManager: failed to add asset path /data/app/com.example.raluca.geoloc.feature-sqq-lfGT9yN1ITtLhodWNA==/base.apk
06-21 17:13:14.899 1744-1775/system_process E/memtrack: Couldn't load memtrack module
06-21 17:13:15.787 5360-5360/com.example.raluca.geoloc.feature E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.raluca.geoloc.feature, PID: 5360
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.raluca.geoloc.feature/com.example.raluca.geoloc.feature.MapsActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'void com.google.android.gms.maps.SupportMapFragment.getMapAsync(com.google.android.gms.maps.OnMapReadyCallback)' on a null object reference
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2817)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2892)
at android.app.ActivityThread.-wrap11(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1593)
at android.os.Handler.dispatchMessage(Handler.java:105)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6541)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void com.google.android.gms.maps.SupportMapFragment.getMapAsync(com.google.android.gms.maps.OnMapReadyCallback)' on a null object reference
at com.example.raluca.geoloc.feature.MapsActivity.initMap(MapsActivity.java:110)
at com.example.raluca.geoloc.feature.MapsActivity.getLocationPermission(MapsActivity.java:123)
at com.example.raluca.geoloc.feature.MapsActivity.onCreate(MapsActivity.java:67)
at android.app.Activity.performCreate(Activity.java:6975)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1213)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2770)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2892) 
at android.app.ActivityThread.-wrap11(Unknown Source:0) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1593) 
at android.os.Handler.dispatchMessage(Handler.java:105) 
at android.os.Looper.loop(Looper.java:164) 
at android.app.ActivityThread.main(ActivityThread.java:6541) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767) 
06-21 17:13:16.975 1510-1510/? E/AudioFlinger: not enough memory for AudioTrack size=131296
06-21 17:13:16.976 1510-1510/? E/AudioFlinger: createRecordTrack_l() initCheck failed -12; no control block?
06-21 17:13:16.978 2349-5365/com.google.android.googlequicksearchbox:search E/AudioRecord: AudioFlinger could not create record track, status: -12
06-21 17:13:16.990 2349-5365/com.google.android.googlequicksearchbox:search E/AudioRecord-JNI: Error creating AudioRecord instance: initialization check failed with status -12.
06-21 17:13:16.990 2349-5365/com.google.android.googlequicksearchbox:search E/android.media.AudioRecord: Error code -20 when initializing native AudioRecord object.
06-21 17:13:16.998 2349-5365/com.google.android.googlequicksearchbox:search E/ActivityThread: Failed to find provider info for com.google.android.apps.gsa.testing.ui.audio.recorded
06-21 17:13:17.682 2308-2853/com.google.android.gms.persistent E/ctxmgr: [ProducerStatusImpl]updateStateForNewContextData: inactive, contextName=7
06-21 17:13:17.794 2308-2308/com.google.android.gms.persistent E/BeaconBle: Missing BluetoothAdapter
06-21 17:13:17.895 2308-2308/com.google.android.gms.persistent E/BeaconBle: Scan couldn't start for Places
06-21 17:13:22.074 1510-1650/? E/AudioFlinger: not enough memory for AudioTrack size=131296
06-21 17:13:22.074 1510-1650/? E/AudioFlinger: createRecordTrack_l() initCheck failed -12; no control block?
06-21 17:13:22.074 2349-5365/com.google.android.googlequicksearchbox:search E/AudioRecord: AudioFlinger could not create record track, status: -12
06-21 17:13:22.084 2349-5365/com.google.android.googlequicksearchbox:search E/AudioRecord-JNI: Error creating AudioRecord instance: initialization check failed with status -12.
06-21 17:13:22.084 2349-5365/com.google.android.googlequicksearchbox:search E/android.media.AudioRecord: Error code -20 when initializing native AudioRecord object.
06-21 17:13:22.086 2349-5365/com.google.android.googlequicksearchbox:search E/ActivityThread: Failed to find provider info for com.google.android.apps.gsa.testing.ui.audio.recorded
06-21 17:13:27.115 1510-1648/? E/AudioFlinger: not enough memory for AudioTrack size=131296
06-21 17:13:27.116 1510-1648/? E/AudioFlinger: createRecordTrack_l() initCheck failed -12; no control block?
06-21 17:13:27.116 2349-5365/com.google.android.googlequicksearchbox:search E/AudioRecord: AudioFlinger could not create record track, status: -12
06-21 17:13:27.123 2349-5365/com.google.android.googlequicksearchbox:search E/AudioRecord-JNI: Error creating AudioRecord instance: initialization check failed with status -12.
06-21 17:13:27.124 2349-5365/com.google.android.googlequicksearchbox:search E/android.media.AudioRecord: Error code -20 when initializing native AudioRecord object.
06-21 17:13:27.714 1744-1775/system_process E/memtrack: Couldn't load memtrack module
06-21 17:13:27.737 1744-1775/system_process E/memtrack: Couldn't load memtrack module
06-21 17:13:31.070 1744-1775/system_process E/memtrack: Couldn't load memtrack module
06-21 17:13:31.084 1744-1775/system_process E/memtrack: Couldn't load memtrack module
06-21 17:13:32.154 1510-1650/? E/AudioFlinger: not enough memory for AudioTrack size=131296
06-21 17:13:32.155 1510-1650/? E/AudioFlinger: createRecordTrack_l() initCheck failed -12; no control block?
06-21 17:13:32.155 2349-5365/com.google.android.googlequicksearchbox:search E/AudioRecord: AudioFlinger could not create record track, status: -12
06-21 17:13:32.157 2349-5365/com.google.android.googlequicksearchbox:search E/AudioRecord-JNI: Error creating AudioRecord instance: initialization check failed with status -12.
06-21 17:13:32.157 2349-5365/com.google.android.googlequicksearchbox:search E/android.media.AudioRecord: Error code -20 when initializing native AudioRecord object.
Msps Activity Layout
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MapsActivity"
android:id="#+id/map"
class="com.google.android.gms.maps.SupportMapFragment"
/>
</RelativeLayout>
Gradle
android {
compileSdkVersion 26
defaultConfig {
minSdkVersion 15
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
debuggable true
}
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation project(':base')
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.github.orhanobut:logger:1.12'
compile 'com.google.android.gms:play-services-maps:11.6.0'
implementation "com.google.android.gms:play-services-location:11.6.0"
}
You have to initialize your map in onCreate() as done here and this will do your job.
public class MapsActivity extends AppCompatActivity implements OnMapReadyCallback
{
private GoogleMap mMap;
#Override
public void onMapReady(GoogleMap googleMap)
{
Toast.makeText(this, "Map is Ready", Toast.LENGTH_SHORT).show();
Log.d("Mapready", "onMapReady: map is ready");
mMap = googleMap;
if (mLocationPermissionsGranted)
{
getDeviceLocation();
if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION)
!= PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(this,
Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
return;
}
mMap.setMyLocationEnabled(true);
mMap.getUiSettings().setMyLocationButtonEnabled(false);
}
}
private static final String TAG = "MapsActivity";
private static final String FINE_LOCATION = Manifest.permission.ACCESS_FINE_LOCATION;
private static final String COURSE_LOCATION = Manifest.permission.ACCESS_COARSE_LOCATION;
private static final int LOCATION_PERMISSION_REQUEST_CODE = 1234;
private static final float DEFAULT_ZOOM = 15f;
//vars
private Boolean mLocationPermissionsGranted = false;
private FusedLocationProviderClient mFusedLocationProviderClient;
#Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_maps);
initMap();
getLocationPermission();
}
private void getDeviceLocation(){
Log.d(TAG, "getDeviceLocation: getting the devices current location");
mFusedLocationProviderClient = LocationServices.getFusedLocationProviderClient(this);
try{
if(mLocationPermissionsGranted){
final Task location = mFusedLocationProviderClient.getLastLocation();
location.addOnCompleteListener(new OnCompleteListener() {
#Override
public void onComplete(#NonNull Task task) {
if(task.isSuccessful()){
Log.d(TAG, "onComplete: found location!");
Location currentLocation = (Location) task.getResult();
moveCamera(new LatLng(currentLocation.getLatitude(), currentLocation.getLongitude()),
DEFAULT_ZOOM);
}else{
Log.d(TAG, "onComplete: current location is null");
Toast.makeText(MapsActivity.this, "unable to get current location", Toast.LENGTH_SHORT).show();
}
}
});
}
}catch (SecurityException e){
Log.e(TAG, "getDeviceLocation: SecurityException: " + e.getMessage() );
}
}
private void moveCamera(LatLng latLng, float zoom){
Log.d(TAG, "moveCamera: moving the camera to: lat: " + latLng.latitude + ", lng: " + latLng.longitude );
mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(latLng, zoom));
}
private void initMap(){
Log.d(TAG, "initMap: initializing map");
SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map);
mapFragment.getMapAsync(MapsActivity.this);
}
private void getLocationPermission(){
Log.d(TAG, "getLocationPermission: getting location permissions");
String[] permissions = {Manifest.permission.ACCESS_FINE_LOCATION,
Manifest.permission.ACCESS_COARSE_LOCATION};
if(ContextCompat.checkSelfPermission(this.getApplicationContext(),
FINE_LOCATION) == PackageManager.PERMISSION_GRANTED){
if(ContextCompat.checkSelfPermission(this.getApplicationContext(),
COURSE_LOCATION) == PackageManager.PERMISSION_GRANTED){
mLocationPermissionsGranted = true;
initMap();
}else{
ActivityCompat.requestPermissions(this,
permissions,
LOCATION_PERMISSION_REQUEST_CODE);
}
}else{
ActivityCompat.requestPermissions(this,
permissions,
LOCATION_PERMISSION_REQUEST_CODE);
}
}
#Override
public void onRequestPermissionsResult(int requestCode, #NonNull String[] permissions, #NonNull int[] grantResults) {
Log.d(TAG, "onRequestPermissionsResult: called.");
mLocationPermissionsGranted = false;
switch(requestCode){
case LOCATION_PERMISSION_REQUEST_CODE:{
if(grantResults.length > 0){
for(int i = 0; i < grantResults.length; i++){
if(grantResults[i] != PackageManager.PERMISSION_GRANTED){
mLocationPermissionsGranted = false;
Log.d(TAG, "onRequestPermissionsResult: permission failed");
return;
}
}
Log.d(TAG, "onRequestPermissionsResult: permission granted");
mLocationPermissionsGranted = true;
//initialize our map
initMap();
}
}
}
}
}
Also, do the following changes in the manifest file:-
<meta-data android:name="com.google.android.geo.API_KEY"
android:value="YOUR_API_KEY"/>
Create a New Project and check on the "Use androidx.* artifacts" and it will work fine.
Should use API 23 or newer.

How to fix HandleSignInResult return false?

I'm making a notes app using firebase auth and realtime database.
I'm stuck at the setup of google authentication.
this is my Code:
`package zohar.com.blablabla;
import android.content.Intent;
import android.support.annotation.NonNull;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Toast;
import com.google.android.gms.auth.api.Auth;
import com.google.android.gms.auth.api.signin.GoogleSignInOptions;
import com.google.android.gms.auth.api.signin.GoogleSignInResult;
import com.google.android.gms.common.ConnectionResult;
import com.google.android.gms.common.SignInButton;
import com.google.android.gms.common.api.GoogleApiClient;
public class LoginActivity extends AppCompatActivity implements
GoogleApiClient.OnConnectionFailedListener, View.OnClickListener {
SignInButton signInButton;
GoogleApiClient mGoogleApiClient;
public static final int RC_SIGN_IN = 9001;
public static final String TAG = "SignInActivity";
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_login);
GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_GAMES_SIGN_IN)
.requestEmail()
.build();
mGoogleApiClient = new GoogleApiClient.Builder(this)
.enableAutoManage(this, this)
.addApi(Auth.GOOGLE_SIGN_IN_API, gso)
.build();
signInButton = (SignInButton) findViewById(R.id.signInButtonGoogle);
signInButton.setOnClickListener(this);
}
#Override
public void onClick(View v) {
signIn();
}
private void signIn() {
Intent signInIntent = Auth.GoogleSignInApi.getSignInIntent(mGoogleApiClient);
startActivityForResult(signInIntent, RC_SIGN_IN);
}
#Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == RC_SIGN_IN) {
GoogleSignInResult result = Auth.GoogleSignInApi.getSignInResultFromIntent(data);
handleSignInResult(result);
}
}
private void handleSignInResult(GoogleSignInResult result) {
Log.d(TAG, "handleSignInResult:" + result.isSuccess());
if (result.isSuccess()) {
//connected successfully
Toast.makeText(this, "You are successfully connected!", Toast.LENGTH_SHORT).show();
Intent toMainActivityIntent = new Intent(LoginActivity.this, MainActivity.class);
startActivity(toMainActivityIntent);
}
}
#Override
public void onConnectionFailed(#NonNull ConnectionResult connectionResult) {
Log.d(TAG, "onConnectionFailed:" + connectionResult);
Toast.makeText(this, "We are currently facing with google/'s api issues,
please try again later", Toast.LENGTH_LONG).show();
}
}`
The problam is that every time when I click on the sign in button its not even showing the account picker (I dont know if its importent but I have more than 1 google accounts on my emulator). When I click it the screen turns little dark and than turns regular.
Everytime HandleSignInResult returns False.
*I did register my project and insert the sha-1.
**Sorry if I made some spelling/grammar mistakes. I'm still learning english and it's not my primary language.
Thanks.
EDIT: This are the warns:
08-14 10:52:34.116 2355-2355/? W/art: Unexpected CPU variant for X86 using
defaults: x86
08-14 10:52:34.404 2355-2355/zohar.com.notescloud W/System: ClassLoader
referenced unknown path: /data/app/zohar.com.notescloud-2/lib/x86
08-14 10:52:34.564 2355-2378/zohar.com.notescloud W/DynamiteModule: Local
module descriptor class for com.google.firebase.auth not found.
08-14 10:52:34.579 2355-2378/zohar.com.notescloud W/DynamiteModule: Local
module descriptor class for com.google.firebase.auth not found.
08-14 10:52:35.009 2355-2355/zohar.com.notescloud W/art: Before Android 4.1,
method android.graphics.PorterDuffColorFilter
android.support.graphics.drawable.VectorDrawableCompat.updateTintFilter(android.graphics.PorterDuffColorFilter, android.content.res.ColorStateList, android.graphics.PorterDuff$Mode) would have incorrectly overridden the package-private method in android.graphics.drawable.Drawable
08-14 10:52:35.209 2355-2355/zohar.com.notescloud W/System: ClassLoader referenced unknown path:
08-14 10:52:35.405 2355-2355/zohar.com.notescloud W/System: ClassLoader referenced unknown path: /data/user_de/0/com.google.android.gms/app_chimera/m/00000006/n/x86
08-14 10:52:35.856 2355-2430/zohar.com.notescloud W/OpenGLRenderer: Failed to choose config with EGL_SWAP_BEHAVIOR_PRESERVED, retrying without...
08-14 10:52:36.030 2355-2355/zohar.com.notescloud W/art: Before Android 4.1, method int android.support.v7.widget.ListViewCompat.lookForSelectablePosition(int, boolean) would have incorrectly overridden the package-private method in android.widget.ListView
c
Debug:
08-14 11:02:08.029 2355-11693/zohar.com.notescloud D/FA: Logging event (FE): user_engagement(_e), Bundle[{firebase_event_origin(_o)=auto, engagement_time_msec(_et)=46612, firebase_screen_class(_sc)=LoginActivity, firebase_screen_id(_si)=3256989730768445770}]
08-14 11:02:08.072 2355-11693/zohar.com.notescloud D/FA: Logging event (FE): screen_view(_vs), Bundle[{firebase_event_origin(_o)=auto, firebase_previous_class(_pc)=LoginActivity, firebase_previous_id(_pi)=3256989730768445770, firebase_screen_class(_sc)=SignInHubActivity, firebase_screen_id(_si)=3256989730768445773}]
08-14 11:02:08.178 2355-11693/zohar.com.notescloud D/FA: Connected to remote service
08-14 11:02:08.183 2355-2430/zohar.com.notescloud D/EGL_emulation: eglMakeCurrent: 0x9aa2b320: ver 2 0 (tinfo 0x9c741ef0)
08-14 11:02:08.205 2355-2430/zohar.com.notescloud D/EGL_emulation: eglMakeCurrent: 0x9aa2b320: ver 2 0 (tinfo 0x9c741ef0)
08-14 11:02:08.947 2355-2355/zohar.com.notescloud D/SignInActivity: handleSignInResult:false
08-14 11:02:08.953 2355-11693/zohar.com.notescloud D/FA: Logging event (FE): screen_view(_vs), Bundle[{firebase_event_origin(_o)=auto, firebase_previous_class(_pc)=SignInHubActivity, firebase_previous_id(_pi)=3256989730768445773, firebase_screen_class(_sc)=LoginActivity, firebase_screen_id(_si)=3256989730768445770}]
EDIT2: FIXED!
I was so dumb and gave the auto-completion make GOOGLE_SIGN_IN to GOOGLE_GAMES_SIGN_IN.
Sry guys.

LoginActivty with Firebase & Facebook authentication not responding after 3th relaunch

Everytime at the 3th relaunch, my app gets stuck on a dark screen. I have no clue why, I have checked out the Facebook and Firebase docs, followed examples (github). Has anyone experienced this too?
Additional information:
Facebook lib: com.facebook.android:facebook-android-sdk:4.12.0
Firebase lib: com.google.firebase:firebase-auth:9.0.0
MainActivity
public class MainActivity extends AppCompatActivity {
private static final String TAG = "MainActivity";
private Intent navigationIntent;
private Intent serviceIntent;
// FIREBASE
private FirebaseAuth firebaseAuth;
private FirebaseAuth.AuthStateListener firebaseAuthListener;
// FACEBOOK
private CallbackManager FBcallbackManager;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
navigationIntent = new Intent(this, NavigationActivity.class);
serviceIntent = new Intent(this, BackgroundService.class);
// Initialize Firebase
firebaseAuth = FirebaseAuth.getInstance();
firebaseAuthListener = new FirebaseAuth.AuthStateListener() {
#Override
public void onAuthStateChanged(#NonNull FirebaseAuth firebaseAuth) {
FirebaseUser user = firebaseAuth.getCurrentUser();
if (user != null) {
// User is signed in
// if so start next activty and close this one
Log.d(TAG, "User logged in");
startHomeActivity();
startActivity(navigationIntent);
finish();
} else {
Log.d(TAG, "User not logged in");
}
}
};
// Initialize Facebook Login button
FBcallbackManager = CallbackManager.Factory.create();
LoginButton loginButton = (LoginButton) findViewById(R.id.facebookButton);
loginButton.setReadPermissions("email", "public_profile");
loginButton.registerCallback(FBcallbackManager, new FacebookCallback<LoginResult>() {
#Override
public void onSuccess(LoginResult loginResult) {
handleFacebookAccessToken(loginResult.getAccessToken());
}
#Override
public void onCancel() {
}
#Override
public void onError(FacebookException error) {
Log.d("Facebook Error", error.toString());
}
});
}
#Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
FBcallbackManager.onActivityResult(requestCode, resultCode, data);
}
#Override
protected void onResume() {
super.onResume();
firebaseAuth.addAuthStateListener(firebaseAuthListener);
}
#Override
protected void onPause() {
super.onPause();
if (firebaseAuthListener != null) {
firebaseAuth.removeAuthStateListener(firebaseAuthListener);
}
}
private void handleFacebookAccessToken(AccessToken accessToken) {
final AuthCredential authCredential = FacebookAuthProvider.getCredential(accessToken.getToken());
firebaseAuth.signInWithCredential(authCredential).addOnCompleteListener(this, new OnCompleteListener<AuthResult>() {
#Override
public void onComplete(#NonNull Task<AuthResult> task) {
if (task.isSuccessful()) {
Log.d(TAG, "Authentication successful");
startHomeActivity();
} else {
Log.d(TAG, "Authentication not successful");
Log.d(TAG, task.getException().getMessage());
}
}
});
}
private boolean isServiceRunning(Class<?> serviceClass) {
ActivityManager manager = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE);
for (ActivityManager.RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) {
if (serviceClass.getName().equals(service.service.getClassName())) {
return true;
}
}
return false;
}
private void startHomeActivity() {
if (navigationIntent != null && serviceIntent != null) {
if (!isServiceRunning(BackgroundService.class)) {
startService(serviceIntent);
Log.d(TAG, "Service is no running. Starting service..");
} else {
Log.d(TAG, "Service is running. Not starting service..");
}
startActivity(navigationIntent);
finish();
}
}
}
Application:
public class ???????? extends Application {
#Override
public void onCreate() {
super.onCreate();
FacebookSdk.sdkInitialize(getApplicationContext());
}
}
Logcat (app specific) before last restart (there is no log on 3th restart/freeze)
05-24 16:53:19.547 16587-16618/my.package.app W/System.err: remove failed: ENOENT (No such file or directory) : /data/user/0/my.package.app/files/AppEventsLogger.persistedevents
05-24 16:53:19.557 16587-16609/my.package.app V/FA: Inactivity, disconnecting from AppMeasurementService
05-24 16:53:19.627 16587-16618/my.package.app I/System.out: (HTTPLog)-Static: isSBSettingEnabled false
05-24 16:53:19.627 16587-16618/my.package.app I/System.out: (HTTPLog)-Static: isSBSettingEnabled false
05-24 16:53:30.167 16587-16587/my.package.app D/ViewRootImpl: ViewPostImeInputStage processKey 0
05-24 16:53:30.247 16587-16587/my.package.app D/ViewRootImpl: ViewPostImeInputStage processKey 1
05-24 16:53:30.287 16587-16609/my.package.app V/FA: Activity paused, time: 455339818
05-24 16:53:30.807 16587-16587/my.package.app D/FirebaseApp: Notifying background state change listeners.a
Logcat (firebase background crash)
05-24 16:53:14.247 16940-16940/my.package.app:background_crash E/DynamiteModule: Failed to load module descriptor class: Didn't find class "com.google.android.gms.dynamite.descriptors.com.google.android.gms.crash.ModuleDescriptor" on path: DexPathList[[zip file "/data/app/my.package.app-1/base.apk"],nativeLibraryDirectories=[/data/app/my.package.app-1/lib/arm64, /vendor/lib64, /system/lib64]]
05-24 16:53:14.247 16940-16968/my.package.app:background_crash W/System.err: remove failed: ENOENT (No such file or directory) : /data/user/0/my.package.app/files/AppEventsLogger.persistedevents
05-24 16:53:14.247 16940-16956/my.package.app:background_crash I/System.out: (HTTPLog)-Static: isSBSettingEnabled false
05-24 16:53:14.247 16940-16956/my.package.app:background_crash I/System.out: (HTTPLog)-Static: isSBSettingEnabled false
05-24 16:53:14.257 16940-16940/my.package.app:background_crash V/GoogleSignatureVerifier: com.google.android.gms signature not valid. Found:
// I have changed the key below for security reasons MIIEQzCCAyugAwIBAgIJAMLgh0ZkSjCNMA0GCSqGSIb3DQEBBAUAMHQxCzAJBgNVBAYTAlVTMRMw
MIIEQzCCAyugAwIBAgIJAMLgh0ZkSjCNMA0GCSqGSIb3DQEBBAUAMHQxCzAJBgNVBAYTAlVTMRMw
MIIEQzCCAyugAwIBAgIJAMLgh0ZkSjCNMA0GCSqGSIb3DQEBBAUAMHQxCzAJBgNVBAYTAlVTMRMw
MIIEQzCCAyugAwIBAgIJAMLgh0ZkSjCNMA0GCSqGSIb3DQEBBAUAMHQxCzAJBgNVBAYTAlVTMRMw
MIIEQzCCAyugAwIBAgIJAMLgh0ZkSjCNMA0GCSqGSIb3DQEBBAUAMHQxCzAJBgNVBAYTAlVTMRMw
MIIEQzCCAyugAwIBAgIJAMLgh0ZkSjCNMA0GCSqGSIb3DQEBBAUAMHQxCzAJBgNVBAYTAlVTMRMw
MIIEQzCCAyugAwIBAgIJAMLgh0ZkSjCNMA0GCSqGSIb3DQEBBAUAMHQxCzAJBgNVBAYTAlVTMRMw
05-24 16:53:14.267 16940-16940/my.package.app:background_crash W/ResourcesManager: getTopLevelResources: /system/priv-app/PrebuiltGmsCore/PrebuiltGmsCore.apk / 1.0 running in my.package.app rsrc of package com.google.android.gms
05-24 16:53:14.267 16940-16940/my.package.app:background_crash D/ResourcesManager: For user 0 new overlays fetched Null
05-24 16:53:14.267 16940-16940/my.package.app:background_crash I/InjectionManager: Inside getClassLibPath caller
05-24 16:53:14.287 16940-16940/my.package.app:background_crash W/System: ClassLoader referenced unknown path: /system/priv-app/PrebuiltGmsCore/lib/arm64
05-24 16:53:14.297 16940-16940/my.package.app:background_crash W/ResourcesManager: getTopLevelResources: /system/priv-app/PrebuiltGmsCore/PrebuiltGmsCore.apk / 1.0 running in my.package.app rsrc of package com.google.android.gms
05-24 16:53:14.297 16940-16940/my.package.app:background_crash D/ChimeraCfgMgr: Reading stored module config
05-24 16:53:14.317 16940-16940/my.package.app:background_crash I/DynamiteModule: Considering local module com.google.android.gms.crash:0 and remote module com.google.android.gms.crash:2
05-24 16:53:14.317 16940-16940/my.package.app:background_crash I/DynamiteModule: Selected remote version of com.google.android.gms.crash, version >= 2
05-24 16:53:14.317 16940-16940/my.package.app:background_crash W/ResourcesManager: getTopLevelResources: /system/priv-app/PrebuiltGmsCore/PrebuiltGmsCore.apk / 1.0 running in my.package.app rsrc of package com.google.android.gms
05-24 16:53:14.327 16940-16940/my.package.app:background_crash I/InjectionManager: Inside getClassLibPath caller
05-24 16:53:14.327 16940-16940/my.package.app:background_crash W/System: ClassLoader referenced unknown path: /data/user/0/com.google.android.gms/app_chimera/m/00000005/n/arm64-v8a
05-24 16:53:14.327 16940-16940/my.package.app:background_crash D/ChimeraFileApk: Primary ABI of requesting process is arm64-v8a
05-24 16:53:14.327 16940-16940/my.package.app:background_crash D/ChimeraFileApk: Classloading successful. Optimized code found.
05-24 16:53:14.337 16940-16940/my.package.app:background_crash I/FirebaseCrashReceiverServiceImpl: FirebaseCrashReceiverServiceImpl created by ClassLoader com.google.android.chimera.container.internal.DelegateLastPathClassLoader[DexPathList[[zip file "/data/user/0/com.google.android.gms/app_chimera/m/00000005/DynamiteModulesC_GmsCore_prodmnc_alldpi_release.apk"],nativeLibraryDirectories=[/data/user/0/com.google.android.gms/app_chimera/m/00000005/n/arm64-v8a, /vendor/lib64, /system/lib64]]]
05-24 16:53:14.337 16940-16940/my.package.app:background_crash D/FirebaseCrashReceiverServiceImpl: onCreate
05-24 16:53:14.347 16940-16940/my.package.app:background_crash I/DynamiteModule: Considering local module com.google.android.gms.flags:0 and remote module com.google.android.gms.flags:1
05-24 16:53:14.347 16940-16940/my.package.app:background_crash I/DynamiteModule: Selected remote version of com.google.android.gms.flags, version >= 1
05-24 16:53:14.417 16940-16940/my.package.app:background_crash I/FirebaseCrashSenderServiceImpl: FirebaseCrashSenderServiceImpl created by ClassLoader com.google.android.chimera.container.internal.DelegateLastPathClassLoader[DexPathList[[zip file "/data/user/0/com.google.android.gms/app_chimera/m/00000005/DynamiteModulesC_GmsCore_prodmnc_alldpi_release.apk"],nativeLibraryDirectories=[/data/user/0/com.google.android.gms/app_chimera/m/00000005/n/arm64-v8a, /vendor/lib64, /system/lib64]]]
05-24 16:53:14.417 16940-16940/my.package.app:background_crash D/FirebaseCrashSenderServiceImpl: onCreate
Possibly this is an issue with the background Firebase Crash process calling the Facebook SDK in a way that the SDK didn't expect. You can guard that with a check for whether Firebase has initialised properly:
#Override
public void onCreate() {
super.onCreate();
if (!FirebaseApp.getApps(this).isEmpty()) {
FacebookSdk.sdkInitialize(getApplicationContext());
}
}
Try that, and see if it stop the freeze occurring.
I have the same problem from firebase analytics version 9.0.2, I think it's a bug.
And I found this issue is on the analytics version 9.0.2, and I try to revert version to 9.0.0, it will be fine and no black screen.
But you are the auth lib 9.0.0, so I think it's different...
My solution like this:
compile 'com.google.firebase:firebase-analytics:9.0.0'

How do I get past mGoogleApiClient.connect() when it doesn't seem to actually connect?

I'm trying to send an ArrayList to my Android Wear device from the mobile device.
Unfortunately I'm not getting past the mGoogleApiClient.connect() as per my sop statements.
What I've done is set up a DataLayer item and used the onDataChanged() to monitor the code and the DataItem being sent with it, but unfortunately it seems like nothing is getting across.
Console output is at the bottom of the post, if that helps pinpoint anything.
MAIN ACTIVITY - MOBILE
public class MainActivity extends AppCompatActivity implements GoogleApiClient.ConnectionCallbacks, GoogleApiClient.OnConnectionFailedListener {
Set<String> tasksSet;
ArrayList<String> actsList;
ArrayAdapter adapter;
ListView list;
GoogleApiClient mGoogleApiClient;
#Override
protected void onCreate(Bundle savedInstanceState) {
mGoogleApiClient = new GoogleApiClient.Builder(this)
.addConnectionCallbacks(this)
.addOnConnectionFailedListener(this)
.addApi(Wearable.API)
.build();
mGoogleApiClient.connect();
if(!PreferenceManager.getDefaultSharedPreferences(this)
.getStringSet("wristaroo", new HashSet<String>()).isEmpty()) {
tasksSet = PreferenceManager.getDefaultSharedPreferences(this)
.getStringSet("wristaroo", new HashSet<String>());
actsList = new ArrayList<String>(tasksSet);
}
else {
actsList = new ArrayList<>();
Set<String> tasksSet = new HashSet<>(actsList);
PreferenceManager.getDefaultSharedPreferences(this)
.edit()
.putStringSet("wristaroo", tasksSet)
.commit();
}
xxxxxxx
other populating code
xxxxxxx
Button btnSend = (Button) findViewById(R.id.sendButton);
btnSend.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
sendCustomSchedule(actsList);
System.out.println("Button Pressed: Send");
}
});
}
private void populateListView() {
list = (ListView) findViewById(R.id.listViewAdd);
list.setAdapter(adapter);
}
public MainActivity getActivity() {
return this;
}
#Override
public void onConnected(#Nullable Bundle bundle) {
}
#Override
public void onConnectionSuspended(int i) {
}
#Override
public void onConnectionFailed(#NonNull ConnectionResult connectionResult) {
}
public void sendCustomSchedule(ArrayList<String> customSchedule) {
PutDataMapRequest putDataMapRequest = PutDataMapRequest.create("/customSched");
putDataMapRequest.getDataMap().putStringArrayList("customSched", customSchedule);
PutDataRequest request = putDataMapRequest.asPutDataRequest().setUrgent();
Wearable.DataApi.putDataItem(mGoogleApiClient, request)
.setResultCallback(new ResultCallback<DataApi.DataItemResult>() {
#Override
public void onResult(#NonNull DataApi.DataItemResult dataItemResult) {
if(!dataItemResult.getStatus().isSuccess()) {
System.out.println("Apparent Failure!");
} else {
System.out.println("Apparent Success!");
}
}
});
System.out.println("When in doubt...");
}
}
MAIN ACTIVITY - WEAR
public class byTimeActivity extends Activity implements DataApi.DataListener,GoogleApiClient.ConnectionCallbacks, GoogleApiClient.OnConnectionFailedListener {
ArrayList<String> choicesList;
ArrayAdapter adapter;
ListView list;
ArrayList<String> data;
String dayExtra;
String howExtra;
String schedExtra;
GoogleApiClient mGoogleApiClient;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mGoogleApiClient = new GoogleApiClient.Builder(this)
.addConnectionCallbacks(this)
.addOnConnectionFailedListener(this)
.addApi(Wearable.API)
.build();
mGoogleApiClient.connect();
setContentView(R.layout.activity_main);
final WatchViewStub stub = (WatchViewStub) findViewById(R.id.watch_view_stub);
dayExtra = getIntent().getExtras().getString("dayExtra");
schedExtra = getIntent().getExtras().getString("schedExtra");
howExtra = getIntent().getExtras().getString("howExtra");
System.out.println("dayExtra: " + dayExtra);
System.out.println("schedExtra: " + schedExtra);
System.out.println("howExtra: " + howExtra);
switch(dayExtra) {
case "Thursday":
if(schedExtra.equals("Full Schedule")) {
setStage(thTime);
}
if(schedExtra.equals("Custom Schedule")) {
adapter = new ArrayAdapter<>(this, R.layout.da_item, data);
}
break;
case "Friday":
setStage(frTime);
break;
case "Saturday":
setStage(saTime);
break;
case "Sunday":
setStage(suTime);
break;
}
stub.setOnLayoutInflatedListener(new WatchViewStub.OnLayoutInflatedListener() {
#Override
public void onLayoutInflated(WatchViewStub stub) {
list = (ListView) findViewById(R.id.mainChoiceList);
list.setAdapter(adapter);
}
});
}
private void setStage(String[] dayStage) {
choicesList = new ArrayList<>(Arrays.asList(dayStage));
adapter = new ArrayAdapter<>(this, R.layout.da_item, choicesList);
adapter.notifyDataSetChanged();
}
#Override
protected void onResume() {
super.onResume();
mGoogleApiClient.connect();
}
#Override
public void onConnected(#Nullable Bundle bundle) {
Wearable.DataApi.addListener(mGoogleApiClient, this);
}
#Override
protected void onPause() {
super.onPause();
Wearable.DataApi.removeListener(mGoogleApiClient, this);
mGoogleApiClient.disconnect();
}
#Override
public void onConnectionSuspended(int i) {
}
#Override
public void onDataChanged(DataEventBuffer dataEvents) {
for (DataEvent event : dataEvents) {
if (event.getType() == DataEvent.TYPE_CHANGED) {
DataItem item = event.getDataItem();
if (item.getUri().getPath().compareTo("/customSched") == 0) {
DataMap dataMap = DataMapItem.fromDataItem(item).getDataMap();
data = dataMap.getStringArrayList("customSched");
System.out.println("Data: " + data);
}
} else if (event.getType() == DataEvent.TYPE_DELETED) {
//dataItem Deleted
}
}
}
#Override
public void onConnectionFailed(#NonNull ConnectionResult connectionResult) {
}
}
CONSOLE OUTPUT - MOBILE
W/System: ClassLoader referenced unknown path: /data/app/com.michaeldvinci.conedmiro.schedaroo-2/lib/arm
I/GMPM: App measurement is starting up, version: 8487
I/GMPM: To enable debug logging run: adb shell setprop log.tag.GMPM VERBOSE
E/GMPM: GoogleService failed to initialize, status: 10, Missing an expected resource: 'R.string.google_app_id' for initializing Google services. Possible causes are missing google-services.json or com.google.gms.google-services gradle plugin.
E/GMPM: Scheduler not set. Not logging error/warn.
E/GMPM: Uploading is not possible. App measurement disabled
D/OpenGLRenderer: Use EGL_SWAP_BEHAVIOR_PRESERVED: true
I/Adreno200-EGL: <qeglDrvAPI_eglInitialize:265>: EGL 1.4 QUALCOMM build: AU_LINUX_ANDROID_JB_2.5.5.04.02.02.092.059_msm8960_JB_2.5.5_CL3896081_release_AU (CL3896081)
Build Date: 06/25/13 Tue
Local Branch:
Remote Branch: quic/jb_2.5.5
Local Patches: NONE
Reconstruct Branch: AU_LINUX_ANDROID_JB_2.5.5.04.02.02.092.059 + NOTHING
I/OpenGLRenderer: Initialized EGL, version 1.4
W/art: Before Android 4.1, method int android.support.v7.widget.ListViewCompat.lookForSelectablePosition(int, boolean) would have incorrectly overridden the package-private method in android.widget.ListView
I/System.out: When in doubt...
I/System.out: Button Pressed: Send
I/System.out: Apparent Success!
CONSOLE OUTPUT - WEAR
W/art: Suspending all threads took: 17.121ms
I/art: Background sticky concurrent mark sweep GC freed 1601(90KB) AllocSpace objects, 0(0B) LOS objects, 23% free, 508KB/663KB, paused 20.603ms total 53.990ms
W/art: Suspending all threads took: 5.855ms
I/art: Background partial concurrent mark sweep GC freed 168(48KB) AllocSpace objects, 0(0B) LOS objects, 45% free, 611KB/1123KB, paused 8.179ms total 61.166ms
I/System.out: mGoogleApiClient connected!
W/GooglePlayServicesUtil: Google Play services out of date. Requires 8487000 but found 8299574
D/OpenGLRenderer: Use EGL_SWAP_BEHAVIOR_PRESERVED: true
[ 04-03 23:16:13.428 15148:15148 D/ ]
HostConnection::get() New Host Connection established 0xb3edca60, tid 15148
D/Atlas: Validating map...
I/OpenGLRenderer: Initialized EGL, version 1.4
D/OpenGLRenderer: Enabling debug mode 0
W/EGL_emulation: eglSurfaceAttrib not implemented
W/OpenGLRenderer: Failed to set EGL_SWAP_BEHAVIOR on surface 0xb3f625e0, error=EGL_SUCCESS
I/System.out: mGoogleApiClient disconnected! //dis/connecting in MainActivity, before switching activities
W/EGL_emulation: eglSurfaceAttrib not implemented
W/OpenGLRenderer: Failed to set EGL_SWAP_BEHAVIOR on surface 0xb3f628a0, error=EGL_SUCCESS
W/EGL_emulation: eglSurfaceAttrib not implemented
W/OpenGLRenderer: Failed to set EGL_SWAP_BEHAVIOR on surface 0xb3f62700, error=EGL_SUCCESS
I/System.out: schedExtra: Custom Schedule
I/System.out: dayExtra: Thursday
I/System.out: howExtra: By Time
I/System.out: dayExtra: Thursday
I/System.out: schedExtra: Custom Schedule
I/System.out: howExtra: By Time
I/System.out: mGoogleApiClient connected!
D/AndroidRuntime: Shutting down VM
--------- beginning of crash
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.michaeldvinci.conedmiro.schedaroo, PID: 15148
java.lang.NullPointerException: Attempt to invoke interface method 'int java.util.List.size()' on a null object reference
W/GooglePlayServicesUtil: Google Play services out of date. Requires 8487000 but found 8299574
WearableListenerService is required REGARDLESS
only briefly mentioned in the documentation [which should definitely be updated]

Google Map crashes on Android when listener calls method

My Google maps activity is crashing when I call a method that I created in the onCameraChange listener.
The map works fine until I actually touch the map and the listener is called:
mMap.setOnCameraChangeListener(new GoogleMap.OnCameraChangeListener() {
#Override
public void onCameraChange(CameraPosition position) {
VisibleRegion vr = mMap.getProjection().getVisibleRegion();
double left = vr.latLngBounds.southwest.longitude;
double top = vr.latLngBounds.northeast.latitude;
double right = vr.latLngBounds.northeast.longitude;
double bottom = vr.latLngBounds.southwest.latitude;
zoomFix(position);
checkXYAxis(left, top, right, bottom);
}
});
If I comment out the method 'checkXYAxis' it works fine. Method:
public void checkXYAxis(double left, double top, double right, double bottom) {
//X
if (left < -87.896567) {
left = -87.896567;
}
else if (right > -87.874628) {
right = -87.874628;
}
//Y
if (top > 43.178949) {
top = 43.169292;
}
else if (bottom < 43.169292) {
bottom = 43.169292;
}
//update camera position
LatLng southwest = new LatLng(bottom, left);
LatLng northeast = new LatLng(top, right);
LatLngBounds newBounds = new LatLngBounds(southwest, northeast);
CameraUpdate update = CameraUpdateFactory.newLatLngBounds(newBounds, 0);
mMap.moveCamera(update);
}
Somewhere in that method it is causing a crash to happen.
Here is the error output:
12-23 23:46:21.903 16841-16841/com.lightningboltstudios.audubontrailmap I/art: Late-enabling -Xcheck:jni
12-23 23:46:21.973 16841-16841/com.lightningboltstudios.audubontrailmap W/ActivityThread: Application com.lightningboltstudios.audubontrailmap can be debugged on port 8100...
12-23 23:46:22.033 16841-16862/com.lightningboltstudios.audubontrailmap I/GMPM: App measurement is starting up
12-23 23:46:22.043 16841-16862/com.lightningboltstudios.audubontrailmap E/GMPM: getGoogleAppId failed with status: 10
12-23 23:46:22.043 16841-16862/com.lightningboltstudios.audubontrailmap E/GMPM: Uploading is not possible. App measurement disabled
12-23 23:46:22.153 16841-16864/com.lightningboltstudios.audubontrailmap D/OpenGLRenderer: Use EGL_SWAP_BEHAVIOR_PRESERVED: true
12-23 23:46:22.153 16841-16841/com.lightningboltstudios.audubontrailmap D/Atlas: Validating map...
12-23 23:46:22.203 16841-16864/com.lightningboltstudios.audubontrailmap I/Adreno-EGL: <qeglDrvAPI_eglInitialize:379>: EGL 1.4 QUALCOMM build: AU_LINUX_ANDROID_LA.BR.1.1.3_RB1.05.01.00.032.017_msm8916_32_LA.BR.1.1.3_RB1__release_AU ()
OpenGL ES Shader Compiler Version: E031.25.03.04
Build Date: 04/20/15 Mon
Local Branch:
Remote Branch: quic/LA.BR.1.1.3_rb1.11
Local Patches: NONE
Reconstruct Branch: AU_LINUX_ANDROID_LA.BR.1.1.3_RB1.05.01.00.032.017 + 26a3cba + 6f69ea6 + 8bc2bc8 + 649fcde + a52cccf + dbf281f + NOTHING
12-23 23:46:22.203 16841-16864/com.lightningboltstudios.audubontrailmap I/OpenGLRenderer: Initialized EGL, version 1.4
12-23 23:46:22.223 16841-16864/com.lightningboltstudios.audubontrailmap D/OpenGLRenderer: Enabling debug mode 0
12-23 23:46:22.313 16841-16841/com.lightningboltstudios.audubontrailmap I/Timeline: Timeline: Activity_idle id: android.os.BinderProxy#24d7d29d time:28513116

Categories

Resources