Android SDK sort of working!

This is my first time doing anything mobile related but am getting somewhere. I loaded up the example SDK app (https://github.com/particle-iot/particle-android) and after much trouble got it working.

For those who get stuck in creating the APK, I found that one of the MainActivity files (setup_testapp/java/MainActivity) was using a pre-AndroidX version of appcompat, and by replacing with androidx.appcompat.app.AppCompatActivity; everything works perfectly. There may be a better way to fix this, but worked for me.

I am left with an issue. I loaded the APK on my phone, logged into Particle, and tried to claim a new Photon:

The new Photon is flashing dark blue as it should be, and I can see its WiFi if I scan, but the app makes no effort to find it. It doesn’t change from its WiFi setting, and no devices ever appear on this screen.

Any ideas ??

cheers!

Did you by any chance change the device’s SoftAP prefix?
The default mobile app will look for networks starting with PHOTON
If you changed only one side of the equation (mobile app or device System.set(SYSTEM_CONFIG_SOFTAP_PREFIX, "????")) the two won’t find together.

2 Likes

Thanks @ScruffR, that was the problem !! got it working !

thanks

So now I have the AP issue working perfectly ! Next issue is the authenticating new users into our product.

I went ahead and created a client id and client secret, and inserted them here:

The apk builds just fine as before. When I now start the app I am not able to register a new user. Presumably this should create a Customer inside the Particle Product page.

When trying to create a new customer, I am either told that the user already exists (it doesn’t), or that the credentials are invalid.

I should add that the Product page inside the Particle Console feel a bit buggy… I cannot manually add devices in some products, but can in others… Also I cannot open the settings without a ‘bummer’ notice.

Any ideas!?

thanks

Customer management isn’t anything I had to deal with yet.
Maybe @rickkas7 can chime in for that issue.

1 Like

@rickkas7 Hi, just to provide more info:

I created a new Product (Grillo Earthquake Alarm), and a new OAuth Client (Simple Auth):

I then added the supplied Client Id and Client Secret to the location above in my Android project, oauth_client_creds.xml

The project builds just fine and I am able to start the APK on my phone, but I constantly get ‘Credentials are invalid’ when entering a user at the start.

@rickkas7 another thought, when I use the supplied Client ID and Client Secret from the Particle Example App, the user registration works fine.

When I use my own Client ID and Client Secret as generated via Simple OAuth on my product page, I get the credential invalid errror on user registration.

Is the problem with Particle ?

Ok, case closed !!

For anyone interested, there is a checklist that should prob be somewhere in the docs related to setting up a product. Here goes;

  1. The mobile SDK needs the specific ‘product_id’ from the product you have setup.
  2. The mobile SDK needs ‘productMode’ to be set to ‘true’
  3. Any devices you are going to use in the product must be added manually using their serial in the portal before you can claim them
  4. Using an old product, like one I had created 3 years ago, does not seem to work (maybe because it has 3 numbers for product_id rather than 4?)
  5. The device type you set when creating the product matters… I had no idea why my photon wasn’t able to be added as a device. Turns out I had set it as a P1 product…

Hey @grillo

Here in the mobile SDK the following two items need to be entered?

  1. The mobile SDK needs the specific ‘product_id’ from the product you have setup.
  2. The mobile SDK needs ‘productMode’ to be set to ‘true’