Android device setup library fork

Hello all,

I am working on a product using a P1 module on a custom PCB. I have a prototype Android app that is working well with the device setup library version 0.6.3. I am at a point with my product that I would like to customize the device setup experience. I know that I can modify some strings in the customization.xml resources file, but this doesn’t do enough for me. For example, the device setup library displays a prompt like Please power on your {device_name} by plugging it in. The indicator light should blink {indicator_light_setup_color_name} where the values in brackets can be customized. The problem is I need to change this whole string. The sentence The indicator light should blink... doesn’t make sense for my product.

This shouldn’t be a problem. I can fork the particle-android repo and should be able to modify the device setup library to my heart’s content. But that is turning out to be harder than I thought. First, in order to get device setup to build (using the latest Android Studio) I had to fix some errors about missing resources. Then when I do get device setup (0.6.3) and cloud sdk (1.0.1) built and include the .aar files as dependencies in my app I get the error that is posted here. I tried to revert the changes in the commit that is referenced as causing the error in the issue, but the error persists.

I’m wondering if anyone can point me to an example of a product that uses a forked and customized device setup library.

Thanks!


Edit (more info):
When I use the published device setup library in my app I include the following line in my build.gradle:
implementation 'io.particle:devicesetup:0.6.3. That line also brings in the cloud sdk dependency so I don’t have to write implementation 'io.particle:cloudsdk:1.0.1. In fact if I do include that I get the duplicate class error referenced above. When I build the device setup library from my fork and include that in my app I write implementation 'io.particle:devicesetup:0.6.3@aar and

repositories {
    ...
    flatDir {
        dirs 'path/to/devicesetup/build/outputs/aar'
    }
}

But then, I am learning because aar files don’t include dependencies, my references to io.particle.android.sdk.cloud are not understood. Ok, so I add implementation 'io.particle:cloudsdk:1.0.1'. But then I get the duplicate class error! Ok, so revert back to version 0.5.1 of the cloud sdk and the duplicate class error goes away and my app builds!

But it crashes when I run it because of java.lang.NoClassDefFoundError: Failed resolution of: Ldagger/internal/Preconditions;. I guess this is because device setup lib depends on Dagger and that dependency isn’t packaged into the aar when I build my fork of device setup.

Can someone help me to understand how to build my own copy of the device setup library so that it includes it’s dependencies in a format that is easily digestible by my product’s app? I am very much a novice with Gradle.

I guess the other option is to cram my app into the setup_example_app included with particle-android and use the provided build scripts to get everything linked up that way.

-Colin

I have done some more work on this and now have the device setup library source bundled with my app. Here is what I did.

  1. Copied the devicesetup directory from the particle-android project into my app project.
  2. Added include :devicesetup in my app’s settings.gradle
  3. Copied some buildscript dependencies that I was missing from particle-android/build.gradle to <myapp>/build.gradle
  4. Changed device setup dependency in <myapp>/app/build.gradle from implementation 'io.particle:devicesetup:0.6.3' to 'implementation project(':devicesetup') and added a dependency on the cloud sdk library
  5. In <myapp>/devicesetup/build.gradle changed 'implementation project(':cloudskd') to implementation 'io.particle:cloudsdk:1.0.1' because I didn’t copy the cloud sdk library
  6. In <myapp>/devicesetup/build.gradle removed references to pom_generator_v1.gradle and bintray_upload_v1.gradle
  7. Fixed some issues that were preventing compilation like missing resource ids and bad layout attributes in device setup resource files
  8. In <myapp>/devicesetup/build.gradle added dependencies on jsr305, gson, and okio to fix compilation errors
  9. Updated some uses of the cloud sdk api that had changed with the version change from step 4
  10. In <myapp>/devicesetup/build.gradle added dependencies on retrofit and kotlin-logging to fix runtime class not found errors

Now it looks like the device setup library is working with my app and I can modify as much as I need. I am not thrilled that it will be somewhat challenging to bring in changes as the device setup library is updated by Particle. I hope this helps someone else.

-Colin