我在我的项目中包含了一个 jar。我把罐子放在 libs 文件夹中。然后我添加到构建路径。我在我的设备上运行该项目,它运行良好。但是当我签署它时,它会崩溃。我猜是proguard
.
如果我不想对 jar 进行 progurad,我该如何编写proguard-project.txt
?
这个罐子是亚马逊移动广告罐。https://developer.amazon.com/sdk/mobileads.html
========编辑==============
04-26 23:13:07.973: E/AndroidRuntime(25405): FATAL EXCEPTION: main
04-26 23:13:07.973: E/AndroidRuntime(25405): android.view.InflateException: Binary XML file line #9: Error inflating class com.amazon.device.ads.AdLayout
04-26 23:13:07.973: E/AndroidRuntime(25405): at android.view.LayoutInflater.createView(LayoutInflater.java:606)
04-26 23:13:07.973: E/AndroidRuntime(25405): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:680)
04-26 23:13:07.973: E/AndroidRuntime(25405): at android.view.LayoutInflater.rInflate(LayoutInflater.java:739)
04-26 23:13:07.973: E/AndroidRuntime(25405): at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
04-26 23:13:07.973: E/AndroidRuntime(25405): at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
04-26 23:13:07.973: E/AndroidRuntime(25405): at com.vtube.app.VideoGridviewAdapter.createViewFromResource(Unknown Source)
04-26 23:13:07.973: E/AndroidRuntime(25405): at com.vtube.app.VideoGridviewAdapter.getView(Unknown Source)
04-26 23:13:07.973: E/AndroidRuntime(25405): at com.vtube.component.ListToGridAdapter.bindView(Unknown Source)
04-26 23:13:07.973: E/AndroidRuntime(25405): at com.vtube.component.ListToGridAdapter.bindGridView(Unknown Source)
04-26 23:13:07.973: E/AndroidRuntime(25405): at com.vtube.component.ListToGridAdapter.getView(Unknown Source)
04-26 23:13:07.973: E/AndroidRuntime(25405): at android.widget.HeaderViewListAdapter.getView(HeaderViewListAdapter.java:220)
04-26 23:13:07.973: E/AndroidRuntime(25405): at android.widget.AbsListView.obtainView(AbsListView.java:2043)
04-26 23:13:07.973: E/AndroidRuntime(25405): at android.widget.ListView.makeAndAddView(ListView.java:1772)
04-26 23:13:07.973: E/AndroidRuntime(25405): at android.widget.ListView.fillDown(ListView.java:672)
04-26 23:13:07.973: E/AndroidRuntime(25405): at android.widget.ListView.fillSpecific(ListView.java:1330)
04-26 23:13:07.973: E/AndroidRuntime(25405): at android.widget.ListView.layoutChildren(ListView.java:1603)
04-26 23:13:07.973: E/AndroidRuntime(25405): at android.widget.AbsListView.onLayout(AbsListView.java:1873)
04-26 23:13:07.973: E/AndroidRuntime(25405): at android.view.View.layout(View.java:11307)
04-26 23:13:07.973: E/AndroidRuntime(25405): at android.view.ViewGroup.layout(ViewGroup.java:4224)
04-26 23:13:07.973: E/AndroidRuntime(25405): at android.widget.FrameLayout.onLayout(FrameLayout.java:431)
04-26 23:13:07.973: E/AndroidRuntime(25405): at android.view.View.layout(View.java:11307)
04-26 23:13:07.973: E/AndroidRuntime(25405): at android.view.ViewGroup.layout(ViewGroup.java:4224)
04-26 23:13:07.973: E/AndroidRuntime(25405): at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1628)
04-26 23:13:07.973: E/AndroidRuntime(25405): at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1486)
04-26 23:13:07.973: E/AndroidRuntime(25405): at android.widget.LinearLayout.onLayout(LinearLayout.java:1399)
04-26 23:13:07.973: E/AndroidRuntime(25405): at android.view.View.layout(View.java:11307)
04-26 23:13:07.973: E/AndroidRuntime(25405): at android.view.ViewGroup.layout(ViewGroup.java:4224)
04-26 23:13:07.973: E/AndroidRuntime(25405): at android.widget.RelativeLayout.onLayout(RelativeLayout.java:925)
04-26 23:13:07.973: E/AndroidRuntime(25405): at android.view.View.layout(View.java:11307)
04-26 23:13:07.973: E/AndroidRuntime(25405): at android.view.ViewGroup.layout(ViewGroup.java:4224)
04-26 23:13:07.973: E/AndroidRuntime(25405): at android.widget.FrameLayout.onLayout(FrameLayout.java:431)
04-26 23:13:07.973: E/AndroidRuntime(25405): at android.view.View.layout(View.java:11307)
04-26 23:13:07.973: E/AndroidRuntime(25405): at android.view.ViewGroup.layout(ViewGroup.java:4224)
04-26 23:13:07.973: E/AndroidRuntime(25405): at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1628)
04-26 23:13:07.973: E/AndroidRuntime(25405): at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1486)
04-26 23:13:07.973: E/AndroidRuntime(25405): at android.widget.LinearLayout.onLayout(LinearLayout.java:1399)
04-26 23:13:07.973: E/AndroidRuntime(25405): at android.view.View.layout(View.java:11307)
04-26 23:13:07.973: E/AndroidRuntime(25405): at android.view.ViewGroup.layout(ViewGroup.java:4224)
04-26 23:13:07.973: E/AndroidRuntime(25405): at android.widget.FrameLayout.onLayout(FrameLayout.java:431)
04-26 23:13:07.973: E/AndroidRuntime(25405): at android.view.View.layout(View.java:11307)
04-26 23:13:07.973: E/AndroidRuntime(25405): at android.view.ViewGroup.layout(ViewGroup.java:4224)
04-26 23:13:07.973: E/AndroidRuntime(25405): at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1501)
04-26 23:13:07.973: E/AndroidRuntime(25405): at android.view.ViewRootImpl.handleMessage(ViewRootImpl.java:2462)
04-26 23:13:07.973: E/AndroidRuntime(25405): at android.os.Handler.dispatchMessage(Handler.java:99)
04-26 23:13:07.973: E/AndroidRuntime(25405): at android.os.Looper.loop(Looper.java:137)
04-26 23:13:07.973: E/AndroidRuntime(25405): at android.app.ActivityThread.main(ActivityThread.java:4560)
04-26 23:13:07.973: E/AndroidRuntime(25405): at java.lang.reflect.Method.invokeNative(Native Method)
04-26 23:13:07.973: E/AndroidRuntime(25405): at java.lang.reflect.Method.invoke(Method.java:511)
04-26 23:13:07.973: E/AndroidRuntime(25405): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
04-26 23:13:07.973: E/AndroidRuntime(25405): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
04-26 23:13:07.973: E/AndroidRuntime(25405): at dalvik.system.NativeStart.main(Native Method)
04-26 23:13:07.973: E/AndroidRuntime(25405): Caused by: java.lang.reflect.InvocationTargetException
04-26 23:13:07.973: E/AndroidRuntime(25405): at java.lang.reflect.Constructor.constructNative(Native Method)
04-26 23:13:07.973: E/AndroidRuntime(25405): at java.lang.reflect.Constructor.newInstance(Constructor.java:417)
04-26 23:13:07.973: E/AndroidRuntime(25405): at android.view.LayoutInflater.createView(LayoutInflater.java:586)
04-26 23:13:07.973: E/AndroidRuntime(25405): ... 50 more
04-26 23:13:07.973: E/AndroidRuntime(25405): Caused by: java.lang.ArrayIndexOutOfBoundsException: length=390; index=-6
04-26 23:13:07.973: E/AndroidRuntime(25405): at android.content.res.TypedArray.getString(TypedArray.java:120)
04-26 23:13:07.973: E/AndroidRuntime(25405): at com.amazon.device.ads.AdLayout.<init>(Unknown Source)
04-26 23:13:07.973: E/AndroidRuntime(25405): ... 53 more
此 FC 仅在签署时发生。所以我想这是proguard问题。cause by
部分在amazon ad jar
.
keep
我投入了很多proguard-project.txt
:
-dontoptimize
-keep class com.amazon.device.ads.** { *; }
-dontwarn com.amazon.**
-keep class com.amazon.** {*;}
-keepattributes *Annotation*
-keepclassmembers class com.amazon.** {*;}
-keepclassmembernames class com.amazon.** {*;}
-keepclasseswithmembernames class * {
native <methods>;
}
-keepclasseswithmembernames class * {
public <init>(android.content.Context, android.util.AttributeSet);
}
-keepclasseswithmembernames class * {
public <init>(android.content.Context, android.util.AttributeSet, int);
}