Android app can not use HttpClient After Android proguard - android

When my android app proguard, My app try to connect to https server, the connection be refused.I don't know why.So i package an apk without proguard and do the same test, the app run normally and connected the https server successfully. This is my proguard config:
-optimizationpasses 5` `
-dontusemixedcaseclassnames ` `
-dontskipnonpubliclibraryclasses` `
-dontpreverifyenter` `
-verbose` `
-optimizations !code/simplification/arithmetic,!field/*,!class/merging/*` `
-ignorewarnings` `
-libraryjars libs/android-support-v4.jar` `
-libraryjars libs/universal-image-loader-1.9.3.jar` `
-libraryjars libs/libqblueota v0.96.jar` `
-libraryjars libs/zxing.jar` `
-keep class com.zxing.** {*; }` `
-keep class android.support.** {*;}` `
-keep class org.apache.** {*;}` `
-keep class com.nostra13.universalimageloader.** {*;}` `
-keep class com.google.zxing.** {*;}` `
-keep class android.** {*; }` `
-keep class com.sengled.cloud.service.** {*;}` `
-keep public class * extends android.app.Activity` `
-keep public class * extends android.app.Application` `
-keep public class * extends android.app.Service` `
-keep public class * extends android.content.BroadcastReceiver` `
-keep public class * extends android.content.ContentProvider
-keep public class * extends android.app.backup.BackupAgentHelper
-keep public class * extends android.preference.Preference
-keep public class com.android.vending.licensing.ILicensingService
-keepclasseswithmembernames class * {native <methods>;}
-keepclasseswithmembers class * {
public <init>(android.content.Context, android.util.AttributeSet);
}
-keepclasseswithmembers class * {
public <init>(android.content.Context, android.util.AttributeSet, int);
}
-keepclassmembers class * extends android.app.Activity {
public void *(android.view.View);
}
-keepclassmembers enum * {
public static **[] values();
public static ** valueOf(java.lang.String);
}
-keep class * implements android.os.Parcelable {
public static final android.os.Parcelable$Creator *;
}

Related

Proguard returned with error code 1. See console Error: Unknown option '(' in argument number 12

While exporting my Android Application from Eclipse IDE, I am getting errors as below:
[2016-02-27 11:15:34 - Zip_Screen_Lock] Proguard returned with error code 1. See console
[2016-02-27 11:15:34 - Zip_Screen_Lock] Error: Unknown option '(' in argument number 12
Androidmanifest.xml
<receiver
android:name="com.homeapps.screenlock.zipper.BootCompleteReceiver"
android:enabled="true"
android:exported="true" >
<intent-filter android:priority="100" >
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
</receiver>
bin - proguard.txt
# view AndroidManifest.xml #generated:48
-keep class com.google.android.gms.ads.AdActivity { <init>(...); }
# view res/layout/screen_lock.xml #generated:58
# view res/layout/setting.xml #generated:25
-keep class com.google.android.gms.ads.AdView { <init>(...); }
# view AndroidManifest.xml #generated:66
-keep class com.homeapps.screenlock.zipper.BootCompleteReceiver { <init>(...); }
# view AndroidManifest.xml #generated:63
-keep class com.homeapps.screenlock.zipper.LockScreenService { <init>(...); }
# view AndroidManifest.xml #generated:44
-keep class com.homeapps.screenlock.zipper.ScreenLockActivity { <init>(...); }
# view AndroidManifest.xml #generated:34
-keep class com.homeapps.screenlock.zipper.Setting { <init>(...); }
# view AndroidManifest.xml #generated:54
-keep class com.startapp.android.publish.AppWallActivity { <init>(...); }
# view AndroidManifest.xml #generated:51
-keep class com.startapp.android.publish.list3d.List3DActivity { <init>(...); }
proguard.cfg
# Android application template
# Remove all the injar/outjar/libraryjar junk, the android ant script takes care of this
-dontpreverify
-repackageclasses ''
-allowaccessmodification
-optimizations !code/simplification/arithmetic
-keepattributes *Annotation*
-dontwarn
-keep public class * extends android.app.Activity
-keep public class * extends android.app.Application
-keep public class * extends android.app.Service
-keep public class * extends android.content.BroadcastReceiver
-keep public class * extends android.content.ContentProvider
-keep public class * extends android.view.View {
public <init>(android.content.Context);
public <init>(android.content.Context, android.util.AttributeSet);
public <init>(android.content.Context, android.util.AttributeSet, int);
public void set*(...);
}
-keepclasseswithmembers class * {
public <init>(android.content.Context, android.util.AttributeSet);
}
-keepclasseswithmembers class * {
public <init>(android.content.Context, android.util.AttributeSet, int);
}
-keepclassmembers class * implements android.os.Parcelable {
static android.os.Parcelable$Creator CREATOR;
}
-keepclassmembers class **.R$* {
public static <fields>;
}
# Keep fragments
-keep public class * extends android.support.v4.app.Fragment
-keep public class * extends android.app.Fragment
# Serializables
-keepnames class * implements java.io.Serializable
-keepclassmembers class * implements java.io.Serializable {
static final long serialVersionUID;
private static final java.io.ObjectStreamField[] serialPersistentFields;
!static !transient <fields>;
!private <fields>;
!private <methods>;
private void writeObject(java.io.ObjectOutputStream);
private void readObject(java.io.ObjectInputStream);
java.lang.Object writeReplace();
java.lang.Object readResolve();
}
# Native Methods
-keepclasseswithmembernames class * {
native <methods>;
}
# Android Support Library
-keep class android.** {*;}
# Button methods
-keepclassmembers class * {
public void *ButtonClicked(android.view.View);
}
# Reflection
# Remove Logging
-assumenosideeffects class android.util.Log {
public static *** e(...);
public static *** w(...);
public static *** wtf(...);
public static *** d(...);
public static *** v(...);
}
I have added dontwarn and dontnote statements to proguard confing file with that I resolved few warnings but Not able to solve remaining issue.Please help me to solve this.Thanks you.

Obfuscate the folder structure - Android

I am developing a android application. I obfuscates the code of the project using progaurd. I want to obfuscate the folder structure as well. anyway to do that ?
Thanks for your help
ProGuard contains various directives, for your ProGuard rules file, that can obfuscate package names, such as -flattenpackagehierarchy and -repackageclasses. Just make sure that anything referenced from AndroidManifest.xml or otherwise accessed via reflection is kept intact.
It is conceivable that the commercial, Android-tuned DexGuard tool can even let you repackage stuff in the manifest (by modifying the manifest entries as part of the obfuscation process), but I do not know if it does or not.
copy and paste this code in proguard.cfg:
-dontusemixedcaseclassnames
-dontskipnonpubliclibraryclasses
-verbose
-dontoptimize
-dontpreverify
-keepattributes *Annotation*
-keep public class * extends android.app.Activity
-keep public class * extends android.app.Application
-keep public class * extends android.app.Service
-keep public class * extends android.content.BroadcastReceiver
-keep public class * extends android.content.ContentProvider
-keep public class * extends android.app.backup.BackupAgent
-keep public class * extends android.preference.Preference
-keep public class * extends android.support.v4.app.Fragment
-keep public class * extends android.support.v7.app.ActionBarActivity
-keep public class * extends android.app.Fragment
-keep public class com.android.vending.licensing.ILicensingService
-keepclasseswithmembernames class * {
native <methods>;
}
-keep public class * extends android.view.View {
public <init>(android.content.Context);
public <init>(android.content.Context, android.util.AttributeSet);
public <init>(android.content.Context, android.util.AttributeSet, int);
public void set*(...);
}
-keepclasseswithmembers class * {
public <init>(android.content.Context, android.util.AttributeSet);
}
-keepclasseswithmembers class * {
public <init>(android.content.Context, android.util.AttributeSet, int);
}
-keepclassmembers class * extends android.app.Activity {
public void *(android.view.View);
}
-keepclassmembers enum * {
public static **[] values();
public static ** valueOf(java.lang.String);
}
-keep class * implements android.os.Parcelable {
public static final android.os.Parcelable$Creator *;
}
-keepclassmembers class **.R$* {
public static <fields>;
}
-dontwarn android.support.**

Proguard and Android

I try to add com.radaee.pdfex_view.jar to proguard. I added this code
-keepclasseswithmembernames class * {
native <methods>;
}
-keep public class com.radaee.* {
public static *;
public static *;
private static *;
}
-keep public class com.radaee.**
to my project.properties.txt, but when I go to my pdf the app closes.
Try
-keep class com.radaee.** {*;}

Proguard does not obfuscate gui components

I would like to use ProGuard to obfuscate my Android app. This works fine. But my gui classes, which extends acitvity, view and sherlockactivity are not obfuscated. Here is the proguard.cfg
-injars bin/classes
-injars libs
-outjars bin/classes-processed.jar
-libraryjars C:/Users/android-sdks/platforms/android-17/android.jar
-dontpreverify
-dontoptimize
-repackageclasses ''
-allowaccessmodification
-optimizationpasses 5
-optimizations !code/simplification/arithmetic,!field/*,!class/merging/*
-keepattributes *Annotation*
-dontwarn sun.misc.Unsafe
-dontwarn com.actionbarsherlock.**
-dontwarn com.google.common.**
-keep class android.support.v4.app.** { *; }
-keep interface android.support.v4.app.** { *; }
-keep class com.actionbarsherlock.** { *; }
-keep interface com.actionbarsherlock.** { *; }
-keep public class * extends android.app.Activity
-keep public class * extends android.app.Application
-keep public class * extends android.app.Service
-keep public class * extends android.content.BroadcastReceiver
-keep public class * extends android.content.ContentProvider
-keep public class * extends android.view.View
-keep public class * extends android.view.ViewGroup
-keep public class * extends android.support.v4.app.Fragment
-keepclassmembers class * extends android.app.Activity {
public void *(android.view.View);
}
-keepclassmembers class android.support.v4.app.Fragment {
*** getActivity();
public *** onCreate();
public *** onCreateOptionsMenu(...);
}
-keepclassmembers class * extends com.actionbarsherlock.ActionBarSherlock {
public <init>(...);
}
-keepclasseswithmembers class * {
public <init>(android.content.Context, android.util.AttributeSet);
}
-keepclasseswithmembers class * {
public <init>(android.content.Context, android.util.AttributeSet, int);
}
-keep public class * extends android.view.View {
public <init>(android.content.Context);
public <init>(android.content.Context, android.util.AttributeSet);
public <init>(android.content.Context, android.util.AttributeSet, int);
public void set*(...);
}
-keepclassmembers class * implements android.os.Parcelable {
static android.os.Parcelable$Creator CREATOR;
}
-keepclassmembers class **.R$* {
public static <fields>;
}
-keepclassmembers class com.brainyoo.brainyoo2android.ui.html.BYJavaScriptInterface {
public *;
}
First, I thought activities can´t be obfuscated because of the reflection call
myactivity.class
I've tried to add:
- keep public class mypackege.myactivity.class
But it does not solve the problem. Any ideas how to obfuscate the gui elements?
Thanks
Christine
But my gui classes, which extends acitvit, view and sherlockactivtiy are not obfusecated.
That is because your ProGuard configuration file says to not obfuscate them. Moreover, this is important, as if they are obfuscated, your app will not run, because:
Android will not find your renamed activities
Android will not find your activity lifecycle methods
Android will not find your widgets (for use with reflection in interpreting layout resources)
etc.
I´ve tried to added: -keep public class mypackege.myactivity.class But it does not solve the problem.
That is because you are telling ProGuard to not obfuscate that class.
Any ideas how to obfusecate the gui elements?
You don't, if you wish to have a working app when you are done.

corrupting apk after proguard obfuscation

I try to use proguard android tools. But obfuscated apk is not installed (i use eclipse export wizard). dex2jar show me that all classes were in jar but named with *.dump.txt and contains something like this:
//class:0002 access:0x0011
public final class com.company.android.BuildConfig
//field:0000 access:0x0019
//Lcom/company/android/BuildConfig;.DEBUG Z
public static final Z DEBUG=true;
//method:0000 access:0x10001
//Lcom/company/android/BuildConfig;.<init>()V
public V <init>()
this:v0 //com.company.android.BuildConfig
LOCAL_VARIABLE LL0 ~ LL1 v0 -> this // Lcom/company/android/BuildConfig;
LABEL | LL0: line 4
INVOKE_DIRECT | |v0.<init>() //Ljava/lang/Object;.<init>()V
RETURN_VOID | |return
LABEL | LL1:
Where i'm wrong? How can i make working obfuscating apk?
My proguard.cfg:
-optimizationpasses 5
-dontusemixedcaseclassnames
-dontskipnonpubliclibraryclasses
-dontpreverify
-verbose
-optimizations !code/simplification/arithmetic,!field/*,!class/merging/*
-keep public class * extends android.app.Activity
-keep public class * extends android.app.Application
-keep public class * extends android.app.Service
-keep public class * extends android.content.BroadcastReceiver
-keep public class * extends android.content.ContentProvider
-keep public class * extends android.app.backup.BackupAgentHelper
-keep public class * extends android.preference.Preference
-keep public class com.android.vending.licensing.ILicensingService
-keepclasseswithmembernames class * {
native <methods>;
}
-keepclasseswithmembers class * {
public <init>(android.content.Context, android.util.AttributeSet);
}
-keepclasseswithmembers class * {
public <init>(android.content.Context, android.util.AttributeSet, int);
}
-keepclassmembers class * extends android.app.Activity {
public void *(android.view.View);
}
-keepclassmembers enum * {
public static **[] values();
public static ** valueOf(java.lang.String);
}
-keep class * implements android.os.Parcelable {
public static final android.os.Parcelable$Creator *;
}
My project.properties:
target=android-8
proguard.config=proguard.cfg
Thanks!

Categories

Resources