OneSignal Push Notification Plugin, Initialization problem with proguard additions

Hello,

I am working on a plugin integrating OneSignal Push Notification service.

I notice that when i am adding proguard additions, the plugin is not getting initialized, during Application Packaging

The problem occurs when adding the commented out additions bellow:



-dontwarn com.onesignal.**
      -keep class com.google.android.gms.common.api.GoogleApiClient {
      void connect();
      void disconnect();
      }

      -keep public interface android.app.OnActivityPausedListener {*;}

      <!---keep class com.onesignal.shortcutbadger.impl.AdwHomeBadger { <init>(...); }
      -keep class com.onesignal.shortcutbadger.impl.ApexHomeBadger { <init>(...); }
      -keep class com.onesignal.shortcutbadger.impl.AsusHomeLauncher { <init>(...); }
      -keep class com.onesignal.shortcutbadger.impl.DefaultBadger { <init>(...); }
      -keep class com.onesignal.shortcutbadger.impl.HuaweiHomeBadger { <init>(...); }
      -keep class com.onesignal.shortcutbadger.impl.NewHtcHomeBadger { <init>(...); }
      -keep class com.onesignal.shortcutbadger.impl.NovaHomeBadger { <init>(...); }
      -keep class com.onesignal.shortcutbadger.impl.SolidHomeBadger { <init>(...); }
      -keep class com.onesignal.shortcutbadger.impl.SonyHomeBadger { <init>(...); }
      -keep class com.onesignal.shortcutbadger.impl.XiaomiHomeBadger { <init>(...); }-->


The conflict occurs with the commented out additions especially with the { <init>(…); } argument.
For example if i erase the <init> the plugin is initialized.

Any ideas what might causing this behavior?

If we add these additions at a ProguardAdditions.txt file to our project’s Build/Android directory, as it was possible since 4.10 version, will it work without problems?

When the pluging is ready i will uploaded to Pandora Entertainment · GitHub and update this thread with configuration instructions:
https://forums.unrealengine.com/showthread.php?127487-FREE-AdColony-AppLovin-Chartboost-UnityAds-Vungle-Sharing-OneSignal-Facebook-Everyplay

Proguard is such a trouble maker I’m not surprised you are running into issues. To determine the root of the issue you would have to share what the output from proguard is telling you. Copy that info and past it back in this thread. At a cursory glance it looks like “<init>” declarations might cause issues since angled brackets are reserved characters in XML. What you can do is wrap your proguard additions section in a CDATA declaration that has worked for me.

Hello robertfsegal,

When you stated the plugin about chartboost was really helpful to see how to handle delegates with blueprints.

I still remember the erros regarding AndroidJNI.h file or jni.h…

Now regarding OneSignal, i don’t get the message
UATHelper: Packaging (Android (ETC1)): UnrealBuildTool: UPL Init: armeabi-v7a
UATHelper: Packaging (Android (ETC1)): UnrealBuildTool: OneSignal init <---- Not initializing

during the packaging.

So if i use: -keep class com.onesignal.shortcutbadger.impl.ApexHomeBadger { <![CDATA[<init>]]>(…); } it should work?

Give it a try and see. I’m still not clear on what the error you are encountering is.

Are you using proguardAdditions section in UnrealPluginLanguage (formerly APL) for adding to proguard? If so, you need to be aware that <init> will be treated as XML. Use <init> instead.

Hello Chris,

Yes i am using UPL. I used instead of <init>, <init> and seems to work. <![CDATA[<init>]]> seems to work too as suggested earlier.

One other question, i am trying to add a permission like this one:

<permission android:name=“${manifestApplicationId}.permission.C2D_MESSAGE”
android:protectionLevel=“signature” />
<uses-permission android:name=“${manifestApplicationId}.permission.C2D_MESSAGE” />

where ${manifestApplicationId} is the package name.

Adding a ManifestRequirementsAdditions.txt file at Build/Android/, which include the above additions, seems to add them properly at the generated …\Intermediate\Android\APK\AndroidManifest.

Is there a way to add it with UPL?

Yes, you can do that like this in the androidManifestUpdates section:


    <setStringFromAttribute result="packageName" tag="manifest" name="package"/>

    <setElement result="c2dPermission" value="permission"/>
    <addAttribute tag="$c2dPermission" name="android:name" value="$S(packageName).permission.C2D_MESSAGE"/>
    <addAttribute tag="$c2dPermission" name="android:protectionLevel" value="signature"/>
    <addElement tag="manifest" name="c2dPermission"/>

    <setElement result="c2dUses" value="uses-permission"/>
    <addAttribute tag="$c2dUses" name="android:name" value="$S(packageName).permission.C2D_MESSAGE"/>
    <addElement tag="manifest" name="c2dUses"/>