欢迎使用CSDN-markdown编辑器

来源:互联网 发布:淘宝直播库里中国行 编辑:程序博客网 时间:2024/05/16 07:39

前几天用Androidstudio进行打包时出现一个错误——-

Error:Execution failed for task ‘:app:transformClassesAndResourcesWithProguardForRelease’.
java.io.IOException: Please correct the above warnings first.

然后一直打包不成功。其实原因是这样的在我们引入第三方库时在build.gradle中有这样一句话

buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile(‘proguard-android.txt’), ‘proguard-rules.pro’
}
}

在proguard-rules.pro这个文件中代码混淆有问题,然后在AndroidStudio 的Messages中有很多的警告信息,那么多半是因为混淆的问题。以下是我集成第三方库后打包出现的信息:

Warning:com.umeng.fb.push.b1:cantfindsuperclassorinterfacecom.umeng.message.UmengMessageHandlerWarning:com.umeng.fb.ConversationActivity:cantfindreferencedmethodvoidfinish()inprogramclasscom.umeng.fb.ConversationActivityWarning:com.umeng.fb.ConversationActivity:cantfindreferencedmethodandroid.app.ActionBargetActionBar()inprogramclasscom.umeng.fb.ConversationActivityWarning:com.umeng.fb.ConversationActivity:cantfindreferencedmethodandroid.content.IntentgetIntent()inprogramclasscom.umeng.fb.ConversationActivityWarning:com.umeng.fb.ConversationActivity:cantfindreferencedmethodandroid.support.v4.app.FragmentManagergetSupportFragmentManager()inprogramclasscom.umeng.fb.ConversationActivityWarning:com.umeng.fb.ConversationActivity:cantfindreferencedmethodvoidsetContentView(int)inprogramclasscom.umeng.fb.ConversationActivityWarning:com.umeng.fb.HelpActivity:cantfindreferencedmethodandroid.view.ViewfindViewById(int)inprogramclasscom.umeng.fb.HelpActivityWarning:com.umeng.fb.HelpActivity:cantfindreferencedmethodvoidfinish()inprogramclasscom.umeng.fb.HelpActivityWarning:com.umeng.fb.HelpActivity:cantfindreferencedmethodandroid.app.ActionBargetActionBar()inprogramclasscom.umeng.fb.HelpActivityWarning:com.umeng.fb.HelpActivity:cantfindreferencedmethodandroid.content.res.ResourcesgetResources()inprogramclasscom.umeng.fb.HelpActivityWarning:com.umeng.fb.HelpActivity:cantfindreferencedmethodandroid.support.v4.app.FragmentManagergetSupportFragmentManager()inprogramclasscom.umeng.fb.HelpActivityWarning:com.umeng.fb.HelpActivity:cantfindreferencedmethodandroid.view.WindowgetWindow()inprogramclasscom.umeng.fb.HelpActivityWarning:com.umeng.fb.HelpActivity:cantfindreferencedmethodvoidsetContentView(int)inprogramclasscom.umeng.fb.HelpActivityWarning:com.umeng.fb.HelpActivitya: can’t find referenced method ‘android.content.Context getApplicationContext()’ in program class com.umeng.fb.HelpActivity
Warning:com.umeng.fb.HelpActivitya:cantfindreferencedmethodandroid.content.IntentgetIntent()inprogramclasscom.umeng.fb.HelpActivityWarning:com.umeng.fb.HelpActivitya: can’t find referenced method ‘android.content.res.Resources getResources()’ in program class com.umeng.fb.HelpActivity
Warning:com.umeng.fb.fragment.FeedbackFragment: can’t find referenced method ‘android.support.v4.app.FragmentActivity getActivity()’ in program class com.umeng.fb.fragment.FeedbackFragment
Warning:com.umeng.fb.fragment.FeedbackFragment: can’t find referenced method ‘android.os.Bundle getArguments()’ in program class com.umeng.fb.fragment.FeedbackFragment
Warning:com.umeng.fb.fragment.FeedbackFragment: can’t find referenced method ‘android.content.res.Resources getResources()’ in program class com.umeng.fb.fragment.FeedbackFragment
Warning:com.umeng.fb.fragment.FeedbackFragment: can’t find referenced method ‘void setArguments(android.os.Bundle)’ in program class com.umeng.fb.fragment.FeedbackFragment
Warning:com.umeng.fb.fragment.FeedbackFragment: can’t find referenced method ‘void setColorSchemeResources(int[])’ in program class com.umeng.fb.widget.InterceptTouchSwipeRefreshLayout
Warning:com.umeng.fb.fragment.FeedbackFragment: can’t find referenced method ‘void setOnRefreshListener(android.support.v4.widget.SwipeRefreshLayoutOnRefreshListener)inprogramclasscom.umeng.fb.widget.InterceptTouchSwipeRefreshLayoutWarning:com.umeng.fb.fragment.FeedbackFragment:cantfindreferencedmethodvoidsetRefreshing(boolean)inprogramclasscom.umeng.fb.widget.InterceptTouchSwipeRefreshLayoutWarning:com.umeng.fb.fragment.FeedbackFragment1: can’t find referenced method ‘android.content.res.Resources getResources()’ in program class com.umeng.fb.fragment.FeedbackFragment
Warning:com.umeng.fb.fragment.FeedbackFragment10:cantfindreferencedmethodvoidsetRefreshing(boolean)inprogramclasscom.umeng.fb.widget.InterceptTouchSwipeRefreshLayoutWarning:com.umeng.fb.fragment.FeedbackFragment11: can’t find referenced method ‘android.support.v4.app.FragmentActivity getActivity()’ in program class com.umeng.fb.fragment.FeedbackFragment
Warning:com.umeng.fb.fragment.FeedbackFragment5:cantfindreferencedmethodvoidstartActivityForResult(android.content.Intent,int)inprogramclasscom.umeng.fb.fragment.FeedbackFragmentWarning:com.umeng.fb.fragment.QuestionFragment:cantfindreferencedmethodandroid.support.v4.app.FragmentActivitygetActivity()inprogramclasscom.umeng.fb.fragment.QuestionFragmentWarning:com.umeng.fb.push.b:cantfindreferencedclasscom.umeng.message.PushAgentWarning:com.umeng.fb.push.b:cantfindreferencedclasscom.umeng.message.entity.UMessageWarning:com.umeng.fb.push.b:cantfindreferencedclasscom.umeng.message.PushAgentWarning:com.umeng.fb.push.b:cantfindreferencedclasscom.umeng.message.entity.UMessageWarning:com.umeng.fb.push.b1: can’t find referenced class com.umeng.message.UmengMessageHandler
Warning:com.umeng.fb.push.b1:cantfindreferencedclasscom.umeng.message.entity.UMessageWarning:com.umeng.fb.push.b1: can’t find referenced class com.umeng.message.UmengMessageHandler
Warning:com.umeng.fb.push.b1:cantfindreferencedclasscom.umeng.message.entity.UMessageWarning:com.umeng.fb.push.b2: can’t find referenced class com.umeng.message.PushAgent
Note: com.mob.tools.utils.DeviceHelper: can’t find dynamically referenced class android.os.SystemProperties
Note: com.umeng.fb.push.FeedbackPush: can’t find dynamically referenced class com.umeng.message.UmengService
Note: the configuration keeps the entry point ‘com.baidu.mobads.AdView { void setListener(com.baidu.mobads.AdViewListener); }’, but not the descriptor class ‘com.baidu.mobads.AdViewListener’
Note: the configuration keeps the entry point ‘com.baidu.mobads.VideoAdView { void setListener(com.baidu.mobads.VideoAdViewListener); }’, but not the descriptor class ‘com.baidu.mobads.VideoAdViewListener’
Note: the configuration keeps the entry point ‘com.mob.tools.gui.MobViewPager { void setAdapter(com.mob.tools.gui.ViewPagerAdapter); }’, but not the descriptor class ‘com.mob.tools.gui.ViewPagerAdapter’
Note: the configuration keeps the entry point ‘com.mob.tools.gui.PullToRequestView { void setAdapter(com.mob.tools.gui.PullToRequestAdatper); }’, but not the descriptor class ‘com.mob.tools.gui.PullToRequestAdatper’
Note: the configuration keeps the entry point ‘com.mob.tools.gui.ScaledImageView { void setOnMatrixChangedListener(com.mob.tools.gui.ScaledImageViewOnMatrixChangedListener); }', but not the descriptor class 'com.mob.tools.gui.ScaledImageViewOnMatrixChangedListener’
Note: there were 8 references to unknown classes.
You should check your configuration for typos.
(http://proguard.sourceforge.net/manual/troubleshooting.html#unknownclass)
Note: there were 5 unkept descriptor classes in kept class members.
You should consider explicitly keeping the mentioned classes
(using ‘-keep’).
(http://proguard.sourceforge.net/manual/troubleshooting.html#descriptorclass)
Note: there were 2 unresolved dynamic references to classes or interfaces.
You should check if you need to specify additional program jars.
(http://proguard.sourceforge.net/manual/troubleshooting.html#dynamicalclass)
Warning:there were 15 unresolved references to classes or interfaces.
You may need to add missing library jars or update their versions.
If your code works fine without the missing classes, you can suppress
the warnings with ‘-dontwarn’ options.
(http://proguard.sourceforge.net/manual/troubleshooting.html#unresolvedclass)
Warning:there were 27 unresolved references to program class members.
Your input classes appear to be inconsistent.
You may need to recompile the code.
(http://proguard.sourceforge.net/manual/troubleshooting.html#unresolvedprogramclassmember)
Warning:Exception while processing task java.io.IOException: Please correct the above warnings first.
:app:transformClassesAndResourcesWithProguardForRelease FAILED
Error:Execution failed for task ‘:app:transformClassesAndResourcesWithProguardForRelease’.
java.io.IOException: Please correct the above warnings first.
Information:BUILD FAILED
Information:Total time: 2.368 secs
Information:1 error
Information:40 warnings
Information:See complete output in console

那么解决这个问题很简单,只要消除这些警告就可以了。
你只需要在proguard-rules.pro这个文件中加入这样一句话

-ignorewarnings //通过这句话就可以取消掉系统中的这些警告。

0 0