Open aatifansari opened 1 year ago
Hi @aatifansari
I suggest to exclude the duplicated libs. I don't know exactly your gradle dependencies, so the solution I suggest is something similar to this approach:
implementation('website.magyar:mitm-java-proxy:2.5.27.114') {
exclude(group: 'ch.qos.logback', module: 'logback-classic')
exclude(group: 'org.eclipse.jetty', module: 'jetty-io')
exclude(group: 'org.slf4j', module: 'jcl-over-slf4j')
exclude(group: 'org.slf4j', module: 'jul-to-slf4j')
}
Thanks @tkohegyi but when running the application it is giving error.. tried both
2023-06-30 16:22:59.017 18869-18869 System.err com.group.sample W java.lang.IllegalStateException: Must set port before starting 2023-06-30 16:22:59.018 18869-18869 System.err com.group.sample W at website.magyar.mitm.proxy.ProxyServer.start(ProxyServer.java:66) 2023-06-30 16:22:59.018 18869-18869 System.err com.group.sample W at com.group.sample.activity.TempActivity.onCreate(TempActivity.java:52) 2023-06-30 16:22:59.018 18869-18869 System.err com.group.sample W at android.app.Activity.performCreate(Activity.java:8305) 2023-06-30 16:22:59.018 18869-18869 System.err com.group.sample W at android.app.Activity.performCreate(Activity.java:8284) 2023-06-30 16:22:59.019 18869-18869 System.err com.group.sample W at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1417) 2023-06-30 16:22:59.019 18869-18869 System.err com.group.sample W at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3626) 2023-06-30 16:22:59.019 18869-18869 System.err com.group.sample W at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3782) 2023-06-30 16:22:59.019 18869-18869 System.err com.group.sample W at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:101) 2023-06-30 16:22:59.019 18869-18869 System.err com.group.sample W at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135) 2023-06-30 16:22:59.019 18869-18869 System.err com.group.sample W at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95) 2023-06-30 16:22:59.019 18869-18869 System.err com.group.sample W at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2307) 2023-06-30 16:22:59.019 18869-18869 System.err com.group.sample W at android.os.Handler.dispatchMessage(Handler.java:106) 2023-06-30 16:22:59.019 18869-18869 System.err com.group.sample W at android.os.Looper.loopOnce(Looper.java:201) 2023-06-30 16:22:59.019 18869-18869 System.err com.group.sample W at android.os.Looper.loop(Looper.java:288) 2023-06-30 16:22:59.019 18869-18869 System.err com.group.sample W at android.app.ActivityThread.main(ActivityThread.java:7872) 2023-06-30 16:22:59.019 18869-18869 System.err com.group.sample W at java.lang.reflect.Method.invoke(Native Method) 2023-06-30 16:22:59.019 18869-18869 System.err com.group.sample W at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548) 2023-06-30 16:22:59.019 18869-18869 System.err com.group.sample W at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:936)
Hi @aatifansari I cannot see your file TempActivity.java, but from the error message ("Must set port before starting") I guess you tried to run the proxy without specifying its port. So the problem is that the ProxyServer class created without specifying the port, and later the proxy has been started without specifying the port to be used.
Pls see and follow this guideline on how to start the proxy.
Hi @tkohegyi
Sorry was passing the port in start() method instead of ProxyServer(PORT_NUMBER) constructor.
But after that also getting error of INSTANCE static field
java.lang.NoSuchFieldError: No static field INSTANCE of type Lorg/apache/http/conn/ssl/AllowAllHostnameVerifier; in class Lorg/apache/http/conn/ssl/AllowAllHostnameVerifier; or its superclasses (declaration of 'org.apache.http.conn.ssl.AllowAllHostnameVerifier' appears in /system/framework/framework.jar!classes4.dex)
at org.apache.http.conn.ssl.SSLConnectionSocketFactory.
Hi @aatifansari - from the log: java.lang.NoSuchFieldError: No static field INSTANCE of type Lorg/apache/http/conn/ssl/AllowAllHostnameVerifier; in class Lorg/apache/http/conn/ssl/AllowAllHostnameVerifier; or its superclasses (declaration of 'org.apache.http.conn.ssl.AllowAllHostnameVerifier' appears in /system/framework/framework.jar!classes4.dex) at org.apache.http.conn.ssl.SSLConnectionSocketFactory.(SSLConnectionSocketFactory.java:151)
Three possible issues might be: case A - You are using an older version of the proxy - like this or even earlier version: https://github.com/tkohegyi/mitmJavaProxy/releases/tag/v2.0.21.100
In which, in the release notes, there is a note: It may happen that additional library need to be included in your build, like this way:
implementation group: 'org.apache.httpcomponents', name: 'httpmime', version:'4.5.13' //this includes httpclient too
implementation ('website.magyar:mitm-java-proxy:2.0.21.100')
AND not the specified version, but a newer version of the lib is used, in which this field is missing. If this is the case, please use exactly the mentioned version of the httpmime lib.
case B - You are using newer/latest verison, but overrides (or android overrules) the httpmime component version that is used during the build of the proxy jar. In this case check and please ensure that not newer than 4.5.14 version of the httpmme/httpclient lib is loaded during the build of your application.
case C - pls see the issue and the solution here: https://stackoverflow.com/questions/60423257/no-static-field-instance-of-type-lorg-apache-http-conn-ssl-allowallhostnameverif
In addition - if you can build your own jar from the latest source, maybe the issue will disappear too.
Hi @tkohegyi thanks for your recommendations
Case A - Lowered down the library version implementation group: 'org.apache.httpcomponents', name: 'httpmime', version:'4.5.13' implementation('website.magyar:mitm-java-proxy:2.0.21.100') { exclude(group: 'ch.qos.logback', module: 'logback-classic') exclude(group: 'org.eclipse.jetty', module: 'jetty-io') exclude(group: 'org.slf4j', module: 'jcl-over-slf4j') exclude(group: 'org.slf4j', module: 'jul-to-slf4j') }
Result - But still getting the same error [No static field INSTANCE of type Lorg/apache/http/conn/ssl/AllowAllHostnameVerifier]
case B - Using the latest library version but not able to verify which version of httpmme/httpclient is being loaded
case C - build the jar locally and then imported it. implementation files("libs/mitm-java-proxy-2.5.27.SNAPSHOT-all.jar")
Result - Getting warning during build process and error while running the app.
Build process warning - Note: Some input files use or override a deprecated API. Note: Recompile with -Xlint:deprecation for details.
Error -
java.lang.NoSuchMethodError: No virtual method getModule()Ljava/lang/Module; in class Ljava/lang/Class; or its super classes (declaration of 'java.lang.Class' appears in /apex/com.android.art/javalib/core-oj.jar)
at ch.qos.logback.core.util.EnvUtil.logbackVersionByModule(EnvUtil.java:56)
at ch.qos.logback.core.util.EnvUtil.logbackVersion(EnvUtil.java:36)
at ch.qos.logback.classic.util.ContextInitializer.autoConfig(ContextInitializer.java:81)
at ch.qos.logback.classic.util.ContextInitializer.autoConfig(ContextInitializer.java:77)
at ch.qos.logback.classic.spi.LogbackServiceProvider.initializeLoggerContext(LogbackServiceProvider.java:50)
at ch.qos.logback.classic.spi.LogbackServiceProvider.initialize(LogbackServiceProvider.java:41)
at org.slf4j.LoggerFactory.bind(LoggerFactory.java:183)
at org.slf4j.LoggerFactory.performInitialization(LoggerFactory.java:170)
at org.slf4j.LoggerFactory.getProvider(LoggerFactory.java:455)
at org.slf4j.LoggerFactory.getILoggerFactory(LoggerFactory.java:441)
at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:390)
at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:416)
at website.magyar.mitm.proxy.ProxyServer.
Note - I have also tried to run the application on Intellij and added a class to start the server it is successfully running there and was able to print the port number also.
Duplicate class org.apache.commons.logging.Log found in modules commons-logging-1.2 (commons-logging:commons-logging:1.2) and jcl-over-slf4j-2.0.6 (org.slf4j:jcl-over-slf4j:2.0.6) Duplicate class org.apache.commons.logging.LogConfigurationException found in modules commons-logging-1.2 (commons-logging:commons-logging:1.2) and jcl-over-slf4j-2.0.6 (org.slf4j:jcl-over-slf4j:2.0.6) Duplicate class org.apache.commons.logging.LogFactory found in modules commons-logging-1.2 (commons-logging:commons-logging:1.2) and jcl-over-slf4j-2.0.6 (org.slf4j:jcl-over-slf4j:2.0.6) Duplicate class org.apache.commons.logging.impl.NoOpLog found in modules commons-logging-1.2 (commons-logging:commons-logging:1.2) and jcl-over-slf4j-2.0.6 (org.slf4j:jcl-over-slf4j:2.0.6) Duplicate class org.apache.commons.logging.impl.SimpleLog found in modules commons-logging-1.2 (commons-logging:commons-logging:1.2) and jcl-over-slf4j-2.0.6 (org.slf4j:jcl-over-slf4j:2.0.6)