Skip to content

Commit

Permalink
Merge pull request #644 from OneSignal/fix/proguardAndroidlib
Browse files Browse the repository at this point in the history
[Fix] Android minify builds
  • Loading branch information
shepherd-l authored and jinliu9508 committed Feb 23, 2024
2 parents 3297f61 + 819d6bc commit 4fe1d74
Show file tree
Hide file tree
Showing 67 changed files with 144 additions and 865 deletions.
14 changes: 7 additions & 7 deletions MIGRATION_GUIDE_v3_to_v5.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,15 @@ OneSignal uses a built-in **alias label** called `external_id` which supports ex
Follow one of the following sections based on your previous install method of the OneSignal SDK.

### Unity Package Manager
1. If you have them, delete the directory at `Assets/OneSignal` and the xml file at `Assets/Plugins/Android/OneSignalConfig.plugin/AndroidManifest.xml`
1. If you have it, delete the directory at `Assets/OneSignal`
2. In Unity, open **Window > Package Manager**
3. From the **Package Manager** window, select **Packages:** in the top left and click on **In Project**
4. Select the OneSignal Unity SDK(s) and press the **Upgrade to 5.x.x** button (make sure to update both Android and iOS packages)
5. Follow the [API Reference](#api-reference) guide below to fix any compilation errors with the new namespaces and updated method calls
6. Check the menu at **Window > OneSignal SDK Setup** to see if there are any remaining steps to run

### Unity Asset Store
1. Delete the directory at `Assets/OneSignal` and the xml file at `Assets/Plugins/Android/OneSignalConfig.plugin/AndroidManifest.xml`
1. Delete the directory at `Assets/OneSignal`
2. In Unity, open **Window > Package Manager**
3. From the **Package Manager** window, select **Packages:** in the top left and click on **My Assets**
4. Select the **OneSignal SDK** from the list and press the **Update** button.
Expand All @@ -50,13 +50,13 @@ Follow one of the following sections based on your previous install method of th
9. Navigate back to the menu at **Window > OneSignal SDK Setup** to see if there are any remaining steps to run

### Unitypackage Distributable
1. Delete the directory at `Assets/OneSignal` and the xml file at `Assets/Plugins/Android/OneSignalConfig.plugin/AndroidManifest.xml`
1. Delete the directory at `Assets/OneSignal`
2. Download the latest release from our [releases page](https://github.com/OneSignal/OneSignal-Unity-SDK/releases)
3. In Unity, navigate to **Assets > Import Package > Custom Package...** and select the newly downloaded `*.unitypackage` file
4. Navigate to **Window > OneSignal SDK Setup**
7. Click **Run All Steps**
8. Follow the [API Reference](#api-reference) guide below to fix any compilation errors with the new namespaces and updated method calls
9. Navigate back to the menu at **Window > OneSignal SDK Setup** to see if there are any remaining steps to run
5. Click **Run All Steps**
6. Follow the [API Reference](#api-reference) guide below to fix any compilation errors with the new namespaces and updated method calls
7. Navigate back to the menu at **Window > OneSignal SDK Setup** to see if there are any remaining steps to run

## Code Modularization

Expand Down Expand Up @@ -259,7 +259,7 @@ Assets/OneSignal/Example/OneSignalExampleBehaviou.cs: error CS0246: The type or
Assets/OneSignal/Attribution/OneSignalVSAttribution.cs: error CS0117: 'OneSignal' does not contain a definition for '...'
```

1. Delete the directory at `Assets/OneSignal` and the xml file at `Assets/Plugins/Android/OneSignalConfig.plugin/AndroidManifest.xml`
1. Delete the directory at `Assets/OneSignal`
- If you would like to regenerate the OneSignal assets, remove the OneSignal Unity SDK packages (Android, Core, iOS) from your project and import the OneSignal SDK again.
2. Check the menu at **Window > OneSignal SDK Setup** to see if there are any remaining steps to run

Expand Down
1 change: 1 addition & 0 deletions OneSignalExample/Assets/OneSignal/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed
- Sending VSAttribution data from the editor
- iOS notifications clicked event firing if the app was cold started from clicking a notification
- ClassNotFoundException: com.onesignal.OneSignal for Android builds with minify enabled. You must run the "Copy Android plugin to Assets" step in **Window > OneSignal SDK Setup**.

## [5.0.2]
### Fixed
Expand Down
14 changes: 7 additions & 7 deletions OneSignalExample/Assets/OneSignal/MIGRATION_GUIDE_v3_to_v5.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,15 @@ OneSignal uses a built-in **alias label** called `external_id` which supports ex
Follow one of the following sections based on your previous install method of the OneSignal SDK.

### Unity Package Manager
1. If you have them, delete the directory at `Assets/OneSignal` and the xml file at `Assets/Plugins/Android/OneSignalConfig.plugin/AndroidManifest.xml`
1. If you have it, delete the directory at `Assets/OneSignal`
2. In Unity, open **Window > Package Manager**
3. From the **Package Manager** window, select **Packages:** in the top left and click on **In Project**
4. Select the OneSignal Unity SDK(s) and press the **Upgrade to 5.x.x** button (make sure to update both Android and iOS packages)
5. Follow the [API Reference](#api-reference) guide below to fix any compilation errors with the new namespaces and updated method calls
6. Check the menu at **Window > OneSignal SDK Setup** to see if there are any remaining steps to run

### Unity Asset Store
1. Delete the directory at `Assets/OneSignal` and the xml file at `Assets/Plugins/Android/OneSignalConfig.plugin/AndroidManifest.xml`
1. Delete the directory at `Assets/OneSignal`
2. In Unity, open **Window > Package Manager**
3. From the **Package Manager** window, select **Packages:** in the top left and click on **My Assets**
4. Select the **OneSignal SDK** from the list and press the **Update** button.
Expand All @@ -50,13 +50,13 @@ Follow one of the following sections based on your previous install method of th
9. Navigate back to the menu at **Window > OneSignal SDK Setup** to see if there are any remaining steps to run

### Unitypackage Distributable
1. Delete the directory at `Assets/OneSignal` and the xml file at `Assets/Plugins/Android/OneSignalConfig.plugin/AndroidManifest.xml`
1. Delete the directory at `Assets/OneSignal`
2. Download the latest release from our [releases page](https://github.com/OneSignal/OneSignal-Unity-SDK/releases)
3. In Unity, navigate to **Assets > Import Package > Custom Package...** and select the newly downloaded `*.unitypackage` file
4. Navigate to **Window > OneSignal SDK Setup**
7. Click **Run All Steps**
8. Follow the [API Reference](#api-reference) guide below to fix any compilation errors with the new namespaces and updated method calls
9. Navigate back to the menu at **Window > OneSignal SDK Setup** to see if there are any remaining steps to run
5. Click **Run All Steps**
6. Follow the [API Reference](#api-reference) guide below to fix any compilation errors with the new namespaces and updated method calls
7. Navigate back to the menu at **Window > OneSignal SDK Setup** to see if there are any remaining steps to run

## Code Modularization

Expand Down Expand Up @@ -259,7 +259,7 @@ Assets/OneSignal/Example/OneSignalExampleBehaviou.cs: error CS0246: The type or
Assets/OneSignal/Attribution/OneSignalVSAttribution.cs: error CS0117: 'OneSignal' does not contain a definition for '...'
```

1. Delete the directory at `Assets/OneSignal` and the xml file at `Assets/Plugins/Android/OneSignalConfig.plugin/AndroidManifest.xml`
1. Delete the directory at `Assets/OneSignal`
- If you would like to regenerate the OneSignal assets, remove the OneSignal Unity SDK packages (Android, Core, iOS) from your project and import the OneSignal SDK again.
2. Check the menu at **Window > OneSignal SDK Setup** to see if there are any remaining steps to run

Expand Down
6 changes: 3 additions & 3 deletions OneSignalExample/Assets/OneSignal/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ And via many additional platforms. [Check them all out](https://documentation.on
## Requirements
- A [OneSignal Account](https://app.onesignal.com/signup) if you do not already have one
- Your OneSignal App ID which you can find under **Settings > Keys & IDs**
- Unity 2018.4 or newer
- Unity 2021.3 or newer
- iOS Builds: CocoaPods 1.11.3 or newer
- In order to test push notifications you will need
- An Android 4.0.3 or newer device or emulator with "Google Play services" installed
Expand Down Expand Up @@ -122,8 +122,8 @@ After building in Unity and exporting the XCode project follow these steps:
### Android
Most of the Android setup was already handled during installation!
The only thing remaining is to setup your own notification icons. You can do this be replacing the example icons located at `Assets/Plugins/Android/OneSignalConfig.plugin`
with your own. There is a complete guide for this [in the plugin's README](com.onesignal.unity.android/Editor/OneSignalConfig.plugin/README.md). See our
The only thing remaining is to setup your own notification icons. You can do this be replacing the example icons located at `Assets/Plugins/Android/OneSignalConfig.androidlib`
with your own. There is a complete guide for this [in the plugin's README](com.onesignal.unity.android/Editor/OneSignalConfig.androidlib/README.md). See our
[Customize Notification Icons](https://documentation.onesignal.com/docs/customize-notification-icons) page for additional details.
## Usage
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ public static class OneSignalSetupReset {
public static void ResetAllSteps() {
/*
* ExportAndroidResourcesStep
* deletes the OneSignalConfig.plugin directory
* deletes the OneSignalConfig.androidlib directory
*/
AssetDatabase.DeleteAsset(Path.Combine("Assets", "Plugins", "Android", "OneSignalConfig.plugin"));
AssetDatabase.DeleteAsset(Path.Combine("Assets", "Plugins", "Android", "OneSignalConfig.androidlib"));

/*
* InstallEdm4UStep
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -48,16 +48,16 @@ You must be sure the icon filenames are correct as per the above table. If you u
have already been done for you.

### Step 2 - Add icons to project
If you have already run our SDK setup wizard (found in the Unity Editor via the `Window > OneSignal` menu) then you will already have the
`OneSignalConfig.plugin` imported into your project at the path `/Assets/Plugins/Android/OneSignalConfig.plugin`. If this is not the case
If you have already run our SDK setup wizard (found in the Unity Editor via the `Window > OneSignal SDK Setup` menu) then you will already have the
`OneSignalConfig.androidlib` imported into your project at the path `/Assets/Plugins/Android/OneSignalConfig.androidlib`. If this is not the case
please run the step **"Copy Android plugin to Assets"** to do so. Once this is ready you can simply copy the files you made in step 1 to
the correct paths:

| Path | Density (dp) | Size (px) |
|------------------------------------------------------------------------------------------------------------|--------------|-----------|
| Assets/Plugins/Android/OneSignalConfig.plugin/res/**drawable-mdpi**/ic_stat_onesignal_default.png | MDPI | 24x24 |
| Assets/Plugins/Android/OneSignalConfig.plugin/res/**drawable-hdpi**/ic_stat_onesignal_default.png | HDPI | 36x36 |
| Assets/Plugins/Android/OneSignalConfig.plugin/res/**drawable-xhdpi**/ic_stat_onesignal_default.png | XHDPI | 48x48 |
| Assets/Plugins/Android/OneSignalConfig.plugin/res/**drawable-xxhdpi**/ic_stat_onesignal_default.png | XXHDPI | 72x72 |
| Assets/Plugins/Android/OneSignalConfig.plugin/res/**drawable-xxxhdpi**/ic_stat_onesignal_default.png | XXXHDPI | 96x96 |
| Assets/Plugins/Android/OneSignalConfig.plugin/res/**drawable-xxxhdpi**/ic_onesignal_large_icon_default.png | XXXHDPI | 256x256 |
| Assets/Plugins/Android/OneSignalConfig.androidlib/src/main/res/**drawable-mdpi**/ic_stat_onesignal_default.png | MDPI | 24x24 |
| Assets/Plugins/Android/OneSignalConfig.androidlib/src/main/res/**drawable-hdpi**/ic_stat_onesignal_default.png | HDPI | 36x36 |
| Assets/Plugins/Android/OneSignalConfig.androidlib/src/main/res/**drawable-xhdpi**/ic_stat_onesignal_default.png | XHDPI | 48x48 |
| Assets/Plugins/Android/OneSignalConfig.androidlib/src/main/res/**drawable-xxhdpi**/ic_stat_onesignal_default.png | XXHDPI | 72x72 |
| Assets/Plugins/Android/OneSignalConfig.androidlib/src/main/res/**drawable-xxxhdpi**/ic_stat_onesignal_default.png | XXXHDPI | 96x96 |
| Assets/Plugins/Android/OneSignalConfig.androidlib/src/main/res/**drawable-xxxhdpi**/ic_onesignal_large_icon_default.png | XXXHDPI | 256x256 |
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
apply plugin: 'com.android.library'

android {
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
}
}

defaultConfig {
consumerProguardFiles "consumer-proguard.pro"
}

compileSdkVersion 31

lintOptions {
abortOnError false
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
-keep class com.onesignal.** { *; }

# Work around for IllegalStateException with kotlinx-coroutines-android
-keep class kotlinx.coroutines.android.AndroidDispatcherFactory {*;}

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ And via many additional platforms. [Check them all out](https://documentation.on
## Requirements
- A [OneSignal Account](https://app.onesignal.com/signup) if you do not already have one
- Your OneSignal App ID which you can find under **Settings > Keys & IDs**
- Unity 2018.4 or newer
- Unity 2021.3 or newer
- iOS Builds: CocoaPods 1.11.3 or newer
- In order to test push notifications you will need
- An Android 5 or newer device or emulator with "Google Play Store (Services)" installed
Expand Down Expand Up @@ -129,8 +129,8 @@ In the Unity editor:
Most of the Android setup was already handled during installation!
The only thing remaining is to setup your own notification icons. You can do this be replacing the example icons located at `Assets/Plugins/Android/OneSignalConfig.plugin`
with your own. There is a complete guide for this [in the plugin's README](com.onesignal.unity.android/Editor/OneSignalConfig.plugin/README.md). See our
The only thing remaining is to setup your own notification icons. You can do this be replacing the example icons located at `Assets/Plugins/Android/OneSignalConfig.androidlib`
with your own. There is a complete guide for this [in the plugin's README](com.onesignal.unity.android/Editor/OneSignalConfig.androidlib/README.md). See our
[Customize Notification Icons](https://documentation.onesignal.com/docs/customize-notification-icons) page for additional details.
## Usage
Expand Down
Loading

0 comments on commit 4fe1d74

Please sign in to comment.