Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7698849
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T22:20:21+00:00 2026-05-31T22:20:21+00:00

i know how to proguard android project,but at present i use android do a

  • 0

i know how to proguard android project,but at present i use android do a jar so that people can use my jar in the android app,but i want to my jar to proguard .i used proguard tool, my .pro file is:

-libraryjars 'D:\Android\android-sdk\platforms\android-7\android.jar'

-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
 -keep public abstract interface com.asqw.android.Listener{
 public protected <methods>; 
}

-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 *;
}
it give me succeed,but when i call the proguarded jar in my app,some class not found.

in my project:it give me :import com.ant.liao.GifView.GifImageType; canot found. my gifView file is :

 public class GifView extends ImageView implements GifAction{


private GifDecoder gifDecoder = null;

private Bitmap currentImage = null;

private boolean isRun = true;

private boolean pause = false;

private DrawThread drawThread = null;

private Context context = null;

private boolean cacheImage = false;

private View backView = null;

private GifImageType animationType = GifImageType.SYNC_DECODER;

public enum GifImageType{

    WAIT_FINISH (0),

    SYNC_DECODER (1),

    COVER (2);

    GifImageType(int i){
        nativeInt = i;
    }
    final int nativeInt;
}


public GifView(Context context) {
    super(context);
    this.context = context;
    //gifDecoder = new GifDecoder(this);
    setScaleType(ImageView.ScaleType.FIT_XY);
}

public GifView(Context context, AttributeSet attrs) {
    this(context, attrs,0);

}  

public GifView(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
    this.context = context;
   // TypedArray a = context.obtainStyledAttributes(attrs,R.array.);
    //gifDecoder = new GifDecoder(this);
    setScaleType(ImageView.ScaleType.FIT_XY);
}


 private void setGifDecoderImage(byte[] gif){

    if(gifDecoder == null){
        gifDecoder = new GifDecoder(this);
    }
    gifDecoder.setGifImage(gif);
    gifDecoder.start();
}


private void setGifDecoderImage(InputStream is){

    if(gifDecoder == null){
        gifDecoder = new GifDecoder(this);
    }
    gifDecoder.setGifImage(is);
    gifDecoder.start();


}


public void setAsBackground(View v){
    backView = v;
}

protected Parcelable onSaveInstanceState() {
    super.onSaveInstanceState();
    if(gifDecoder != null)
        gifDecoder.free();

    return null;
}

// public void setCahceImage(){
// if(gifDecoder == null){
// gifDecoder = new GifDecoder(this);
// }
// cacheImage = true;
// gifDecoder.setCacheImage(true, context);
// }

public void setGifImage(byte[] gif){
    setGifDecoderImage(gif);
}


public void setGifImage(InputStream is){
    setGifDecoderImage(is);
}


public void setGifImage(int resId){
    Resources r = getResources();
    InputStream is = r.openRawResource(resId);
    setGifDecoderImage(is);
}


public void destroy(){
    if(gifDecoder != null)
        gifDecoder.free();
}


public void showCover(){
    if(gifDecoder == null)
        return;
    pause = true;
    currentImage = gifDecoder.getImage();
    invalidate();
}


public void showAnimation(){
    if(pause){
        pause = false;
    }
}


public void setGifImageType(GifImageType type){
    if(gifDecoder == null)
        animationType = type;
}


 public void parseOk(boolean parseStatus,int frameIndex){
    if(parseStatus){
        if(gifDecoder != null){
            switch(animationType){
            case WAIT_FINISH:
                if(frameIndex == -1){
                    if(gifDecoder.getFrameCount() > 1){    
                        DrawThread dt = new DrawThread();
                        dt.start();
                    }else{
                        reDraw();
                    }
                }
                break;
            case COVER:
                if(frameIndex == 1){
                    currentImage = gifDecoder.getImage();
                    reDraw();
                }else if(frameIndex == -1){
                    if(gifDecoder.getFrameCount() > 1){
                        if(drawThread == null){
                            drawThread = new DrawThread();
                            drawThread.start();
                        }
                    }else{
                        reDraw();
                    }
                }
                break;
            case SYNC_DECODER:
                if(frameIndex == 1){
                    currentImage = gifDecoder.getImage();
                    reDraw();
                }else if(frameIndex == -1){
                    reDraw();
                }else{
                    if(drawThread == null){
                        drawThread = new DrawThread();
                        drawThread.start();
                    }
                }
                break;
            }

        }else{
            Log.e("gif","parse error");
        }

    }
}

private void reDraw(){
    if(redrawHandler != null){
        Message msg = redrawHandler.obtainMessage();
        redrawHandler.sendMessage(msg);
    }

}

private void drawImage(){
    setImageBitmap(currentImage);
    invalidate();
}

private Handler redrawHandler = new Handler(){
    public void handleMessage(Message msg) {
        try{
            if(backView != null){
                backView.setBackgroundDrawable(new BitmapDrawable(currentImage));
            }else{
                drawImage();
            }
        }catch(Exception ex){
            Log.e("GifView", ex.toString());
        }
    }
};

  private class DrawThread extends Thread{  
    public void run(){
        if(gifDecoder == null){
            return;
        }
        while(isRun){
            if(gifDecoder.getFrameCount() == 1){

                GifFrame f = gifDecoder.next();
                currentImage = f.image;
                gifDecoder.free();
                reDraw();

                break;
            }
            if (pause == false) {
                GifFrame frame = gifDecoder.next();

                if (frame == null) {
                    SystemClock.sleep(50);
                    continue;
                }
                if (frame.image != null)
                    currentImage = frame.image;
                else if (frame.imageName != null) {
                    currentImage = BitmapFactory.decodeFile(frame.imageName);
                }
                long sp = frame.delay;
                if (redrawHandler != null) {
                    reDraw();
                    SystemClock.sleep(sp);
                } else {
                    break;
                }
            } else {
                SystemClock.sleep(50);
            }
        }
    }
}

}
when i using proguard tool to proguard the files,gf2.setGifImage(R.drawable.a2);
gf2.setGifImageType(GifImageType.COVER);gf1.showCover() and so on ,all the public method not called from the jar

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T22:20:22+00:00Added an answer on May 31, 2026 at 10:20 pm

    add the following to your proguard.config. I think it will help preserving the the enum:

    -keep public enum com.ant.liao.GifView.GifImageType$** {
        **[] $VALUES;
        public *;
    }
    

    or bypass the class which defines enum:

    -keep class com.ant.liao.GifView { *; }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know that I can do something like $int = (int)99; //(int) has a
I know that design patterns is generally something that's connected to OO programming, but
I know regex and substrings is a common question on here but i can
We know in SDK 2.3 we can obfuscate APK with Proguard. The question is:
I know that there's something fishy about the malloc part, but I'm having trouble
I'm experimenting with proguard now that it's easier to use from within eclipse. I've
I know that this may be common knowledge, but is there a way to
I've been trying to see ProGuard in action with my test Android app. Do
I know we can trigger an Intent.ACTION_SEND intent to send email. But according to
I am having the following error on proguard.cfg file in my android project. I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.