use*_*104 8 java android proguard android-proguard
我在我的应用程序使用的几个库和之后的minifyEnabled是true,它不能生成APK.经过一些研究,我找到了规则并将其.pro逐个添加到文件中.
这是图书馆清单
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:23.1.0'
compile 'com.squareup.picasso:picasso:2.3.2'
compile 'com.nineoldandroids:library:2.4.0'
compile 'com.daimajia.slider:library:1.1.5@aar'
compile 'org.apache.httpcomponents:httpmime:4.3.5'//Volley
compile 'org.apache.httpcomponents:httpcore:4.2.4'//Volley
compile 'com.mcxiaoke.volley:library:1.0.17'//Volley
compile 'com.github.bumptech.glide:glide:3.6.1'//Gradle
compile 'com.baoyz.swipemenulistview:library:1.3.0'//Swipe Menu li stview
compile 'org.lucasr.twowayview:twowayview:0.1.4' //horizontal listview
compile 'com.android.support:recyclerview-v7:+'
Run Code Online (Sandbox Code Playgroud)
对于JAR,它是 PayPalAndroidSDK-2.9.11.jar
简而言之,我想知道是不是可以不为库添加规则,因为有些库似乎没有提到如何为它们设置proguard?它可以加密而不是优化代码并删除一些有用的代码吗?
非常感谢.
我想知道是不是可以逐个为库添加规则,因为有些库似乎没有提到如何为它们设置proguard?
是的可能,不是为您在项目中使用的每个库逐个添加规则.尝试在您的proguard-rules.pro文件中添加以下内容.
-keep class !com.example.myproject.** { *; }
Run Code Online (Sandbox Code Playgroud)
这个想法只是简单地使用你在你的正则表达式中使用proguard-rules.pro.
但是如果你没有混淆你的代码,那么使用proguard有什么意义呢.您可能希望在混淆后保持项目中的某些类不变.你只需要像其他库一样保留它们.例如 -
// I want to keep the classes in the `Models` package to remain unchanged
-keep class com.example.myproject.Models.** { *; }
-keepclassmembers class com.example.myproject.Model.** { *; }
Run Code Online (Sandbox Code Playgroud)
无论如何,逐个添加规则并不是很难,因为在混淆时你会有更多的控制权.这是我的proguard-rules.pro.你可以看看它.
-useuniqueclassmembernames
-allowaccessmodification
-keep class com.google.** { *; }
-keep class com.journeyapps.** { *; }
-keep class com.makeramen.** { *; }
-keep class com.github.** { *; }
-keep class org.apache.** { *; }
-keep class com.flipboard.** { *; }
-keep class com.android.** { *; }
-keep class com.mikepenz.** { *; }
-keep class junit.** { *; }
-keep class org.mockito.** { *; }
-keep class android.support.v7.widget.SearchView { *; }
-keep class com.example.myproject.Models.** { *; }
-keepclassmembers class com.example.myproject.Model.** { *; }
-keepattributes Signature
-keepattributes *Annotation*
-dontwarn com.google.**
-dontwarn org.apache.**
-dontwarn android.support.**
-dontwarn org.junit.**
-dontwarn org.mockito.**
-dontwarn com.makeramen.**
-assumenosideeffects class android.util.Log {
public static *** d(...);
public static *** v(...);
public static *** w(...);
public static *** i(...);
public static *** e(...);
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1896 次 |
| 最近记录: |