instacart / truetime-android

Android NTP time library. Get the true current time impervious to device clock time changes
https://tech.instacart.com/truetime/
Apache License 2.0
1.41k stars 194 forks source link

Request: Upgrade truetime to work with Android 12 #139

Closed laurenyew-nytimes closed 2 years ago

laurenyew-nytimes commented 3 years ago

Hi, I'm trying to upgrade my project to Android 12 and I use the truetime-android library. When my project uses this dependency, it is failing due to a ManifestMerger issue b/c truetime doesn't have android:exported="false" in it's activity's intent filter in AndroidManifest.xml. Can you please fix this and put out a new release so I can use the library with Android 12 (https://developer.android.com/about/versions/12/behavior-changes-12#exported)? Thanks!

erikhuizinga commented 3 years ago

Might be duplicate of #137 and fixed by #136.

jcrabanal commented 3 years ago

I can confirm that you cannot set targetSdkVersion 31 in apps that depend on TrueTime because the build process fails.

However, you can redeclare the receiver in your app main manifest file, and Android Studio manifest merger will ignore the library declaration:

    <!-- Start the Service if applicable on boot -->
    <receiver android:name="com.instacart.library.truetime.BootCompletedBroadcastReceiver"
        android:exported="false">
        <intent-filter>
            <action android:name="android.intent.action.BOOT_COMPLETED" />
        </intent-filter>
    </receiver>

This is not optimal and you need to remember to remove this once the library is fixed, but it works.

jcrabanal commented 3 years ago

I am checking now more carefully this, and it seems like it needs a lot more work is needed to make it compatible... I'm getting PendingIntent mutability exceptions everywhere, and this seems to be at fault:

https://developer.android.com/about/versions/12/behavior-changes-12#pending-intent-mutability

otorresd commented 2 years ago

So, when this will be ready for android 12?

jcrabanal commented 2 years ago

@otorresd This library seems unmaintained, you're better off downloading the source and fixing it by yourself like I did. It is very simple and contains only a few classes.

I didn't need the boot broadcast receiver so I just removed all of it, problem solved. Otherwise just check my previous comments.

erikhuizinga commented 2 years ago

You might just as well create a maintained FOSS fork (assuming that this repo's license permits it). Note that there are many forks of this repo (likely mostly PRs), maybe there is already a maintained one? Note that there also are other issues/PRs about this in this repo: https://github.com/instacart/truetime-android/issues/139#issuecomment-882458402.

otorresd commented 2 years ago

Ok, thanks

kaushikgopal commented 2 years ago

Duplicated by https://github.com/instacart/truetime-android/pull/136

Feel free to reopen if not the case.