3

After adding an Android Certificate in my project, the Codename One server started getting issues to build, then by asking the Codename One support, they told me it could be something related to the Proguard, so after disabling the Proguard by setting android.enableProguard=false which is not recommended right? So after doing it the Codename One server builds fine, but I want to keep the Proguard enable since it's the recommeded, but when I keep it enable the Codename One server gets build error with the following error log: https://s3.amazonaws.com/codenameone-build-response/d5f3c0c7-71a3-4a17-9f19-1c4e8fb3903d-1523988845519-error.txt

In addition the only libraries I'm using are: cn1-codescan.cn1lib, CN1JSON.cn1lib and parse4cn1.cn1lib

Am I missing Proguard build hints? I'm using the following Proguard build hints:

android.proguardKeep=-keep class com.mypackage.ProblemClass { *; } -keep class android.support.v4.** { *; } -keep class android.support.v7.** { *; } -keep public class * extends android.app.Service -keep public class * extends android.content.BroadcastReceiver -keep public class * extends android.app.Activity -keep public class * extends android.preference.Preference -keep public class com.freshdesk.mobihelp.exception.MobihelpComponentNotFoundException -keepclassmembers class * implements android.os.Parcelable {   public static final android.os.Parcelable$Creator *; }
Simple
  • 827
  • 1
  • 9
  • 21

1 Answers1

2

You need to replace the word ProblemClass with the full path to the class that is causing the problem...

You wrote this:

android.proguardKeep=-keep class com.mypackage.ProblemClass { *; } -keep class android.support.v4.** { *; } -keep class android.support.v7.** { *; } -keep public class * extends android.app.Service -keep public class * extends android.content.BroadcastReceiver -keep public class * extends android.app.Activity -keep public class * extends android.preference.Preference -keep public class com.freshdesk.mobihelp.exception.MobihelpComponentNotFoundException -keepclassmembers class * implements android.os.Parcelable {   public static final android.os.Parcelable$Creator *; }

You should have written this for com.parse.ParseOkHttpClient :

android.proguardKeep=-keep class com.parse.ParseOkHttpClient { *; } -keep class android.support.v4.** { *; } -keep class android.support.v7.** { *; } -keep public class * extends android.app.Service -keep public class * extends android.content.BroadcastReceiver -keep public class * extends android.app.Activity -keep public class * extends android.preference.Preference -keep public class com.freshdesk.mobihelp.exception.MobihelpComponentNotFoundException -keepclassmembers class * implements android.os.Parcelable {   public static final android.os.Parcelable$Creator *; }
Shai Almog
  • 51,749
  • 5
  • 35
  • 65
  • Fixed it but the problem still there, new error log: https://s3.amazonaws.com/codenameone-build-response/0e646dad-561c-458f-bd9e-4aed91a085d4-1524063039391-error.txt – Simple Apr 18 '18 at 14:51
  • Try adding `-dontwarn okhttp3.**` to the keep statement – Shai Almog Apr 19 '18 at 04:31
  • Some warnings gone but there still some left over such as `can't find referenced class okio.Okio` and `can't find referenced class okio.BufferedSink` then I fixed it by adding as well `-dontwarn okio.**` so it's gone, but the problem still there, as well 2 warnings left over, error log: https://s3.amazonaws.com/codenameone-build-response/5bc752d5-fdfc-430f-8676-f06bff1e3733-1524149163229-error.txt I'm afraid of the build hint character limit, because I just have a few characters left to add in the build hint so if I have to add something extensive I'll reach the character limit. – Simple Apr 19 '18 at 14:53
  • Try replacing `-keep class com.parse.ParseOkHttpClient { *; }` with `-keep class com.parse.**` I don't think there is a character limit for build hints – Shai Almog Apr 20 '18 at 04:11
  • Nothing worked so far, I'm reporting a bug from `parse4cn1` do the test yourself, try to build a default project with the following libraries: `cn1-codescan.cn1lib`, `CN1JSON.cn1lib`, then add an Android Certificate to your project, CN1 server will build fine! However after adding this library: `parse4cn1.cn1lib`, it won't build anymore! Even if this is a default project with no modification. I'm pretty sure there is something wrong with `parse4cn1` with `Proguard`, consider this as a report. there is a character limit for build hint indeed, see it yourself. Waiting for a solution. – Simple Apr 20 '18 at 15:45
  • By the way here's the last error log, after replacing `-keep class com.parse.ParseOkHttpClient { *; }` with `-keep class com.parse.**` https://s3.amazonaws.com/codenameone-build-response/e7ac843c-66ce-4221-babb-dd7840b257ec-1524238440144-error.txt – Simple Apr 20 '18 at 15:49
  • Try changing it to `-keep class com.parse.*{ *; }` – Shai Almog Apr 21 '18 at 04:19
  • It didn't work, these warnings still there: `Warning: com.parse.NotificationCompat$NotificationCompatImplBase: can't find referenced method 'void setLatestEventInfo(android.content.Context,java.lang.CharSequence,java.lang.CharSequence,android.app.PendingIntent)' in library class android.app.Notification Warning: com.parse.ParseApacheHttpClient: can't find referenced method 'org.apache.http.conn.ssl.SSLSocketFactory getHttpSocketFactory(int,android.net.SSLSessionCache)' in library class android.net.SSLCertificateSocketFactory` – Simple Apr 21 '18 at 04:57
  • As you can see in this error log: https://s3.amazonaws.com/codenameone-build-response/1d214c79-fc12-43eb-8fae-b4482569080b-1524286793863-error.txt – Simple Apr 21 '18 at 04:57
  • Add `-dontwarn bolts.**` – Shai Almog Apr 22 '18 at 04:15
  • It didn't work, error log: https://s3.amazonaws.com/codenameone-build-response/1470285e-8db7-4b26-90a4-222ea604dc0c-1524451201527-error.txt Is there a real solution for that? Shouldn't you consider reporting this issue to your parse4cn1 maintainer? I mean I can't release my application because of this issue and I have a deadline so I can't wait for long it's been 4 days since started this topic. – Simple Apr 23 '18 at 02:35
  • He doesn't work for us. It's a 3rd party project. Didn't you ask him for help? – Shai Almog Apr 23 '18 at 03:12
  • Hi, I don't have much experience with Proguard and can't really help you with this issue. The warnings you posted above are coming from classes in the Parse SDK which parse4cn1 wraps around. That means if yii were to use the Parse SDK directly in an Android app, you'll mist likely face the same issued. Perhaps you can search for Proguard settings for Parse or consider a first release with Proguard disabled if that's an option? – netsuite_insights Apr 24 '18 at 16:29