How to Select and Load saved game snapshot from google play games - android

I am on the Saved Games screen where is shows the list of all saves. When I select a saved game the app crashes with the error: android.os.BadParcelableException: ClassNotFoundException when unmarshalling: com.google.android.gms.games.snapshot.SnapshotMetadataEntity
It's basically the same code from here https://developers.google.com/games/services/android/savedgames?authuser=3&hl=sl
Please assist.
#Override
public void onActivityResult(int requestCode, int resultCode, Intent intent) {
super.onActivityResult(requestCode, resultCode, intent);
switch (requestCode) {
case RC_LIST_SAVED_GAMES:
if (resultCode == RESULT_OK) {
if (intent != null) {
if (intent.hasExtra(SnapshotsClient.EXTRA_SNAPSHOT_METADATA)) {
// Error occurs here when saved game is selected
SnapshotMetadata snapshotMetadata = intent.getParcelableExtra(SnapshotsClient.EXTRA_SNAPSHOT_METADATA);
assert snapshotMetadata != null;
sCurrentSaveName = snapshotMetadata.getUniqueName();
onLoadFromSnapshot(intent.getParcelableExtra(SnapshotsClient.EXTRA_SNAPSHOT_METADATA));
} else if (intent.hasExtra(SnapshotsClient.EXTRA_SNAPSHOT_NEW)) {
String unique = Long.toString(System.currentTimeMillis());
sCurrentSaveName = "snapshotH-" + unique;
onSaveSnapshot(null);
}
}
}
break;
}
}
This is what is shown in Logcat
2020-02-07 19:07:07.410 31988-31988/com.positivelymade.homeless2 E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.positivelymade.homeless2, PID: 31988
java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=9005, result=-1, data=Intent { (has extras) }} to activity {com.positivelymade.homeless2/com.positivelymade.homeless2.MainActivity}: android.os.BadParcelableException: ClassNotFoundException when unmarshalling: com.google.android.gms.games.snapshot.SnapshotMetadataEntity
at android.app.ActivityThread.deliverResults(ActivityThread.java:4605)
at android.app.ActivityThread.handleSendResult(ActivityThread.java:4647)
at android.app.servertransaction.ActivityResultItem.execute(ActivityResultItem.java:49)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1948)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:214)
at android.app.ActivityThread.main(ActivityThread.java:7045)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:964)
Caused by: android.os.BadParcelableException: ClassNotFoundException when unmarshalling: com.google.android.gms.games.snapshot.SnapshotMetadataEntity
at android.os.Parcel.readParcelableCreator(Parcel.java:2855)
at android.os.Parcel.readParcelable(Parcel.java:2781)
at android.os.Parcel.readValue(Parcel.java:2684)
at android.os.Parcel.readArrayMapInternal(Parcel.java:3053)
at android.os.BaseBundle.initializeFromParcelLocked(BaseBundle.java:288)
at android.os.BaseBundle.unparcel(BaseBundle.java:232)
at android.os.BaseBundle.containsKey(BaseBundle.java:504)
at android.content.Intent.hasExtra(Intent.java:7923)
at com.positivelymade.homeless2.MainActivity.onActivityResult(MainActivity.java:222)
at android.app.Activity.dispatchActivityResult(Activity.java:7759)
at android.app.ActivityThread.deliverResults(ActivityThread.java:4598)
at android.app.ActivityThread.handleSendResult(ActivityThread.java:4647) 
at android.app.servertransaction.ActivityResultItem.execute(ActivityResultItem.java:49) 
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108) 
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1948) 
at android.os.Handler.dispatchMessage(Handler.java:106) 
at android.os.Looper.loop(Looper.java:214) 
at android.app.ActivityThread.main(ActivityThread.java:7045) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:964) 

In my case, it is not working only in my release build since it is using pro guard. I solved it by adding pro guard configuration described here

Related

java.lang.IllegalArgumentException: Intent expected to contain a Place, but doesn't. in jetpack compose

