Skip to content

Commit

Permalink
修改混淆后问题
Browse files Browse the repository at this point in the history
  • Loading branch information
wrp committed Jan 28, 2024
1 parent dbeeaa9 commit f9a564b
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 16 deletions.
8 changes: 4 additions & 4 deletions manager/app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -143,12 +143,12 @@ dependencies {
implementation ("io.reactivex.rxjava2:rxjava:2.1.8")
implementation ("com.squareup.retrofit2:retrofit:2.4.0")
implementation ("com.squareup.retrofit2:converter-gson:2.4.0")
implementation ("com.squareup.retrofit2:converter-scalars:2.4.0")
// implementation ("com.squareup.retrofit2:converter-scalars:2.4.0")
implementation ("com.squareup.retrofit2:adapter-rxjava2:2.4.0")
implementation ("com.squareup.okhttp3:logging-interceptor:4.9.0")
// implementation ("com.squareup.okhttp3:logging-interceptor:4.10.0")
implementation( "com.jakewharton.rxrelay2:rxrelay:2.1.0")
implementation ("com.squareup.okhttp3:okhttp:4.9.0")
implementation ("com.squareup.okhttp:okhttp-urlconnection:2.2.0")
// implementation ("com.squareup.okhttp3:okhttp:4.10.0")
// implementation ("com.squareup.okhttp:okhttp-urlconnection:2.2.0")

implementation ("org.greenrobot:eventbus:3.2.0")
implementation ("com.tencent.bugly:crashreport:latest.release")
Expand Down
47 changes: 44 additions & 3 deletions manager/app/proguard-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,48 @@
-dontwarn org.openjsse.javax.net.ssl.**
-dontwarn org.openjsse.net.ssl.**

# 保留androidx下的所有类及其内部类
#-keep class androidx.** {*;}
#-keep public class * extends androidx.**
#-keep interface androidx.** {*;}



## ---------Retrofit混淆方法---------------
-dontwarn javax.annotation.**
-dontwarn javax.inject.**
# OkHttp3
-dontwarn okhttp3.logging.**
-keep class okhttp3.internal.**{*;}
-keep class okhttp3.**{*;}
-keep class okhttp3.** { *; }
-dontwarn com.squareup.okhttp3.**
-keep class com.squareup.okhttp3.** { *;}

-dontwarn com.squareup.**
-dontwarn okio.**
-keep public class org.codehaus.* { *; }
-keep public class java.nio.* { *; }

# Retrofit
-dontwarn retrofit2.**
-keep class retrofit2.** { *; }
-keepattributes Signature, InnerClasses, EnclosingMethod
-keepattributes RuntimeVisibleAnnotations, RuntimeVisibleParameterAnnotations
-keepattributes AnnotationDefault
-keepclassmembers,allowshrinking,allowobfuscation interface * {
@retrofit2.http.* <methods>;
}
-dontwarn org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement
-dontwarn javax.annotation.**
-dontwarn kotlin.Unit
-dontwarn retrofit2.KotlinExtensions
-dontwarn retrofit2.KotlinExtensions$*
-if interface * { @retrofit2.http.* <methods>; }
-keep,allowobfuscation interface <1>
-if interface * { @retrofit2.http.* <methods>; }
-keep,allowobfuscation interface * extends <1>
-keep,allowobfuscation,allowshrinking class kotlin.coroutines.Continuation
-if interface * { @retrofit2.http.* public *** *(...); }
-keep,allowoptimization,allowshrinking,allowobfuscation class <3>

-keepattributes Signature
-keepattributes Exceptions
# RxJava RxAndroid
Expand All @@ -31,6 +63,7 @@
long producerIndex;
long consumerIndex;
}

-keepclassmembers class rx.internal.util.unsafe.BaseLinkedQueueProducerNodeRef {
rx.internal.util.atomic.LinkedQueueNode producerNode;
}
Expand All @@ -43,7 +76,13 @@
-keepattributes Signature
# RxJava2
-dontwarn io.reactivex.**
-keepclasseswithmembers class * {
@retrofit2.* <methods>;
}

-keepclasseswithmembers interface * {
@retrofit2.* <methods>;
}
# RxJava2: If you are using RxAndroid (e.g. AndroidSchedulers)
-dontwarn io.reactivex.android.**

Expand All @@ -56,9 +95,11 @@
# Gson
-keep class com.google.gson.stream.** { *; }
-keepattributes EnclosingMethod
-keep class com.google.gson.** { *; }

# Gson
-keep class me.weishu.kernelsu.bean.**{*;} # 自定义数据模型的bean目录
-keep class me.weishu.kernelsu.net.CommonService # 自定义数据模型的bean目录

#eventbus
-keepattributes *Annotation*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@

import me.weishu.kernelsu.net.interceptor.HttpUrlInterceptor;
import okhttp3.OkHttpClient;
import okhttp3.logging.HttpLoggingInterceptor;

import retrofit2.Retrofit;
import retrofit2.adapter.rxjava2.RxJava2CallAdapterFactory;
import retrofit2.converter.gson.GsonConverterFactory;
import retrofit2.converter.scalars.ScalarsConverterFactory;


/**
* @author: ji xin
Expand All @@ -30,8 +30,8 @@ public class BaseRetrofitManager {

private OkHttpClient getOkHttpClient() {

HttpLoggingInterceptor interceptor = new HttpLoggingInterceptor();
interceptor.setLevel(HttpLoggingInterceptor.Level.BODY);
// HttpLoggingInterceptor interceptor = new HttpLoggingInterceptor();
// interceptor.setLevel(HttpLoggingInterceptor.Level.BODY);

//
// File cacheFile = new File(BaseApplication.getContext().getCacheDir(), "cache");
Expand All @@ -42,7 +42,7 @@ private OkHttpClient getOkHttpClient() {
.connectTimeout(CONNECT_TIME_OUT, TimeUnit.SECONDS)
// .addInterceptor(interceptor)
.addInterceptor(new HttpUrlInterceptor())
.addNetworkInterceptor(interceptor)
// .addNetworkInterceptor(interceptor)
// .cache(cache)
.build();
return okHttpClient;
Expand All @@ -53,7 +53,7 @@ protected Retrofit getRetrofit() {
Gson gson = GsonUtils.createGson(true).setLenient().create();
retrofit = new Retrofit.Builder()
.client(getOkHttpClient())
.addConverterFactory(ScalarsConverterFactory.create())

.addConverterFactory(GsonConverterFactory.create(gson))
.addCallAdapterFactory(RxJava2CallAdapterFactory.create())
.baseUrl(BASE_URL)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,13 @@ public class CommonRetrofitManager extends BaseRetrofitManager {
private CommonService mCommonService;

public CommonRetrofitManager() {
//构造函数获取retrofit对象,并创建接口类的对象,拿到这个对象,可以调用具体的接口
mCommonService = getRetrofit().create(CommonService.class);
try{
//构造函数获取retrofit对象,并创建接口类的对象,拿到这个对象,可以调用具体的接口
mCommonService = getRetrofit().create(CommonService.class);
}catch (Exception e){
e.printStackTrace();
}

}

private static class SingletonHolder {
Expand Down
2 changes: 1 addition & 1 deletion manager/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ android.enableAppCompileTimeRClass=true
android.useAndroidX=true
#org.gradle.parallel=true
#org.gradle.vfs.watch=true
#org.gradle.jvmargs=-Xmx2048m
#org.gradle.jvmargs=-Xmx8096m
#android.native.buildOutput=verbose

0 comments on commit f9a564b

Please sign in to comment.