how can I use annotationProcessor in android.mk
Asked Answered
J

1

7

I just want to use bufferknife and drag2 in my system app, I have built my app with the command mm.

I have tried every possible method I could find, but failed! I've only found the below Android.mk by Googling:

# Copyright (C) 2015 The Android Open Source Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a c

opy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
LOCAL_PATH := $(call my-dir)
# Include definitions of DAGGER2_PROCESSOR_CLASSES/LIBRARIES
include external/dagger2/dagger2_annotation_processor.mk
# build caliper host jar
# ============================================================
include $(CLEAR_VARS)
LOCAL_MODULE := caliper-host
LOCAL_MODULE_TAGS := optional
LOCAL_MODULE_CLASS := JAVA_LIBRARIES
LOCAL_SRC_FILES := $(call all-java-files-under, caliper/src/main/java/)
LOCAL_JAVA_RESOURCE_DIRS := caliper/src/main/resources
LOCAL_IS_HOST_MODULE := true
LOCAL_STATIC_JAVA_LIBRARIES := \
  apache-commons-math-host \
  caliper-gson-host \
  caliper-java-allocation-instrumenter-host \
  caliper-jersey-client-host \
  caliper-jersey-core-host \
  caliper-joda-time-host \
  caliper-jsr311-api-host \
  dagger2-host \
  dagger2-inject-host \
  guavalib
# Use Dagger2 annotation processor
PROCESSOR_LIBRARIES := $(DAGGER2_PROCESSOR_LIBRARIES)
PROCESSOR_CLASSES := $(DAGGER2_PROCESSOR_CLASSES)
include external/dagger2/java_annotation_processors.mk
include $(BUILD_HOST_JAVA_LIBRARY)
# Remember the location of the generated files, this is needed for when
# building for target
caliper_host_generated_sources_dir := $(local-generated-sources-dir)/annotation_processor_output
# build caliper target api jar
# ============================================================
# This contains just those classes needed for benchmarks to compile.
include $(CLEAR_VARS)
LOCAL_MODULE := caliper-api-target
LOCAL_MODULE_TAGS := optional
LOCAL_MODULE_CLASS := JAVA_LIBRARIES
LOCAL_SRC_FILES := \
  caliper/src/main/java/com/google/caliper/AfterExperiment.java \
  caliper/src/main/java/com/google/caliper/BeforeExperiment.java \
  caliper/src/main/java/com/google/caliper/Param.java \
  caliper/src/main/java/com/google/caliper/All.java \
  caliper/src/main/java/com/google/caliper/Benchmark.java
include $(BUILD_JAVA_LIBRARY)
# build caliper tests
# ============================================================
# vogar --expectations $ANDROID_BUILD_TOP/external/caliper/expec`enter code here`tations/knownfailures.txt \
        --test-only \
        --classpath $ANDROID_BUILD_TOP/out/host/common/obj/JAVA_LIBRARIES/caliper-tests_intermediates/javalib.jar \
        com.google.caliper
include $(CLEAR_VARS)
LOCAL_MODULE := caliper-tests
LOCAL_MODULE_TAGS := optional
LOCAL_MODULE_CLASS := JAVA_LIBRARIES
LOCAL_SRC_FILES := $(call all-java-files-under, caliper/src/test/java/)
LOCAL_JAVA_RESOURCE_DIRS := caliper/src/test/resources
LOCAL_IS_HOST_MODULE := true
LOCAL_STATIC_JAVA_LIBRARIES := \
  caliper-host \
  junit \
  mockito-host
# Use Dagger2 annotation processor
PROCESSOR_LIBRARIES := $(DAGGER2_PROCESSOR_LIBRARIES)
PROCESSOR_CLASSES := $(DAGGER2_PROCESSOR_CLASSES)
include external/dagger2/java_annotation_processors.mk
include $(BUILD_HOST_JAVA_LIBRARY)
# build caliper examples
# ============================================================
include $(CLEAR_VARS)
LOCAL_MODULE := caliper-examples
LOCAL_MODULE_TAGS := optional
LOCAL_MODULE_CLASS := JAVA_LIBRARIES
LOCAL_SRC_FILES := $(call all-java-files-under, examples/src/main/java/)
LOCAL_IS_HOST_MODULE := true
LOCAL_STATIC_JAVA_LIBRARIES := \
  caliper-host \
  junit \
  mockito-host