I am trying to make a app that can search the places with google autocomplete search in jetpack compose but when I launch the intent of the autocomplete and after writing one later app is crashing here is my code:-
My ViewModel
init {
if (!Places.isInitialized()) {
Places.initialize(context, "$API_KEY", Locale.US);
}
}
val field = listOf(Place.Field.NAME, Place.Field.LAT_LNG)
My UI
val context = LocalContext.current
val intent = Autocomplete.IntentBuilder(AutocompleteActivityMode.OVERLAY, viewModel.field).build(context)
val launcher = rememberLauncherForActivityResult(ActivityResultContracts.StartActivityForResult()) {
if(it.resultCode == 2){
val place = Autocomplete.getPlaceFromIntent(it.data)
val latLng = place.latLng
Log.d("place LatLng: ", latLng.toString())
// move the camera position of the map
// cameraPositionState.move(CameraUpdateFactory.newLatLngZoom(lonLat, 15f))
}
}
My Logcat
FATAL EXCEPTION: main Process: com.example.trip, PID: 19245
java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=988884199, result=2, data=Intent { (has extras) }} to activity {com.example.trip/com.example.trip.MainActivity}: java.lang.IllegalArgumentException: Intent expected to contain a Place, but doesn't.
at android.app.ActivityThread.deliverResults(ActivityThread.java:5015)
at android.app.ActivityThread.handleSendResult(ActivityThread.java:5056)
at android.app.servertransaction.ActivityResultItem.execute(ActivityResultItem.java:51)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2066)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:223)
at android.app.ActivityThread.main(ActivityThread.java:7656)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
Caused by: java.lang.IllegalArgumentException: Intent expected to contain a Place, but doesn't.
at com.google.android.libraries.places.internal.zzha.zze(com.google.android.libraries.places:places##2.6.0:1)
at com.google.android.libraries.places.internal.zzfo.zzb(com.google.android.libraries.places:places##2.6.0:3)
at com.google.android.libraries.places.widget.Autocomplete.getPlaceFromIntent(com.google.android.libraries.places:places##2.6.0:1)
at com.example.trip.ui.theme.tripSection.createTrip.CreateTripScreenKt$CreateTripScreen$2$1$launcher$1.invoke(CreateTripScreen.kt:116)
at com.example.trip.ui.theme.tripSection.createTrip.CreateTripScreenKt$CreateTripScreen$2$1$launcher$1.invoke(CreateTripScreen.kt:113)
at androidx.activity.compose.ActivityResultRegistryKt$rememberLauncherForActivityResult$1$1.onActivityResult(ActivityResultRegistry.kt:105)
at androidx.activity.result.ActivityResultRegistry.doDispatch(ActivityResultRegistry.java:392)
at androidx.activity.result.ActivityResultRegistry.dispatchResult(ActivityResultRegistry.java:351)
at androidx.activity.ComponentActivity.onActivityResult(ComponentActivity.java:638)
at android.app.Activity.dispatchActivityResult(Activity.java:8310)
at android.app.ActivityThread.deliverResults(ActivityThread.java:5008)
at android.app.ActivityThread.handleSendResult(ActivityThread.java:5056) 
at android.app.servertransaction.ActivityResultItem.execute(ActivityResultItem.java:51) 
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135) 
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2066) 
at android.os.Handler.dispatchMessage(Handler.java:106) 
at android.os.Looper.loop(Looper.java:223) 
at android.app.ActivityThread.main(ActivityThread.java:7656) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947) 
My gradle
//Google places api
implementation 'com.google.android.libraries.places:places:2.6.0'

Google places Autocomplete error: "Intent expected to contain a Place, but doesn't"

