Amazon cognito with google button crashes program

I am working on getting cognito working. It works great with the user sign-in and facebook, but for some reason when I add the google button it crashes with a long error messages and a bunch of java.lang.NoClassDefFoundError

I am following the tutorial found here: http://docs.aws.amazon.com/mobile-hub/latest/developerguide/add-aws-mobile-user-sign-in-google.html#google-config-overview

This is the line that causes all of the errors:

        // Add Google as Identity Provider.
    IdentityManager.getDefaultIdentityManager().addSignInProvider(
            GoogleSignInProvider.class);
    GoogleSignInProvider.setPermissions(Scopes.EMAIL, Scopes.PROFILE);

My grade file is as follows

apply plugin: 'com.android.application'

android {
    compileSdkVersion 26
    buildToolsVersion "25.0.2"
    defaultConfig {
        applicationId "com.sniffergps.sniffer"
        minSdkVersion 19
        targetSdkVersion 26
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        multiDexEnabled true
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    compile 'com.android.support:appcompat-v7:26.0.0-alpha1'
    compile 'com.android.support:design:26.0.0-alpha1'
    testCompile 'junit:junit:4.12'

    compile('com.amazonaws:aws-android-sdk-auth-userpools:2.6.0@aar') { transitive = true; }
    compile('com.amazonaws:aws-android-sdk-auth-core:2.6.0@aar') { transitive = true; }

    // SDK Sign-in prompt UI library
    compile('com.amazonaws:aws-android-sdk-auth-ui:2.6.0@aar') { transitive = true; }

    compile 'com.amazonaws:aws-android-sdk-core:2.6.0'
    compile('com.amazonaws:aws-android-sdk-auth-core:2.6.0@aar') { transitive = true; }

    compile('com.amazonaws:aws-android-sdk-auth-facebook:2.6.+@aar') { transitive = true; }

    compile('com.amazonaws:aws-android-sdk-auth-ui:2.6.+@aar') { transitive = true; }

    compile 'com.android.support:support-v4:26.0'
    compile('com.amazonaws:aws-android-sdk-auth-google:2.6.+@aar') { transitive = true; }

    // Dependencies for the SDK Sign-in prompt UI library
    compile('com.amazonaws:aws-android-sdk-auth-ui:2.6.+@aar') { transitive = true; }
    compile 'com.android.support:appcompat-v7:26.0.0-alpha1'
    compile 'com.amazonaws:aws-android-sdk-cognitoidentityprovider:2.6.0'
    compile 'com.amazonaws:aws-android-sdk-core:2.6.0'
    compile 'com.android.support:multidex:1.0.1'
    compile 'com.android.support:support-v4:26.0'
    //compile 'com.android.support.constraint:constraint-layout:+'
    testCompile 'junit:junit:4.12'
    compile 'com.google.android.gms:play-services-maps:10.0.1'

    compile 'com.android.support:support-v4:26.+'
    compile ('com.amazonaws:aws-android-sdk-auth-google:2.6.+@aar') { transitive = true; }

    // Dependencies for the SDK Sign-in prompt UI library
    compile 'com.android.support:appcompat-v7:26.+'
    compile ('com.amazonaws:aws-android-sdk-auth-ui:2.6.+@aar') { transitive = true; }

    compile 'com.amazonaws:aws-android-sdk-ddb-mapper:2.6.0'
}

The error log is below:

10-10 13:12:55.155 26609-26661/com.sniffergps.sniffer I/OpenGLRenderer: Initialized EGL, version 1.4
10-10 13:12:55.155 26609-26661/com.sniffergps.sniffer D/OpenGLRenderer: Swap behavior 2
10-10 13:12:55.186 26609-26659/com.sniffergps.sniffer D/CognitoUserPoolsSignInProvider: CognitoLoginKey: <my login key>
10-10 13:12:55.187 26609-26659/com.sniffergps.sniffer D/GoogleSignInProvider: Initializing Google SDK...
10-10 13:12:55.192 26609-26659/com.sniffergps.sniffer D/GoogleSignInProvider: Created Google SignInOptions.
10-10 13:12:55.205 26609-26659/com.sniffergps.sniffer I/zygote64: Rejecting re-init on previously-failed class java.lang.Class<com.google.android.gms.auth.api.proxy.ProxyRequest>: java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/android/gms/common/internal/safeparcel/AbstractSafeParcelable;
10-10 13:12:55.205 26609-26659/com.sniffergps.sniffer I/zygote64:     at void com.google.android.gms.auth.api.Auth.<clinit>() ((null):-1)
10-10 13:12:55.205 26609-26659/com.sniffergps.sniffer I/zygote64:     at void com.amazonaws.mobile.auth.google.GoogleSignInProvider.initialize(android.content.Context, com.amazonaws.mobile.config.AWSConfiguration) (GoogleSignInProvider.java:133)
10-10 13:12:55.205 26609-26659/com.sniffergps.sniffer I/zygote64:     at void com.amazonaws.mobile.auth.core.signin.SignInManager.<init>(android.content.Context) (SignInManager.java:74)
10-10 13:12:55.205 26609-26659/com.sniffergps.sniffer I/zygote64:     at com.amazonaws.mobile.auth.core.signin.SignInManager com.amazonaws.mobile.auth.core.signin.SignInManager.getInstance(android.content.Context) (SignInManager.java:103)
10-10 13:12:55.205 26609-26659/com.sniffergps.sniffer I/zygote64:     at void com.amazonaws.mobile.auth.core.IdentityManager$7.run() (IdentityManager.java:653)
10-10 13:12:55.205 26609-26659/com.sniffergps.sniffer I/zygote64:     at java.lang.Object java.util.concurrent.Executors$RunnableAdapter.call() (Executors.java:457)
10-10 13:12:55.205 26609-26659/com.sniffergps.sniffer I/zygote64:     at void java.util.concurrent.FutureTask.run() (FutureTask.java:266)
10-10 13:12:55.205 26609-26659/com.sniffergps.sniffer I/zygote64:     at void java.util.concurrent.ThreadPoolExecutor.runWorker(java.util.concurrent.ThreadPoolExecutor$Worker) (ThreadPoolExecutor.java:1162)
10-10 13:12:55.205 26609-26659/com.sniffergps.sniffer I/zygote64:     at void java.util.concurrent.ThreadPoolExecutor$Worker.run() (ThreadPoolExecutor.java:636)
10-10 13:12:55.205 26609-26659/com.sniffergps.sniffer I/zygote64:     at void java.lang.Thread.run() (Thread.java:764)
10-10 13:12:55.205 26609-26659/com.sniffergps.sniffer I/zygote64: Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.android.gms.common.internal.safeparcel.AbstractSafeParcelable" on path: DexPathList[[zip file "/data/app/com.sniffergps.sniffer-XWFh5D8pOM7REOl4SkxjmQ==/base.apk", zip file "/data/app/com.sniffergps.sniffer-XWFh5D8pOM7REOl4SkxjmQ==/split_lib_dependencies_apk.apk", zip file "/data/app/com.sniffergps.sniffer-XWFh5D8pOM7REOl4SkxjmQ==/split_lib_slice_0_apk.apk", zip file "/data/app/com.sniffergps.sniffer-XWFh5D8pOM7REOl4SkxjmQ==/split_lib_slice_1_apk.apk", zip file "/data/app/com.sniffergps.sniffer-XWFh5D8pOM7REOl4SkxjmQ==/split_lib_slice_2_apk.apk", zip file "/data/app/com.sniffergps.sniffer-XWFh5D8pOM7REOl4SkxjmQ==/split_lib_slice_3_apk.apk", zip file "/data/app/com.sniffergps.sniffer-XWFh5D8pOM7REOl4SkxjmQ==/split_lib_slice_4_apk.apk", zip file "/data/app/com.sniffergps.sniffer-XWFh5D8pOM7REOl4SkxjmQ==/split_lib_slice_5_apk.apk", zip file "/data/app/com.sniffergps.sniffer-XWFh5D8pOM7REOl4SkxjmQ==/split_lib_slice_6_apk.apk", zip file "/
10-10 13:12:55.205 26609-26659/com.sniffergps.sniffer I/zygote64:     at java.lang.Class dalvik.system.BaseDexClassLoader.findClass(java.lang.String) (BaseDexClassLoader.java:93)
10-10 13:12:55.205 26609-26659/com.sniffergps.sniffer I/zygote64:     at java.lang.Class java.lang.ClassLoader.loadClass(java.lang.String, boolean) (ClassLoader.java:379)
10-10 13:12:55.205 26609-26659/com.sniffergps.sniffer I/zygote64:     at java.lang.Class java.lang.ClassLoader.loadClass(java.lang.String) (ClassLoader.java:312)
10-10 13:12:55.205 26609-26659/com.sniffergps.sniffer I/zygote64:     at void com.google.android.gms.auth.api.Auth.<clinit>() ((null):-1)
10-10 13:12:55.205 26609-26659/com.sniffergps.sniffer I/zygote64:     at void com.amazonaws.mobile.auth.google.GoogleSignInProvider.initialize(android.content.Context, com.amazonaws.mobile.config.AWSConfiguration) (GoogleSignInProvider.java:133)
10-10 13:12:55.205 26609-26659/com.sniffergps.sniffer I/zygote64:     at void com.amazonaws.mobile.auth.core.signin.SignInManager.<init>(android.content.Context) (SignInManager.java:74)
10-10 13:12:55.205 26609-26659/com.sniffergps.sniffer I/zygote64:     at com.amazonaws.mobile.auth.core.signin.SignInManager com.amazonaws.mobile.auth.core.signin.SignInManager.getInstance(android.content.Context) (SignInManager.java:103)
10-10 13:12:55.205 26609-26659/com.sniffergps.sniffer I/zygote64:     at void com.amazonaws.mobile.auth.core.IdentityManager$7.run() (IdentityManager.java:653)
10-10 13:12:55.205 26609-26659/com.sniffergps.sniffer I/zygote64:     at java.lang.Object java.util.concurrent.Executors$RunnableAdapter.call() (Executors.java:457)
10-10 13:12:55.205 26609-26659/com.sniffergps.sniffer I/zygote64:     at void java.util.concurrent.FutureTask.run() (FutureTask.java:266)
10-10 13:12:55.205 26609-26659/com.sniffergps.sniffer I/zygote64:     at void java.util.concurrent.ThreadPoolExecutor.runWorker(java.util.concurrent.ThreadPoolExecutor$Worker) (ThreadPoolExecutor.java:1162)
10-10 13:12:55.205 26609-26659/com.sniffergps.sniffer I/zygote64:     at void java.util.concurrent.ThreadPoolExecutor$Worker.run() (ThreadPoolExecutor.java:636)
10-10 13:12:55.205 26609-26659/com.sniffergps.sniffer I/zygote64:     at void java.lang.Thread.run() (Thread.java:764)
10-10 13:12:55.206 26609-26659/com.sniffergps.sniffer I/zygote64: Rejecting re-init on previously-failed class java.lang.Class<com.google.android.gms.auth.api.proxy.ProxyRequest>: java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/android/gms/common/internal/safeparcel/AbstractSafeParcelable;
10-10 13:12:55.206 26609-26659/com.sniffergps.sniffer I/zygote64:     at void com.google.android.gms.auth.api.Auth.<clinit>() ((null):-1)
10-10 13:12:55.206 26609-26659/com.sniffergps.sniffer I/zygote64:     at void com.amazonaws.mobile.auth.google.GoogleSignInProvider.initialize(android.content.Context, com.amazonaws.mobile.config.AWSConfiguration) (GoogleSignInProvider.java:133)
10-10 13:12:55.206 26609-26659/com.sniffergps.sniffer I/zygote64:     at void com.amazonaws.mobile.auth.core.signin.SignInManager.<init>(android.content.Context) (SignInManager.java:74)
10-10 13:12:55.206 26609-26659/com.sniffergps.sniffer I/zygote64:     at com.amazonaws.mobile.auth.core.signin.SignInManager com.amazonaws.mobile.auth.core.signin.SignInManager.getInstance(android.content.Context) (SignInManager.java:103)
10-10 13:12:55.206 26609-26659/com.sniffergps.sniffer I/zygote64:     at void com.amazonaws.mobile.auth.core.IdentityManager$7.run() (IdentityManager.java:653)
10-10 13:12:55.206 26609-26659/com.sniffergps.sniffer I/zygote64:     at java.lang.Object java.util.concurrent.Executors$RunnableAdapter.call() (Executors.java:457)
10-10 13:12:55.206 26609-26659/com.sniffergps.sniffer I/zygote64:     at void java.util.concurrent.FutureTask.run() (FutureTask.java:266)
10-10 13:12:55.206 26609-26659/com.sniffergps.sniffer I/zygote64:     at void java.util.concurrent.ThreadPoolExecutor.runWorker(java.util.concurrent.ThreadPoolExecutor$Worker) (ThreadPoolExecutor.java:1162)
10-10 13:12:55.206 26609-26659/com.sniffergps.sniffer I/zygote64:     at void java.util.concurrent.ThreadPoolExecutor$Worker.run() (ThreadPoolExecutor.java:636)
10-10 13:12:55.206 26609-26659/com.sniffergps.sniffer I/zygote64:     at void java.lang.Thread.run() (Thread.java:764)
10-10 13:12:55.206 26609-26659/com.sniffergps.sniffer I/zygote64: Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.android.gms.common.internal.safeparcel.AbstractSafeParcelable" on path: DexPathList[[zip file "/data/app/com.sniffergps.sniffer-XWFh5D8pOM7REOl4SkxjmQ==/base.apk", zip file "/data/app/com.sniffergps.sniffer-XWFh5D8pOM7REOl4SkxjmQ==/split_lib_dependencies_apk.apk", zip file "/data/app/com.sniffergps.sniffer-XWFh5D8pOM7REOl4SkxjmQ==/split_lib_slice_0_apk.apk", zip file "/data/app/com.sniffergps.sniffer-XWFh5D8pOM7REOl4SkxjmQ==/split_lib_slice_1_apk.apk", zip file "/data/app/com.sniffergps.sniffer-XWFh5D8pOM7REOl4SkxjmQ==/split_lib_slice_2_apk.apk", zip file "/data/app/com.sniffergps.sniffer-XWFh5D8pOM7REOl4SkxjmQ==/split_lib_slice_3_apk.apk", zip file "/data/app/com.sniffergps.sniffer-XWFh5D8pOM7REOl4SkxjmQ==/split_lib_slice_4_apk.apk", zip file "/data/app/com.sniffergps.sniffer-XWFh5D8pOM7REOl4SkxjmQ==/split_lib_slice_5_apk.apk", zip file "/data/app/com.sniffergps.sniffer-XWFh5D8pOM7REOl4SkxjmQ==/split_lib_slice_6_apk.apk", zip file "/
10-10 13:12:55.206 26609-26659/com.sniffergps.sniffer I/zygote64:     at java.lang.Class dalvik.system.BaseDexClassLoader.findClass(java.lang.String) (BaseDexClassLoader.java:93)
10-10 13:12:55.206 26609-26659/com.sniffergps.sniffer I/zygote64:     at java.lang.Class java.lang.ClassLoader.loadClass(java.lang.String, boolean) (ClassLoader.java:379)
10-10 13:12:55.206 26609-26659/com.sniffergps.sniffer I/zygote64:     at java.lang.Class java.lang.ClassLoader.loadClass(java.lang.String) (ClassLoader.java:312)
10-10 13:12:55.206 26609-26659/com.sniffergps.sniffer I/zygote64:     at void com.google.android.gms.auth.api.Auth.<clinit>() ((null):-1)
10-10 13:12:55.206 26609-26659/com.sniffergps.sniffer I/zygote64:     at void com.amazonaws.mobile.auth.google.GoogleSignInProvider.initialize(android.content.Context, com.amazonaws.mobile.config.AWSConfiguration) (GoogleSignInProvider.java:133)
10-10 13:12:55.206 26609-26659/com.sniffergps.sniffer I/zygote64:     at void com.amazonaws.mobile.auth.core.signin.SignInManager.<init>(android.content.Context) (SignInManager.java:74)
10-10 13:12:55.206 26609-26659/com.sniffergps.sniffer I/zygote64:     at com.amazonaws.mobile.auth.core.signin.SignInManager com.amazonaws.mobile.auth.core.signin.SignInManager.getInstance(android.content.Context) (SignInManager.java:103)
10-10 13:12:55.206 26609-26659/com.sniffergps.sniffer I/zygote64:     at void com.amazonaws.mobile.auth.core.IdentityManager$7.run() (IdentityManager.java:653)
10-10 13:12:55.206 26609-26659/com.sniffergps.sniffer I/zygote64:     at java.lang.Object java.util.concurrent.Executors$RunnableAdapter.call() (Executors.java:457)
10-10 13:12:55.206 26609-26659/com.sniffergps.sniffer I/zygote64:     at void java.util.concurrent.FutureTask.run() (FutureTask.java:266)
10-10 13:12:55.206 26609-26659/com.sniffergps.sniffer I/zygote64:     at void java.util.concurrent.ThreadPoolExecutor.runWorker(java.util.concurrent.ThreadPoolExecutor$Worker) (ThreadPoolExecutor.java:1162)
10-10 13:12:55.206 26609-26659/com.sniffergps.sniffer I/zygote64:     at void java.util.concurrent.ThreadPoolExecutor$Worker.run() (ThreadPoolExecutor.java:636)
10-10 13:12:55.206 26609-26659/com.sniffergps.sniffer I/zygote64:     at void java.lang.Thread.run() (Thread.java:764)
...<and many more>...
10-10 13:12:56.421 26609-26615/com.sniffergps.sniffer I/zygote64: Do partial code cache collection, code=30KB, data=23KB
10-10 13:12:56.423 26609-26615/com.sniffergps.sniffer I/zygote64: After code cache collection, code=30KB, data=23KB
10-10 13:12:56.423 26609-26615/com.sniffergps.sniffer I/zygote64: Increasing code cache capacity to 128KB

org.hibernate.PropertyAccessException: Could not set field value with Composite Key

Using Spring Boot with Hibernate JPA

I am having trouble accessing a DAO for an @Entity which has a composite key where one of the columns is a foreign key. It’s giving me
org.hibernate.PropertyAccessException: Could not set field value [...] by reflection when I try to do a findOne() using the DAO.

So I have two MySQL relations, all_contacts and contact_phones, represented in order here:

all_contacts contact_phones

contact_phones has a composite primary key consisting of contactid + number, of those two, contactId is also a foreign key for the same value in all_contacts. I’ve established the relationship using the proper @OneToMany and @ManyToOne annotations

Entity for all_contacts:

    @Entity
    @Table(name = "all_contacts")
    public class Contact {

      @Column(name="userid", columnDefinition ="bigint(13)")
      private BigInteger userId;

      @Id
      @GeneratedValue(strategy = GenerationType.AUTO)
      @Column(name="contactid", columnDefinition ="bigint(13)")
      private BigInteger contactId;


     @OneToMany(mappedBy = "contact", cascade = CascadeType.ALL)
     @ElementCollection(targetClass=ContactPhones.class)
     private Set<ContactPhones> phones = new HashSet<ContactPhones>(0);

    // the rest of the fields, including getters and setters

    }

Entity for contact_phones:

@Entity
@Table( name ="contact_phones")
@IdClass(ContactPhonesKey.class)
public class ContactPhones {


  @ManyToOne(fetch = FetchType.LAZY)
  @JoinColumn(name="contactid", nullable = false)
  @Id
  private Contact contact;

  @Column(name="phone_type", columnDefinition = "")
  private String phoneType;

  @Id
  @Column(columnDefinition ="bigint(13)")
  private BigInteger number;

  // getters and setters
}

And, because the primary key of the contact_phones class was composite (hence the @IdClass(ContactPhonesKey.class) ), I was forced to create a Key class to direct it:

Class for ContactPhonesKey:

public class ContactPhonesKey implements Serializable {

  private Contact contact;
  private String number;

  public ContactPhonesKey() {}

  public ContactPhonesKey(Contact contact, String number) {
    this.contact = contact;
    this.number = number;
  }

// getters and setters 

}

However, whenever I try to access something by the DAO (when I have created an instance of it by @Autowired) I made for the contact_phones class:

public interface ContactPhonesRepository extends CrudRepository<ContactPhones, BigInteger> {

  List<ContactPhones> findByNumberContaining(String number);


  @Query(value ="SELECT * FROM contact_phones cp WHERE cp.contactid= :contactId",
          nativeQuery=true)
  List<ContactPhones> findAllPhonesByContactId(@Param("contactId")BigInteger contactId);

}

I am getting an error about not being able to set the ContactPhonesKey class due to reflection. Here’s the full error I get:

Could not set field value [111456666] value by reflection : [class app.models.relationentities.ContactPhonesKey.number] setter of app.models.relationentities.ContactPhonesKey.number; nested exception is org.hibernate.PropertyAccessException: Could not set field value [111456666] value by reflection : [class app.models.relationentities.ContactPhonesKey.number] setter of app.models.relationentities.ContactPhonesKey.number

Java inner interfaces as return types

I’m learning Java and recently came across the following piece of code that is working properly, but I don’t understand why:

public class ExecutionChain<Result> {

    Parametriezed1<Result>  classMethod1() {
        return this::method1;
    }

    Parametriezed2<Result> method1() {
        return this::method2;
    }

    Result method2(Result result) {
        return result;
    }

    interface Parametriezed1<Result> {
        Parametriezed2 method1();
    }

    interface Parametriezed2<Result> {
        Result method2(Result result);
    }
}

Could someone please explain:

  • why method1 seems to be overriding Parametriezed2 method1() without ExecutionChain implementing Parametriezed1
  • why it is ok to call this::method1 in spite of the fact that neither method1 nor method2 returns Parametriezed1 type?

I would be more than grateful for some documentation for the principles that were used here.

Disable Google Calendar Push Notification when app is an owner of the change

When I create/update a Google Event from my app using java client:

events
.insert(originalCalendarId, googleEvent)
.setSupportsAttachments(true)
.execute()

I’m still getting push-notifications about event creation/update.
I don’t want to get them since I’m the one who did these changes. The changes are applied on the app in a different way and additional push notifications are useless in this case.

However, I need to get new changes when they are made somewhere else(another app or Google Web UI).

Is there a way to handle this case? Maybe there is an approach to make Google know that push-notifications for specific queries aren’t needed.

I also see that there is a property:

com.google.api.services.calendar.Calendar.Events.Insert#sendNotifications

But, no matter what I set here, notifications are still sent.

What’s the best way to get a Class object for an array type?

It’s easy to get a class literal for a class:

String.class

But how can I get a class object for an array type?

This works, but it’s ugly, and probably not a compile time constant:

new byte[0].getClass()

I looked in the JLS but the only thing I found out is that what I’m calling a “class literal” isn’t a “literal” according to the JLS definition.

Java switch between panels (using custom buttons) on JFrame

I want to make a some kind of modern GUI that has tabs on left, like shown on this picture:

enter image description here

Any ideas how could I make panels switch between while not disposing data that’s written/set, for example into text fields, text area, check boxs, scroll bars and etc.?

I was thinking about just removing old one panel and adding another panel, but when I click on panel I visited before controls data will have been reset, and I think it would flicker.

How do i limit the user to only inputting 1-3

import java.util.Random;
import java.io.*;
import java.util.*;
/**
    Courtney Fox 
    Professor Yao
    Midterm Part 1
    10/10/17
    Purpose:
      The purpose of this program is to develop a Nim game that consists of a
      pile of stones ranging from 10-16. From that pile, both the player and 
      computer have to pick up to 3 stones and whoever gets the last stone 
      loses. 
   Logic:
**/   
public class FoxMidQ1
{
   public static void main(String[] args)
   {
      //Variables
      int user = 0;
      //int computer;
      //int loser;
      int gamenum = 0;
      //Scanner
      Scanner input = new Scanner(System.in);
     //Welcome Output
     System.out.println("Welcome to Nim Game!");
     //Get pile size: Randomly generate 10-16
     int[] pile = {10, 11, 12, 13, 14, 15 , 16};
     int stones = pile[(int)(Math.random() * pile.length)];
     System.out.println("Game #"+ (gamenum + 1) +": There are "+ stones + " 
     stones in the pile.");
     System.out.println("You can remove up to 3 stones from pile at a 
     time.");
     //User takes stones
     System.out.println("How many stones would you like to remove? ");
     user = input.nextInt();

I got the beginning started but I’m stuck at the part where the user is only suppose to take 1,2, or 3 stones from the pile. I tried doing do,while,for,if,else and none of those loops are doing what I want it to do because the user is only suppose to have one turn then its the computers turn to pick up to 3 stones out of the pile.

Xamarin Change photo metadata

Is it possible to change photo metadata? It is guarantee that my app is runned with enabled gps, but I need to take a photo with current longitude and latitude, so gps have to be enabled in default camera app too. Can I take a photo, and, then set the location to it’s metadata?