include $(BUILD_HOST_JAVA_LIBRARY)
# Build host dependencies.
# ============================================================
include $(CLEAR_VARS)
LOCAL_PREBUILT_JAVA_LIBRARIES := \
    caliper-gson-host:lib/gson-2.2.2$(COMMON_JAVA_PACKAGE_SUFFIX) \
    caliper-java-allocation-instrumenter-host:lib/java-allocation-instrumenter-2.0$(COMMON_JAVA_PACKAGE_SUFFIX) \
    caliper-jersey-client-host:lib/jersey-client-1.11$(COMMON_JAVA_PACKAGE_SUFFIX) \
    caliper-jersey-core-host:lib/jersey-core-1.11$(COMMON_JAVA_PACKAGE_SUFFIX) \
    caliper-joda-time-host:lib/joda-time-2.1$(COMMON_JAVA_PACKAGE_SUFFIX) \
    caliper-jsr311-api-host:lib/jsr311-api-1.1.1$(COMMON_JAVA_PACKAGE_SUFFIX)
include $(BUILD_HOST_PREBUILT)
Jacinda answered 27/4, 2018 at 10:34 Comment(0)
B
3

I done a sample aosp dagger app using below android.mk. Just try and let me know the result.

    LOCAL_PATH:= $(call my-dir)
    include $(CLEAR_VARS)
    LOCAL_SRC_FILES := $(call all-java-files-under, src)

    LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/res \
    frameworks/support/v7/appcompat/res \
    frameworks/support/design/res

    LOCAL_PACKAGE_NAME := DaggerSample
    LOCAL_STATIC_JAVA_LIBRARIES += android-support-v4
    LOCAL_STATIC_JAVA_LIBRARIES += android-support-v7-appcompat
    LOCAL_STATIC_JAVA_LIBRARIES += android-support-v7-gridlayout
    LOCAL_STATIC_JAVA_LIBRARIES += android-support-v13
    LOCAL_STATIC_JAVA_LIBRARIES += ds-dagger2-target
    LOCAL_STATIC_JAVA_LIBRARIES += ds-guava-target
    LOCAL_STATIC_JAVA_LIBRARIES += ds-javax-annotation-api-target
    LOCAL_STATIC_JAVA_LIBRARIES += jsr305
    LOCAL_STATIC_JAVA_LIBRARIES += ds-javax-inject-target

    LOCAL_JAVA_LIBRARIES := \
        ds-auto-value \

    # Libraries needed by the compiler (JACK) to generate code.
    PROCESSOR_LIBRARIES_TARGET := \
        ds-auto-value \
        ds-dagger2 \
        ds-dagger2-compiler \
        ds-dagger2-producers \
        ds-guava \
        ds-javax-annotation-api \
        ds-javax-inject \

    # Resolve the jar paths.
    PROCESSOR_JARS := $(call java-lib-deps, $(PROCESSOR_LIBRARIES_TARGET))
    # Necessary for annotation processors to work correctly.
    LOCAL_ADDITIONAL_DEPENDENCIES += $(PROCESSOR_JARS)

    LOCAL_JACK_FLAGS += --processorpath $(call normalize-path-list,$(PROCESSOR_JARS))
    LOCAL_JAVACFLAGS += -processorpath $(call normalize-path-list,$(PROCESSOR_JARS))



    LOCAL_CERTIFICATE := platform

    LOCAL_MODULE_TAGS := optional

    LOCAL_PRIVILEGED_MODULE := true


    LOCAL_USE_AAPT2 := true

    LOCAL_PROGUARD_ENABLED := disabled

    LOCAL_DEX_PREOPT := false

    LOCAL_AAPT_FLAGS := --auto-add-overlay
    LOCAL_AAPT_FLAGS += --extra-packages android.support.v7.appcompat:android.support.v7.gridlayout

    include $(BUILD_PACKAGE)


    # Create references to prebuilt libraries.
    include $(CLEAR_VARS)

    LOCAL_PREBUILT_STATIC_JAVA_LIBRARIES := \
        ds-auto-value:../../../prebuilts/tools/common/m2/repository/com/google/auto/value/auto-value/1.3/auto-value-1.3$(COMMON_JAVA_PACKAGE_SUFFIX) \
        ds-dagger2-compiler:../../../prebuilts/tools/common/m2/repository/com/google/dagger/dagger-compiler/2.7/dagger-compiler-2.7$(COMMON_JAVA_PACKAGE_SUFFIX) \
        ds-dagger2:../../../prebuilts/tools/common/m2/repository/com/google/dagger/dagger/2.7/dagger-2.7$(COMMON_JAVA_PACKAGE_SUFFIX) \
        ds-dagger2-producers:../../../prebuilts/tools/common/m2/repository/com/google/dagger/dagger-producers/2.7/dagger-producers-2.7$(COMMON_JAVA_PACKAGE_SUFFIX) \
        ds-guava:../../../prebuilts/tools/common/m2/repository/com/google/guava/guava/20.0/guava-20.0$(COMMON_JAVA_PACKAGE_SUFFIX) \
        ds-javax-annotation-api:../../../prebuilts/tools/common/m2/repository/javax/annotation/javax.annotation-api/1.2/javax.annotation-api-1.2$(COMMON_JAVA_PACKAGE_SUFFIX) \
        ds-javax-inject:../../../prebuilts/tools/common/m2/repository/javax/inject/javax.inject/1/javax.inject-1$(COMMON_JAVA_PACKAGE_SUFFIX)

    include $(BUILD_MULTI_PREBUILT)

    include $(CLEAR_VARS)

    LOCAL_MODULE_CLASS := JAVA_LIBRARIES
    LOCAL_MODULE := ds-guava-target
    LOCAL_SDK_VERSION := current
    LOCAL_SRC_FILES := ../../../prebuilts/tools/common/m2/repository/com/google/guava/guava/20.0/guava-20.0$(COMMON_JAVA_PACKAGE_SUFFIX)
    LOCAL_UNINSTALLABLE_MODULE := true

    include $(BUILD_PREBUILT)

    include $(CLEAR_VARS)

    LOCAL_MODULE_CLASS := JAVA_LIBRARIES
    LOCAL_MODULE := ds-dagger2-target
    LOCAL_SDK_VERSION := current
    LOCAL_SRC_FILES := ../../../prebuilts/tools/common/m2/repository/com/google/dagger/dagger/2.7/dagger-2.7$(COMMON_JAVA_PACKAGE_SUFFIX)
    LOCAL_UNINSTALLABLE_MODULE := true

    include $(BUILD_PREBUILT)

    include $(CLEAR_VARS)

    include $(CLEAR_VARS)

    LOCAL_MODULE_CLASS := JAVA_LIBRARIES
    LOCAL_MODULE := ds-javax-annotation-api-target
    LOCAL_SDK_VERSION := current
    LOCAL_SRC_FILES := ../../../prebuilts/tools/common/m2/repository/javax/annotation/javax.annotation-api/1.2/javax.annotation-api-1.2$(COMMON_JAVA_PACKAGE_SUFFIX)
    LOCAL_UNINSTALLABLE_MODULE := true

    include $(BUILD_PREBUILT)

    include $(CLEAR_VARS)

    LOCAL_MODULE_CLASS := JAVA_LIBRARIES
    LOCAL_MODULE := ds-javax-inject-target
    LOCAL_SDK_VERSION := current
    LOCAL_SRC_FILES := ../../../prebuilts/tools/common/m2/repository/javax/inject/javax.inject/1/javax.inject-1$(COMMON_JAVA_PACKAGE_SUFFIX)
    LOCAL_UNINSTALLABLE_MODULE := true

    include $(BUILD_PREBUILT)
Brainwash answered 13/6, 2018 at 6:19 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.