Obfuscation of programs, package and release the apk, and then test the apk with a real machine. It is found that all pages with network requests cannot display data and view logs, the following exceptions are found:
<喎?http: www.bkjia.com kf ware vc " target="_blank" class="keylink"> VcD4KPHA + zfjJz7Lpwcuy6Q = "Missing type parameter" what is the cause of this problem? You can see that this answer is because gson's new typeToken is used in the program. It should be because the classes related to typetoken are obfuscated in the obfuscation file, which makes the runtime program unrecognizable. View
At com a. a. c. a. a (Unknown Source) is a obfuscated and unrecognized class. For the sake of proof, the mapping.txt file generated after the download is used to find out which class of com a. a. c. a corresponds to the program class, such:
It can be determined that it is directed to com. google. gson. reflect. TypeToken
Then add this sentence to the example file proguard-android.txt (the txt I used on Android Studio0.3.7 obfuscated the program, and many previous projects were included in proguard. cfg:
-Keep class com. google. gson. ** {*;} indicates that the proguard operation is not performed on this class.
There are also many solutions available on the Internet, such as the following two
Android obfuscation compilation-problem summary and proguard Missing type parameter on stackoverflow
Add in proguard. cfg
-Dontobfuscate
-Dontoptimize
Or add:
# Gson uses generic type information stored in a class file when working with fields. Proguard# removes such information by default, so configure it to keep all of it.-keepattributes Signature# Gson specific classes-keep class sun.misc.Unsafe { *; }#-keep class com.google.gson.stream.** { *; }# Application classes that will be serialized/deserialized over Gson-keep class com.google.gson.examples.android.model.** { *; }
However, after this configuration, the same error still occurs after the apk is packaged and released, and the problem is not solved.
After the tangle, think about the problem. Since the problem lies in obfuscation of classes that should not be obfuscated and network data retrieval, an error is reported, the problem caused by TypeToken class obfuscation has been ruled out (-keep class com. google. gson. ** {*;} also encountered the Missing Type patamerer problem.) The program encountered a obfuscated class before it was executed to TypeToken, view the code in the program for Obtaining Network Data and converting the json format, and find:
The classes under org.jsonare used in the obtained interface data, but the class is not retained in proguard-android.txt.
Add the following to proguard-android.txt:
-Keep classorg. json .**{*;}
Package and release the apk again. The operation is normal and the problem is solved!