使用android相容包android-support-v4.jar出現的一些問題

來源:互聯網
上載者:User

項目需要用到ViewPager,毫不猶豫的引入了官方提供的android-support-v4.jar

開發過程平淡無奇,簽名打包時出現了兩個問題

1.使用eclipse匯出簽名apk出現錯誤

[2011-11-03 16:07:52 - AndroidViewPager] Proguard returned with error code 1. See console[2011-11-03 16:07:52 - AndroidViewPager] Note: there were 95 duplicate class definitions.[2011-11-03 16:07:52 - AndroidViewPager] Warning: android.support.v4.os.ParcelableCompatCreatorHoneycombMR2: can't find superclass or interface android.os.Parcelable$ClassLoaderCreator[2011-11-03 16:07:52 - AndroidViewPager] Warning: android.support.v4.app.ActivityCompatHoneycomb: can't find referenced method 'void invalidateOptionsMenu()' in class android.app.Activity[2011-11-03 16:07:52 - AndroidViewPager] Warning: android.support.v4.app.ActivityCompatHoneycomb: can't find referenced method 'void dump(java.lang.String,java.io.FileDescriptor,java.io.PrintWriter,java.lang.String[])' in class android.app.Activity[2011-11-03 16:07:52 - AndroidViewPager] Warning: android.support.v4.os.ParcelableCompatCreatorHoneycombMR2: can't find referenced class android.os.Parcelable$ClassLoaderCreator[2011-11-03 16:07:52 - AndroidViewPager] Warning: android.support.v4.os.ParcelableCompatCreatorHoneycombMR2: can't find referenced class android.os.Parcelable$ClassLoaderCreator[2011-11-03 16:07:52 - AndroidViewPager] Warning: android.support.v4.view.MenuCompatHoneycomb: can't find referenced method 'void setShowAsAction(int)' in class android.view.MenuItem[2011-11-03 16:07:52 - AndroidViewPager] Warning: there were 3 unresolved references to classes or interfaces.[2011-11-03 16:07:52 - AndroidViewPager]          You may need to specify additional library jars (using '-libraryjars'),[2011-11-03 16:07:52 - AndroidViewPager]          or perhaps the '-dontskipnonpubliclibraryclasses' option.[2011-11-03 16:07:52 - AndroidViewPager] Warning: there were 3 unresolved references to program class members.[2011-11-03 16:07:52 - AndroidViewPager]          Your input classes appear to be inconsistent.[2011-11-03 16:07:52 - AndroidViewPager]          You may need to recompile them and try again.[2011-11-03 16:07:52 - AndroidViewPager]          Alternatively, you may have to specify the options [2011-11-03 16:07:52 - AndroidViewPager]          '-dontskipnonpubliclibraryclasses' and/or[2011-11-03 16:07:52 - AndroidViewPager]          '-dontskipnonpubliclibraryclassmembers'.[2011-11-03 16:07:52 - AndroidViewPager] java.io.IOException: Please correct the above warnings first.[2011-11-03 16:07:52 - AndroidViewPager]    at proguard.Initializer.execute(Initializer.java:308) [2011-11-03 16:07:52 - AndroidViewPager]    at proguard.ProGuard.initialize(ProGuard.java:210)[2011-11-03 16:07:52 - AndroidViewPager]    at proguard.ProGuard.execute(ProGuard.java:85)[2011-11-03 16:07:52 - AndroidViewPager]    at proguard.ProGuard.main(ProGuard.java:499)

原因:

Android Compatibility library referencing classes that only exist in recent versions of the Android API

解決方案:在項目的proguard.cfg檔案中添加


-dontwarn **HoneycombMR2-dontwarn **CompatICS-dontwarn **Honeycomb-dontwarn **CompatIcs*-dontwarn **CompatFroyo-dontwarn **CompatGingerbread

具體要dontwarn哪些條目,可以根據報錯來進行相應的修改


2.使用命令列指令碼產生的apk無法運行,當運行到android-support-v4.jar相關的類時,出現ClassNotFoundException
解決方案:運行dx命令時,將android-support-v4.jar加入class.dex

%DX% --dex --output=%OUT_FOLDER%\classes.dex %OUT_CLASS_FOLDER% %THIRD_JAR%

參考

  1. http://stackoverflow.com/questions/7993608/i-am-getting-error-while-export-my-android-application-from-eclipse-which-use-an
  2. http://snmoney.blog.163.com/blog/static/440058201181011468397/






聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.