Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NoClassDefFoundError: Failed resolution of: Lorg/apache/logging/log4j/LogManager #326

Closed
FutureHere opened this issue Mar 24, 2023 · 7 comments

Comments

@FutureHere
Copy link

FutureHere commented Mar 24, 2023

After upgrade Proguard version 6.0.3 to 7.3.0
apk crash
image

mapping:

proguard.optimize.gson._GsonUtil -> b.a.a.a:
{"fileName":"_GsonUtil.java","id":"sourceFile"}
org.apache.logging.log4j.Logger logger -> a
43:43:void () ->
63:75:com.google.gson.TypeAdapter getTypeAdapter(com.google.gson.Gson,java.lang.Class,java.lang.Object) -> a
95:108:com.google.gson.TypeAdapter getTypeAdapter(com.google.gson.Gson,com.google.gson.reflect.TypeToken,java.lang.Object) -> a
116:120:java.lang.reflect.Type getRuntimeTypeIfMoreSpecific(java.lang.reflect.Type,java.lang.Object) -> a
131:131:boolean isCustomTypeAdapter(com.google.gson.TypeAdapter) -> a
45:45:void () ->

I think the reason is Gson optimization

can u help me ? Thanks

@FutureHere
Copy link
Author

image

@mrjameshamilton
Copy link
Collaborator

Hi @FutureHere !

Can you try to narrow down the issue by disabling ProGuard features and/or adding keep rules?

For example: you can disable GSON optimization with -optimizations !library/gson (see https://www.guardsquare.com/manual/configuration/optimizations)

You can also try disabling obfuscation, optimization and shrinking generally to see if one of those are causing the problem: -dontshrink, -dontobfuscate, -dontoptimize

You can also try adding keep rules for the missing class.

If you cannot solve the issue via configuration, can you provide a reproducible sample?

@FutureHere
Copy link
Author

Hi @FutureHere !

Can you try to narrow down the issue by disabling ProGuard features and/or adding keep rules?

For example: you can disable GSON optimization with -optimizations !library/gson (see https://www.guardsquare.com/manual/configuration/optimizations)

You can also try disabling obfuscation, optimization and shrinking generally to see if one of those are causing the problem: -dontshrink, -dontobfuscate, -dontoptimize

You can also try adding keep rules for the missing class.

If you cannot solve the issue via configuration, can you provide a reproducible sample?

How can i use proguard without log4j ?
i find the problem proguard dependent org.apache.logging.log4j and change the app code In proguard process
but my application not dependent log4j, so the crash that Noclassdefound log4j happened.

we cant dependent log4j in our app ,so How can i use proguard without log4j ? Whether it can be set?

1 similar comment
@FutureHere
Copy link
Author

Hi @FutureHere !

Can you try to narrow down the issue by disabling ProGuard features and/or adding keep rules?

For example: you can disable GSON optimization with -optimizations !library/gson (see https://www.guardsquare.com/manual/configuration/optimizations)

You can also try disabling obfuscation, optimization and shrinking generally to see if one of those are causing the problem: -dontshrink, -dontobfuscate, -dontoptimize

You can also try adding keep rules for the missing class.

If you cannot solve the issue via configuration, can you provide a reproducible sample?

How can i use proguard without log4j ?
i find the problem proguard dependent org.apache.logging.log4j and change the app code In proguard process
but my application not dependent log4j, so the crash that Noclassdefound log4j happened.

we cant dependent log4j in our app ,so How can i use proguard without log4j ? Whether it can be set?

@FutureHere
Copy link
Author

image

-optimizations !library/gson

@FutureHere
Copy link
Author

addConfigurationDebugging?

@mrjameshamilton
Copy link
Collaborator

Thanks for the extra information! It looks like log4j loggers were accidentally added to code that is injected into the app for GSON optimization and configuration debugging. Should be solved by #328

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants