嗨,你的同事stackoverflowers!在android源應用程序中添加一個庫時出現「沒有規則製作目標」的錯誤
我正在AOSP構建系統中工作。我添加了另一個庫的依賴在我的應用程序(在封裝/應用程序),我得到這個奇怪的錯誤:
mmm -B packages/apps/MyApp/
make: Entering directory `/home/user/workspace/aosp'
target R.java/Manifest.java: MyApp (out/target/common/obj/APPS/MyApp_intermediates/src/R.stamp)
make: *** No rule to make target `out/target/common/obj/JAVA_LIBRARIES/bcprov-jdk15on-152_intermediates/javalib.jar', needed by `out/target/common/obj/APPS/MyApp_intermediates/classes-full-debug.jar'. Stop.
我沒有這個錯誤與Android Studio和庫按預期工作,但我需要構建它在AOSP。
這裏的Android.mk:
LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)
# TAGS is test, so apk will end up in /data/app
LOCAL_MODULE_TAGS := tests
LOCAL_MODULE_OWNER := mycompany
# Java sources are in ./java
LOCAL_SRC_FILES := $(call all-java-files-under, java)
# Resources are in ./res
LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/res
# We need all these jars
LOCAL_STATIC_JAVA_LIBRARIES += android-support-v4
LOCAL_STATIC_JAVA_LIBRARIES := restlet-2.3.2-jsslutils
LOCAL_STATIC_JAVA_LIBRARIES += restlet-2.3.2-restlet-ext-nio
LOCAL_STATIC_JAVA_LIBRARIES += restlet-2.3.2-restlet
LOCAL_STATIC_JAVA_LIBRARIES += bcprov-jdk15on-152
LOCAL_STATIC_JAVA_LIBRARIES += ksoap2-android-assembly-3.4.0-jar-with-dependencies
LOCAL_JAVA_LIBRARIES := com.mycompany.myservice.lib
# The name of this application
LOCAL_PACKAGE_NAME := MyApp
# No Proguard
LOCAL_PROGUARD_ENABLED := disabled
# Build an APK
include $(BUILD_PACKAGE)
而且AndroidManifest.xml中:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="mycompany.myapp" >
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-feature android:name="android.hardware.camera" />
<uses-feature android:name="android.hardware.camera.autofocus" />
<uses-feature android:name="android.hardware.sensor" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_people"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<uses-library
android:name="com.mycompany.myservice.lib"
android:required="true" />
<activity
android:name=".MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<service
android:name=".ws.CommandIntentService"
android:exported="false" >
</service>
<service
android:name=".ws.WSRequestIntentService"
android:exported="false" >
</service>
<service
android:name=".ws.CloudClientService"
android:enabled="true"
android:exported="false" >
</service>
</application>
</manifest>
我得到這個錯誤兩種bountycaste(bcprov ...)和KSOAP庫。
尋求工作/失敗的庫之間的差異,我嘗試了一個Java反編譯器。 我能夠使用unzip和jad(java反編譯器)從restlet和ksoap2類中反編譯類。這兩個文件反編譯沒有問題。
我也嘗試使用LOCAL_PREBUILT_STATIC_JAVA_LIBRARIES
預編譯庫,但它沒有工作。
在此先感謝!
正確答案是使用LOCAL_PREBUILT_STATIC_JAVA_LIBRARIES。在我的特殊設置中,預建的庫位於'{root_aosp_dir}/external'中,所以在發佈之前我沒有找到它們!/facepalm 所有其他無關的建議,例如'com.mycompany.myservice.lib',它工作得很好...... – ForeverLearning