Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Fix] OneSignalConfig.androidlib minSdkVersion and targetSdkVersion for Unity 2021 #675

Merged
merged 2 commits into from
Jan 23, 2024

Conversation

shepherd-l
Copy link
Contributor

@shepherd-l shepherd-l commented Jan 10, 2024

Description

One Line Summary

Fixes OneSignalConfig.androidlib minSdkVersion and targetSdkVersion Android build errors in Unity 2021

Details

Motivation

Fixes the following Android build error in Unity 2021.3.10 that occurs when calling defaultConfig.minSdk and similarly for defaultConfig.targetSdk. This error does not occur in Unity 2022.3.10.

A problem occurred evaluating project ':unityLibrary:OneSignalConfig.androidlib'.
> Could not get unknown property 'minSdk' for DefaultConfig_Decorated{name=main, dimension=null, minSdkVersion=DefaultApiVersion{mApiLevel=22, mCodename='null'}, targetSdkVersion=DefaultApiVersion{mApiLevel=30, mCodename='null'}, renderscriptTargetApi=null, renderscriptSupportModeEnabled=null, renderscriptSupportModeBlasEnabled=null, renderscriptNdkModeEnabled=null, versionCode=1, versionName=0.1, applicationId=null, testApplicationId=null, testInstrumentationRunner=null, testInstrumentationRunnerArguments={}, testHandleProfiling=null, testFunctionalTest=null, signingConfig=null, resConfig=[], mBuildConfigFields={}, mResValues={}, mProguardFiles=[], mConsumerProguardFiles=[/Users/shepherd/projects/My project (1)/Library/Bee/Android/Prj/Mono2x/Gradle/unityLibrary/proguard-unity.txt], mManifestPlaceholders={}, mWearAppUnbundled=null} of type com.android.build.gradle.internal.dsl.DefaultConfig.

Both Unity versions successfully build when using defaultConfig.minSdkVersion.mApiLevel and defaultConfig.minSdkVersion.mApiLevel

Scope

In the next release, devs need to apply the changes made to OneSignalConfig.androidlib:

  1. Delete their current OneSignalConfig.androidlib in their Unity project
  2. Go to Window > OneSignal SDK Setup and run the "Copy Android plugin to Assets" step to add the updated OneSignalConfig.androidlib back in their project

Testing

Manual testing

Tested building for Android on a new Unity project (3D Core template) with the OneSignal SDK installed with Unity 2021.3.10f1 and 2022.3.10f1. Also tested building for Android with the OneSignal example app on Unity 2022.3.10f1.

Affected code checklist

  • Notifications
    • Display
    • Open
    • Push Processing
    • Confirm Deliveries
  • Outcomes
  • Sessions
  • In-App Messaging
  • REST API requests
  • Public API changes

Checklist

Overview

  • I have filled out all REQUIRED sections above
  • PR does one thing
  • Any Public API changes are explained in the PR details and conform to existing APIs

Testing

  • I have included test coverage for these changes, or explained why they are not needed
  • All automated tests pass, or I explained why that is not possible
  • I have personally tested this on my device, or explained why that is not possible

Final pass

  • Code is as readable as possible.
  • I have reviewed this PR myself, ensuring it meets each checklist item

This change is Reviewable

Copy link
Contributor

@jinliu9508 jinliu9508 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Confirmed that the change works in Unity and Android.

In Unity 2021.3.10, "defaultConfig.minSdk" produces the Android build error: Could not get unknown property. This error does not occur in Unity 2022.3.10. Since both Unity versions can successfully build with "defaultConfig.minSdkVersion.mApiLevel" , this change was made.
Deleted OneSignalConfig.androidlib from example project and ran Window > OneSignal SDK Setup > Copy Android plugin to Assets to apply changes made in previous commit to the example app
@shepherd-l shepherd-l force-pushed the fix/OneSignalConfigSdkVersions branch from c3f2dee to 3e1d04e Compare January 23, 2024 17:31
@shepherd-l shepherd-l merged commit ab49686 into user-model/main Jan 23, 2024
1 check passed
@shepherd-l shepherd-l deleted the fix/OneSignalConfigSdkVersions branch January 23, 2024 17:33
jinliu9508 pushed a commit that referenced this pull request Feb 23, 2024
[Fix] OneSignalConfig.androidlib minSdkVersion and targetSdkVersion for Unity 2021
jinliu9508 pushed a commit that referenced this pull request Feb 27, 2024
[Fix] OneSignalConfig.androidlib minSdkVersion and targetSdkVersion for Unity 2021
jinliu9508 pushed a commit that referenced this pull request Feb 27, 2024
[Fix] OneSignalConfig.androidlib minSdkVersion and targetSdkVersion for Unity 2021
jinliu9508 pushed a commit that referenced this pull request Feb 27, 2024
[Fix] OneSignalConfig.androidlib minSdkVersion and targetSdkVersion for Unity 2021
jinliu9508 pushed a commit that referenced this pull request Feb 27, 2024
[Fix] OneSignalConfig.androidlib minSdkVersion and targetSdkVersion for Unity 2021
jinliu9508 pushed a commit that referenced this pull request Mar 1, 2024
[Fix] OneSignalConfig.androidlib minSdkVersion and targetSdkVersion for Unity 2021
jinliu9508 pushed a commit that referenced this pull request Mar 4, 2024
[Fix] OneSignalConfig.androidlib minSdkVersion and targetSdkVersion for Unity 2021
jinliu9508 pushed a commit that referenced this pull request Mar 4, 2024
[Fix] OneSignalConfig.androidlib minSdkVersion and targetSdkVersion for Unity 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants