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

Using latest Dex2Jar : Seeing this failure " Failed resolution of: Lres/Hex " #18

Open
vramasam opened this issue Mar 1, 2022 · 17 comments
Labels
bug Something isn't working

Comments

@vramasam
Copy link

vramasam commented Mar 1, 2022

Hello @ThexXTURBOXx

When we try to use https://mvnrepository.com/artifact/com.squareup.okhttp3/okhttp/4.9.3 in the apk. It results in following error.

Process: com.sampleapp, PID: 13211
java.lang.NoClassDefFoundError: Failed resolution of: Lres/Hex;
at okhttp3.internal.http2.Huffman.$d2j$hex$c61541e3$decode_I(Unknown Source:16)
at okhttp3.internal.http2.Huffman.(Unknown Source:17)
at okhttp3.internal.http2.Hpack$Writer.writeByteString(Unknown Source:11)
at okhttp3.internal.http2.Hpack$Writer.writeHeaders(Unknown Source:264)
at okhttp3.internal.http2.Http2Writer.headers(Unknown Source:12)
at okhttp3.internal.http2.Http2Connection.newStream(Unknown Source:82)
at okhttp3.internal.http2.Http2Connection.newStream(Unknown Source:6)
at okhttp3.internal.http2.Http2ExchangeCodec.writeRequestHeaders(Unknown Source:25)
at okhttp3.internal.connection.Exchange.writeRequestHeaders(Unknown Source:16)
at okhttp3.internal.http.CallServerInterceptor.intercept(Unknown Source:29)
at okhttp3.internal.http.RealInterceptorChain.proceed(Unknown Source:80)
at okhttp3.internal.connection.ConnectInterceptor.intercept(Unknown Source:32)
at okhttp3.internal.http.RealInterceptorChain.proceed(Unknown Source:80)
at okhttp3.internal.cache.CacheInterceptor.intercept(Unknown Source:192)
at okhttp3.internal.http.RealInterceptorChain.proceed(Unknown Source:80)
at okhttp3.internal.http.BridgeInterceptor.intercept(Unknown Source:171)
at okhttp3.internal.http.RealInterceptorChain.proceed(Unknown Source:80)
at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(Unknown Source:37)
at okhttp3.internal.http.RealInterceptorChain.proceed(Unknown Source:80)
at okhttp3.internal.connection.RealCall.getResponseWithInterceptorChain$okhttp(Unknown Source:119)
at okhttp3.internal.connection.RealCall.execute(Unknown Source:27)

How we are calling the OkHttpClient from code: The problem is with 4.x.x http library

private static final String URL_STRING = "https://www.google.com/";
private void okHttpLib()
{
try {
new Thread(new Runnable()
{
@OverRide
public void run()
{
try {
OkHttpClient client = new OkHttpClient();
Request request = new Request.Builder()
.url(URL_STRING)
.build();
Response response = client.newCall(request).execute();
Log.i(LOG_TAG, "OK HTTP, " + URL_STRING + ", status code: " + response.code());
response.body().string();
}
catch (Exception e) {
Log.e(LOG_TAG, "Exception while making okhttp call");
}
}
}).start();
}
catch (Exception e) {
Log.e(LOG_TAG, "Exception", e);
}
}

Can you please check this issue?

@vramasam vramasam changed the title Using latest OkHttp library 4.9.1 - Kotlin library gives problem Using latest Dex2Jar : Seeing this failure " Failed resolution of: Lres/Hex " Mar 20, 2022
@vramasam
Copy link
Author

Not seeing this exception specific to okHttp library. Observed the same issue in another apk.
Process: com.hdfc.techapp, PID: 9828
java.lang.NoClassDefFoundError: Failed resolution of: Lres/Hex;
at androidx.appcompat.R$styleable.$d2j$hex$b9a46b2b$decode_I(Unknown Source:16)
at androidx.appcompat.R$styleable.(Unknown Source:115)
at androidx.appcompat.app.AppCompatDelegateImpl.createView(Unknown Source:8)
at

Tried the same with the old version of Dex2Jar there this issue is not happening. Can you please look into it?

@ThexXTURBOXx
Copy link
Owner

Hello, sorry for not responding for quite some time. I needed to finish some work for University and academic purposes.
What exactly are you trying to do? It seems like you are trying to disassemble a dex file into a jar and reassembling it into Dalvik and then trying to run the apk/dex file on an Android phone. Is that correct?

I searched for the res/Hex file everywhere, but no matter what, I can't find it. Even if you run jadx on an APK file with okhttp included, there is no res/Hex class file.

@vramasam
Copy link
Author

vramasam commented Mar 29, 2022

@ThexXTURBOXx No problem. Thank you for the response back.