I am creating an simple app where user types any address and gets suggestions, after clicking on any suggestion it will be displayed in a textview.
Autcomplete initialization:
try {
val fields = listOf(
Place.Field.ID, Place.Field.NAME, Place.Field.LAT_LNG,
Place.Field.ADDRESS)
val intent=Autocomplete.IntentBuilder(AutocompleteActivityMode.FULLSCREEN, fields).build(this)
startActivityForResult(intent, PLACE_AUTOCOMPLETE_REQUEST_CODE)
}catch (e: Exception){
e.printStackTrace()
}
onActivityResult() code:
if (requestCode == PLACE_AUTOCOMPLETE_REQUEST_CODE){
val place = Autocomplete.getPlaceFromIntent(data!!)
et_location.setText(place.address)
mLatitude=place.latLng!!.latitude
mLongitude=place.latLng!!.longitude
}
The problem is that whenever I type a single alphabet in the Autocomplete, the application crashes saying Intent expected to contain a Place, but doesn't.
What is the problem with my code?
This question didn't help me as I want place.address to return a string address.
logcat:
java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=3, result=2, data=Intent { (has extras) }} to activity {com.example.happyplaces/com.example.happyplaces.activities.AddHappyPlaceActivity}: java.lang.IllegalArgumentException: Intent expected to contain a Place, but doesn't.
at android.app.ActivityThread.deliverResults(ActivityThread.java:4268)
at android.app.ActivityThread.handleSendResult(ActivityThread.java:4312)
at android.app.ActivityThread.-wrap19(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1644)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6494)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
Caused by: java.lang.IllegalArgumentException: Intent expected to contain a Place, but doesn't.
at com.google.android.libraries.places.internal.zzft.zza(com.google.android.libraries.places:places##2.4.0:5)
at com.google.android.libraries.places.internal.zzeg.zza(com.google.android.libraries.places:places##2.4.0:3)
at com.google.android.libraries.places.widget.Autocomplete.getPlaceFromIntent(com.google.android.libraries.places:places##2.4.0:2)
at com.example.happyplaces.activities.AddHappyPlaceActivity.onActivityResult(AddHappyPlaceActivity.kt:253)
at android.app.Activity.dispatchActivityResult(Activity.java:7276)
at android.app.ActivityThread.deliverResults(ActivityThread.java:4264)
at android.app.ActivityThread.handleSendResult(ActivityThread.java:4312) 
at android.app.ActivityThread.-wrap19(Unknown Source:0) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1644) 
at android.os.Handler.dispatchMessage(Handler.java:106) 
at android.os.Looper.loop(Looper.java:164) 
at android.app.ActivityThread.main(ActivityThread.java:6494) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807) 

Parceable error : Unmarshalling unknown type code 7274595 at offset 1112

I go to activity from two fragment and i pass extras through intent the first intent is data
Intent intent = new Intent(getContext(), AllAlbumImgActivity.class);
photoGrapherSavedPhoto.albumName=getResources().getString(R.string.photos);
intent.putExtra(SELECTED_IMG_ID, photoGrapherSavedPhoto.id);
intent.putExtra(LIST_NAME, getActivity().getResources().getString(R.string.photos));
intent.putExtra(LIST_TYPE, CURRENT_PHOTOGRAPHER_PHOTOS_LIST);
intent.putExtra(CURRENT_PAGE, nextPageUrl);
intent.putParcelableArrayListExtra(ALL_ALBUM_IMAGES, (ArrayList<? extends Parcelable>) photoGrapherPhotoList);
intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
startActivityForResult(intent, ALBUM_LIST_REQUEST_CODE);
and it worked fine
the second intent
Intent intent = new Intent(getContext(), AllAlbumImgActivity.class);
photoGrapherSavedPhoto.albumName="Saved";
intent.putExtra(SELECTED_IMG_ID, photoGrapherSavedPhoto.id);
intent.putExtra(LIST_NAME, getActivity().getResources().getString(R.string.saved));
intent.putExtra(LIST_TYPE, CURRENT_PHOTOGRAPHER_SAVED_LIST);
intent.putExtra(CURRENT_PAGE, nextPageUrl);
intent.putParcelableArrayListExtra(ALL_ALBUM_IMAGES, (ArrayList<? extends Parcelable>) photoGrapherSavedPhotoList);
intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
startActivityForResult(intent, ALBUM_LIST_REQUEST_CODE);
but it doesn't work fine with second intent data
here is how i receive the data
if (intent.getSerializableExtra(LIST_TYPE) != null)
photosListType = (Constants.PhotosListType) intent.getSerializableExtra(LIST_TYPE);
if (intent.getStringExtra(LIST_NAME) != null)
topBarTitle.setText(intent.getStringExtra(LIST_NAME));
if (photosListType == CURRENT_PHOTOGRAPHER_PHOTOS_LIST || photosListType == CURRENT_PHOTOGRAPHER_SAVED_LIST) {
nextPageUrl = intent.getStringExtra(CURRENT_PAGE);
}
if (intent.getParcelableArrayListExtra(ALL_ALBUM_IMAGES) != null) {
this.albumImgList = intent.getParcelableArrayListExtra(ALL_ALBUM_IMAGES);
int selectedPosition = intent.getIntExtra(SELECTED_IMG_ID, 0);
for (int i = 0; i < albumImgList.size(); i++) {
if (albumImgList.get(i).id == selectedPosition) {
// Objects.requireNonNull(allAlbumImgRv.getLayoutManager()).smoothScrollToPosition(allAlbumImgRv, null, i);
scrolledPosition = i;
break;
}
}
}
but when i pass the second intent it shows this error
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.softmills.phlog, PID: 14899
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.softmills.phlog/com.example.softmills.phlog.ui.album.view.AllAlbumImgActivity}: java.lang.RuntimeException: Parcel android.os.Parcel#b21b847: Unmarshalling unknown type code 7274595 at offset 1100
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2913)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3048)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1808)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6669)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
Caused by: java.lang.RuntimeException: Parcel android.os.Parcel#b21b847: Unmarshalling unknown type code 7274595 at offset 1100
at android.os.Parcel.readValue(Parcel.java:2747)
at android.os.Parcel.readListInternal(Parcel.java:3098)
at android.os.Parcel.readArrayList(Parcel.java:2319)
at android.os.Parcel.readValue(Parcel.java:2689)
at android.os.Parcel.readArrayMapInternal(Parcel.java:3037)
at android.os.BaseBundle.initializeFromParcelLocked(BaseBundle.java:288)
at android.os.BaseBundle.unparcel(BaseBundle.java:232)
at android.os.BaseBundle.getSerializable(BaseBundle.java:1227)
at android.os.Bundle.getSerializable(Bundle.java:1034)
at android.content.Intent.getSerializableExtra(Intent.java:7516)
at com.example.softmills.phlog.ui.album.view.AllAlbumImgActivity.initView(AllAlbumImgActivity.java:97)
at com.example.softmills.phlog.ui.album.view.AllAlbumImgActivity.onCreate(AllAlbumImgActivity.java:85)
at android.app.Activity.performCreate(Activity.java:7136)
at android.app.Activity.performCreate(Activity.java:7127)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1271)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2893)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3048) 
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78) 
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108) 
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1808) 
at android.os.Handler.dispatchMessage(Handler.java:106) 
at android.os.Looper.loop(Looper.java:193) 
at android.app.ActivityThread.main(ActivityThread.java:6669) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858) 
there i was passing All album as parceable and in the two intent it has the same object
but one work and one generate strange error related to parcelable!!
You can trying this one :
#Parcel
-keepclassmembers class * implements android.os.Parcelable {
static ** CREATOR;
}
Add this to proguard , it can be help u.

Android Studio: Error on BitmapFactory.decodeFile

I have an activity for capturing images with camera. After the snapshot, it is calling the following onActivityResult. I have an error when trying to decode the document (row marked with "ERROR HERE"). Some ideas of the reason? Thanks
Java
//if you capture image, convert to bitmap, show on screen and call readTextFromImage
#Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (resultCode == RESULT_OK) {
if (requestCode == REQUEST_PICTURE_CAPTURE) {
Bitmap bitmap = BitmapFactory.decodeFile(pictureFile.getAbsolutePath()); // <--- ERROR HERE
bitmap = Helper.rotateBitmap(bitmap, pictureFile.getAbsolutePath());
image.setImageBitmap(bitmap);
} else if (requestCode == REQUEST_GET_SINGLE_FILE) {
Bitmap bitmap = null;
try {
bitmap = MediaStore.Images.Media.getBitmap(this.getContentResolver(), data.getData());
} catch (Exception e) {
Log.d("Error Receipt: ", e.toString());
}
if (bitmap != null) {
image.setImageBitmap(bitmap);
}
}
//readTextFromImage();
}
}
Logcat
04-27 18:25:19.276 16179-16179/com.example.ves.gennaio3 E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.ves.gennaio3, PID: 16179
java.lang.RuntimeException: Unable to resume activity {com.example.ves.gennaio3/com.example.ves.gennaio3.ReceiptActivity}: java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=100, result=-1, data=null} to activity {com.example.ves.gennaio3/com.example.ves.gennaio3.ReceiptActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String java.io.File.getAbsolutePath()' on a null object reference
at android.app.ActivityThread.performResumeActivity(ActivityThread.java:3121)
at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:3152)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2495)
at android.app.ActivityThread.-wrap11(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1354)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5443)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:728)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
Caused by: java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=100, result=-1, data=null} to activity {com.example.ves.gennaio3/com.example.ves.gennaio3.ReceiptActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String java.io.File.getAbsolutePath()' on a null object reference
at android.app.ActivityThread.deliverResults(ActivityThread.java:3720)
at android.app.ActivityThread.performResumeActivity(ActivityThread.java:3107)
at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:3152) 
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2495) 
at android.app.ActivityThread.-wrap11(ActivityThread.java) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1354) 
at android.os.Handler.dispatchMessage(Handler.java:102) 
at android.os.Looper.loop(Looper.java:148) 
at android.app.ActivityThread.main(ActivityThread.java:5443) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:728) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618) 
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String java.io.File.getAbsolutePath()' on a null object reference
at com.example.ves.gennaio3.ReceiptActivity.onActivityResult(ReceiptActivity.java:184)
at android.app.Activity.dispatchActivityResult(Activity.java:6442)
at android.app.ActivityThread.deliverResults(ActivityThread.java:3716)
at android.app.ActivityThread.performResumeActivity(ActivityThread.java:3107) 
at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:3152) 
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2495) 
at android.app.ActivityThread.-wrap11(ActivityThread.java) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1354) 
at android.os.Handler.dispatchMessage(Handler.java:102) 
at android.os.Looper.loop(Looper.java:148) 
at android.app.ActivityThread.main(ActivityThread.java:5443) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:728) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618) 
Since you hasn't instantiated pictureFile, it is null by default.
Try
String pictureFile = data.getStringExtra("...","defaultPath");
and then you can use BitmapFactory.decodeFile...
If you declared pictureFile path before, then check your fileProvider.
Regards,
Csongi

