1. 程式人生 > >Android mk編譯OkHttp3

Android mk編譯OkHttp3

使用OkHttp,放到framework層編譯,編譯錯誤:

Warning: okio.DeflaterSink: can't find referenced class org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement
Warning: okio.Okio: can't find referenced class java.nio.file.Files
Warning: okio.Okio: can't find referenced class java.nio.file.Files
Warning: okio.Okio: can't
find referenced class java.nio.file.Files Warning: okio.Okio: can't find referenced class java.nio.file.Path Warning: okio.Okio: can't find referenced class java.nio.file.OpenOption Warning: okio.Okio: can't find referenced class java.nio.file.Path Warning: okio.Okio: can't find referenced class java.nio.file
.OpenOption Warning: okio.Okio: can't find referenced class org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement Warning: okio.Okio: can't find referenced class java.nio.file.Path Warning: okio.Okio: can't find referenced class java.nio.file.OpenOption Warning: okio.Okio: can't find referenced class java.nio.file
.Path Warning: okio.Okio: can't find referenced class java.nio.file.OpenOption Warning: okio.Okio: can't find referenced class org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement Warning: there were 14 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) Error: Please correct the above warnings first.

編譯環境:

  • Welcome to Ubuntu 14.04.4 LTS (GNU/Linux 3.16.0-40-generic x86_64)

  • [email protected]:~$ java -version

  • java version “1.7.0_101”
  • OpenJDK Runtime Environment (IcedTea 2.6.6) (7u101-2.6.6-0ubuntu0.14.04.1)
  • OpenJDK 64-Bit Server VM (build 24.95-b01, mixed mode)

github okhttp FAQs

擦,不用管。
關鍵提示資訊:“the warnings with ‘-dontwarn’ options”
////////////////////////////////////////////////////////////////

修改Android.mk

###使能proguard.cfg
LOCAL_PROGUARD_ENABLED := full
LOCAL_PROGUARD_FLAG_FILES := proguard.cfg

LOCAL_CERTIFICATE := platform
include $(BUILD_PACKAGE)

include $(CLEAR_VARS)
LOCAL_PREBUILT_STATIC_JAVA_LIBRARIES := okhttp:libs/okhttp-3.5.0.jar 
LOCAL_PREBUILT_STATIC_JAVA_LIBRARIES += okio:libs/okio-1.11.0.jar
include $(BUILD_MULTI_PREBUILT)

修改proguard.cfg

-dontwarn okio.**

目錄結構:
.
├── AndroidManifest.xml
├── Android.mk
├── assets
├── libs
│?? ├── okhttp-3.5.0.jar
│?? └── okio-1.11.0.jar