Yes your understanding is correct, we are disassemble the dex file in to jar and then reassembling the Dalvik .

Here as you said this file "res/Hex" is not available in the final apk.
We tried including the "dex-translator/src/test/java/res/Hex.java" in the final dex file, then this error is not coming. or We have to change IR2JConverter MAX_FILL_ARRAY_BYTES to Integer.MAX

Ideally my understanding, in this class dex-translator/src/main/java/com/googlecode/d2j/dex/Dex2Asm.java addHexDecodeMethod suppose to do that. But it didn't happen. I may be wrong here, I thought it will give you idea where to look out. Sorry If I am wrong here.

We also observed this is not happening with Dex2Jar first version for the same apk. It's happening because of the changes done with Dex2Jar latest changes.

@ThexXTURBOXx
Copy link
Owner

@vramasam Thanks for additional information. Please try out v47 where I believe I have fixed this issue :)

@ThexXTURBOXx
Copy link
Owner

ThexXTURBOXx commented Mar 29, 2022

For future reference:
Introduced bug in: 62eba63
Fixed in: 0e26919 (additional fix in 8496704)

@vramasam
Copy link
Author

@vramasam Thanks for additional information. Please try out v47 where I believe I have fixed this issue :)

Sure. Thank you. Will test and update the results here.

@ThexXTURBOXx
Copy link
Owner

@vramasam Do you have any news on this or are there still any errors occurring regarding this?

@vramasam
Copy link
Author

vramasam commented Apr 1, 2022

Hello @ThexXTURBOXx

We observed below exception:
2022-03-31 16:17:48.090 20215-20215/? E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.hdfc.techapp, PID: 20215
java.lang.NoSuchMethodError: No static method decode_B(Ljava/lang/String;)[B in class Landroidx/appcompat/R$styleable; or its super classes (declaration of 'androidx.appcompat.R$styleable' appears in /data/app/~~aQ9x9aGc8JPDrjAM226nIA==/com.xxx.xxxx-qkeGzcHRj9s7g-NO1EajHw==/base.apk)
at androidx.appcompat.R$styleable.$d2j$hex$497c133b$decode_I(Unknown Source:22)
at androidx.appcompat.R$styleable.(Unknown Source:115)
at androidx.appcompat.app.AppCompatDelegateImpl.createView(Unknown Source:8)

@ThexXTURBOXx
Copy link
Owner

Ah I see! I forgot one small thing. Give me a second :)

@ThexXTURBOXx
Copy link
Owner

Try again using version v48. Now, the method name should also be properly changed.

@vramasam
Copy link
Author

vramasam commented Apr 1, 2022

Okay @ThexXTURBOXx . Thank you. Will test and let you know

@ThexXTURBOXx
Copy link
Owner

@vramasam Any news on this? :)

@vramasam
Copy link
Author

vramasam commented Apr 7, 2022

Hello @ThexXTURBOXx

Sorry for the delay response. The above error got resolved. We are seeing the following exception.

2022-04-07 12:30:05.898 21597-21597/? E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.xx.xxxx, PID: 21597
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.xxx.techapp/com.xxxx.xxxx.MainActivity}: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3763)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3939)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:85)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2278)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:246)
at android.app.ActivityThread.main(ActivityThread.java:8429)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:596)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1130)
Caused by: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.
at androidx.appcompat.app.AppCompatDelegateImpl.createSubDecor(Unknown Source:438)
at androidx.appcompat.app.AppCompatDelegateImpl.ensureSubDecor(Unknown Source:5)
at androidx.appcompat.app.AppCompatDelegateImpl.setContentView(Unknown Source:0)
at androidx.appcompat.app.AppCompatActivity.setContentView(Unknown Source:7)

@ThexXTURBOXx
Copy link
Owner

Thanks for your feedback! Nice to hear that this issue has been resolved.
I will take a look at the new issue as soon as possible

@vramasam
Copy link
Author

Thank you @ThexXTURBOXx .

If you have any further updates on the ticket, please let us know.

@ThexXTURBOXx
Copy link
Owner

Yes, I will! I think the main problem is that dex2jar is not the right tool for a complete, 100% working disassembling and reassembling of dex files.
There will always be errors because of incompatibilities between both instruction sets.
Depending on what you want to achieve, it might be worth to take a look at dexlib2 or even multidexlib2 (from DexPatcher). They provide nice functionality for parsing and manipulating these files (if that is what you want to do).

@vramasam
Copy link
Author

Ohh okay. Thank you for the update and suggestion. Then this issue is not possible to be fixed ?

@ThexXTURBOXx ThexXTURBOXx added the bug Something isn't working label Sep 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants