Ich versuche, ein Projekt in System Building-Umgebung zu erstellen. Das Projekt enthält ein Bibliotheksprojekt, das einige Ressourcen enthält. Die Codes im Bibliotheksprojekt greifen auf diese Ressourcen zu. Das Gebäude ist durch einige Fehler gescheitert. Hier sind die Details:Building Fehler auf einem Bibliotheksprojekt einschließlich Ressourcen
Die Struktur des Projekts ist:
packages/experimental/MyApplication/
|--AndroidManifest.xml
|--Android.mk
|--proguard.flags
|--libs/
|--res/
|--src/
|--mylibrary/
| |--AndroidManifest.xml
| |--Android.mk
| |--libs/
| |--res/
| | |--values/strings.xml
| |--src/
| |-- |--com/example/mytest/CustomView.java
mylibrary ist das Bibliotheksprojekt. In diesem Fall greift ein CustomView.java auf die in strings.xml definierte Zeichenfolgenressource zu. Die Make-Datei für Hauptprojekt ist:
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
mylib_dir := mylibrary/res
res_dir := $(mylib_dir) res
LOCAL_MODULE_TAGS := optional
LOCAL_SRC_FILES := $(call all-java-files-under, src)
LOCAL_RESOURCE_DIR := $(addprefix $(LOCAL_PATH)/, $(res_dir))
LOCAL_AAPT_FLAGS := --auto-add-overlay
LOCAL_AAPT_FLAGS += --extra-packages com.example.popoalex.mylibrary
LOCAL_STATIC_JAVA_LIBRARIES := mylibrary okhttp
LOCAL_PACKAGE_NAME := MyApplication
#LOCAL_CERTIFICATE := platform
#LOCAL_PROGUARD_FLAG_FILES := proguard.flags
include $(BUILD_PACKAGE)
##################################################
include $(CLEAR_VARS)
LOCAL_PREBUILT_STATIC_JAVA_LIBRARIES := okhttp:libs/okhttp-1.0.0.jar
include $(BUILD_MULTI_PREBUILT)
# only include rules to build other stuff for the original package, not the derived package.
ifeq ($(strip $(LOCAL_PACKAGE_OVERRIDES)),)
# Use the folloing include to make our test apk.
include $(call all-makefiles-under,$(LOCAL_PATH))
endif
Und die Make-Datei für Bibliotheksprojekt ist:
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := mylibrary
LOCAL_STATIC_JAVA_LIBRARIES := gson
LOCAL_SRC_FILES := $(call all-java-files-under, src)
LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/res
include $(BUILD_STATIC_JAVA_LIBRARY)
##################################################
include $(CLEAR_VARS)
LOCAL_PREBUILT_STATIC_JAVA_LIBRARIES := gson:libs/gson-2.2.4.jar
include $(BUILD_MULTI_PREBUILT)
##################################################
# Build all sub-directories
include $(call all-makefiles-under,$(LOCAL_PATH))
Das Gebäude Befehl ich verwendet wurde:
mmm packages/experimental/MyApplication/
Das Gebäude ausgegeben werden:
============================================
PLATFORM_VERSION_CODENAME=REL
PLATFORM_VERSION=4.3.1
CM_VERSION=10.2-20160708-UNOFFICIAL-n8000
TARGET_PRODUCT=cm_n8000
TARGET_BUILD_VARIANT=userdebug
TARGET_BUILD_TYPE=release
TARGET_BUILD_APPS=
TARGET_ARCH=arm
TARGET_ARCH_VARIANT=armv7-a-neon
TARGET_CPU_VARIANT=cortex-a9
HOST_ARCH=x86
HOST_OS=linux
HOST_OS_EXTRA=Linux-3.16.0-76-generic-x86_64-with-Ubuntu-14.04-trusty
HOST_BUILD_TYPE=release
BUILD_ID=JLS36I
OUT_DIR=/home/popoalex/Projects/cm/out
============================================
PRODUCT_COPY_FILES device/samsung/smdk4412-common/rootdir/init.trace.rc:root/init.trace.rc ignored.
PRODUCT_COPY_FILES device/samsung/smdk4412-common/configs/audio_effects.conf:system/etc/audio_effects.conf ignored.
PRODUCT_COPY_FILES device/samsung/n80xx-common/ueventd.smdk4x12.rc:root/ueventd.smdk4x12.rc ignored.
PRODUCT_COPY_FILES device/samsung/n80xx-common/ueventd.smdk4x12.rc:recovery/root/ueventd.smdk4x12.rc ignored.
PRODUCT_COPY_FILES device/samsung/n80xx-common/configs/audio_policy.conf:system/etc/audio_policy.conf ignored.
PRODUCT_COPY_FILES device/samsung/n8000/configs/gps.conf:system/etc/gps.conf ignored.
No private recovery resources for TARGET_DEVICE n8000
make: Entering directory `/home/popoalex/Projects/cm'
Proguard: /home/popoalex/Projects/cm/out/target/common/obj/APPS/MyApplication_intermediates/proguard.classes.jar
ProGuard, version 4.4
Reading program jar [/home/popoalex/Projects/cm/out/target/common/obj/APPS/MyApplication_intermediates/classes.jar]
Reading library jar [/home/popoalex/Projects/cm/out/target/common/obj/JAVA_LIBRARIES/core_intermediates/classes.jar]
Reading library jar [/home/popoalex/Projects/cm/out/target/common/obj/JAVA_LIBRARIES/core-junit_intermediates/classes.jar]
Reading library jar [/home/popoalex/Projects/cm/out/target/common/obj/JAVA_LIBRARIES/ext_intermediates/classes.jar]
Reading library jar [/home/popoalex/Projects/cm/out/target/common/obj/JAVA_LIBRARIES/framework_intermediates/classes.jar]
Warning: com.example.popoalex.mylibrary.CustomView: can't find referenced class com.example.popoalex.mylibrary.R$string
Warning: com.example.popoalex.mylibrary.CustomView: can't find referenced class com.example.popoalex.mylibrary.R$string
Warning: com.example.popoalex.mylibrary.CustomView: can't find referenced class com.example.popoalex.mylibrary.R
Note: com.squareup.okhttp.internal.Platform accesses a method 'setHostname(java.lang.String)' dynamically
Maybe this is library method 'gov.nist.core.Host { void setHostname(java.lang.String); }'
Maybe this is library method 'org.apache.harmony.xnet.provider.jsse.OpenSSLSocketImpl { void setHostname(java.lang.String); }'
Note: com.squareup.okhttp.internal.Platform accesses a method 'setNpnProtocols(byte[])' dynamically
Maybe this is library method 'org.apache.harmony.xnet.provider.jsse.OpenSSLSocketImpl { void setNpnProtocols(byte[]); }'
Note: com.squareup.okhttp.internal.Platform accesses a method 'getNpnSelectedProtocol()' dynamically
Maybe this is library method 'org.apache.harmony.xnet.provider.jsse.OpenSSLSocketImpl { byte[] getNpnSelectedProtocol(); }'
Note: com.squareup.okhttp.internal.Platform accesses a method 'get(javax.net.ssl.SSLSocket)' dynamically
Note: there were 4 accesses to class members by means of introspection.
You should consider explicitly keeping the mentioned class members
(using '-keep' or '-keepclassmembers').
Warning: there were 3 unresolved references to classes or interfaces.
You may need to specify additional library jars (using '-libraryjars'),
or perhaps the '-dontskipnonpubliclibraryclasses' option.
Error: Please correct the above warnings first.
make: *** [/home/popoalex/Projects/cm/out/target/common/obj/APPS/MyApplication_intermediates/proguard.classes.jar] Error 1
make: Leaving directory `/home/popoalex/Projects/cm'
Wenn ich Kommentieren Sie die Codes, die beim Zugriff auf die String-Ressource das Gebäude erfolgreich waren. Die proguard.flags verwende ich nur die Standard. Das System, das ich das Gebäude leitete, ist Ubuntu 14.04, und der Quellcode basiert auf CM 10.2 (die Äquivalenz zu AOSP 4.3.1).
Aktualisiert:
Die Zwischendateien von Bibliotheksprojekt Gebäude erfolgreich generiert. Im Verzeichnis: out/target/common/obj/JAVA_LIBRARIES/mylibrary_intermediates/
Es scheint, dass Sie versuchen, 'mylibrary' zu verwenden, bevor es erstellt wurde. Überprüfen Sie die Build-Reihenfolge – CJxD
Wie sehen Sie die Build-Reihenfolge? Könntest du mir mehr Anweisungen geben, weil ich mich nicht sehr gut auskenne? Danke :) – popo
Ich bin nicht vertraut mit Android Makefiles selbst, aber stellen Sie sicher, dass die Zeile 'include $ (Aufruf all-makefiles-unter, $ (LOCAL_PATH))' wird * vor * Ihr Projekt beginnt zu bauen. Sie müssen die Bibliothek für Ihr Hauptprojekt verfügbar haben, bevor sie versucht, sie zu erstellen. – CJxD