Firebase database conflicting getters for name: getAddress

Currently trying out Google's Places API and meanwhile trying to push a Place to my Firebase database. The code below tries to do that but errors out when it is called.
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == PLACE_PICKER_REQUEST) {
if (resultCode == RESULT_OK) {
Place place = PlacePicker.getPlace(this, data);
String toastMsg = String.format("Place: %s", place.getName());
Toast.makeText(this, toastMsg, Toast.LENGTH_LONG).show();
String userUid = FirebaseAuth.getInstance().getCurrentUser().getUid();
DatabaseReference userRef = database.getReference("users/" + userUid);
userRef.setValue(place);
}
}
}
The error I get is as follows:
11-23 18:34:24.874 13155-13155/io.app.roomie E/AndroidRuntime: FATAL EXCEPTION: main
Process: io.app.roomie, PID: 13155
java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=1, result=-1, data=Intent { (has extras) }} to activity {io.app.roomie/io.app.roomie.MainActivity}: com.google.firebase.database.DatabaseException: Found conflicting getters for name: getAddress
at android.app.ActivityThread.deliverResults(ActivityThread.java:4089)
at android.app.ActivityThread.handleSendResult(ActivityThread.java:4132)
at android.app.ActivityThread.-wrap20(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1533)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6119)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
Caused by: com.google.firebase.database.DatabaseException: Found conflicting getters for name: getAddress
at com.google.android.gms.internal.zzamy$zza.<init>(Unknown Source)
at com.google.android.gms.internal.zzamy.zzj(Unknown Source)
at com.google.android.gms.internal.zzamy.zzca(Unknown Source)
at com.google.android.gms.internal.zzamy.zzbz(Unknown Source)
at com.google.firebase.database.DatabaseReference.zza(Unknown Source)
at com.google.firebase.database.DatabaseReference.setValue(Unknown Source)
at io.app.roomie.MainActivity.onActivityResult(MainActivity.java:81)
at android.app.Activity.dispatchActivityResult(Activity.java:6932)
at android.app.ActivityThread.deliverResults(ActivityThread.java:4085)
at android.app.ActivityThread.handleSendResult(ActivityThread.java:4132)
at android.app.ActivityThread.-wrap20(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1533)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6119)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
Sorry about the code formatting. I couldn't get it to work otherwise.
The class com.google.android.gms.location.places.Place is not meant to be directly saved into Firebase.
You should write a simple POJO class that contains only the fields you need from Place, copy the data, and save this simple object into the database.

Categories

Resources