Re: How to build intermediate classes.jar

已查看 7,512 次
跳至第一个未读帖子

KYUNG HO KIM

未读,
2016年4月20日 22:48:032016/4/20
收件人 Android Building
I'v found out that classes.jar has been made after build all android with "make -j<number>".
Before android-m, I can make classes.jar with just "mm" on library folder.
Thanks.

2016년 4월 19일 화요일 오후 12시 46분 45초 UTC+9, KYUNG HO KIM 님의 말:
Hi,

I used the classes.jar in intermediate folder for developing some applications on eclipse that including below static or shared java library. (eg. test, test2 lib)
The library used the android.mk, below.
But after I using android-M source, there's no classes.jar file in intermediate folder.

How can I build the classes.jar as before?
Or how I can I build the jar file including class files when we build the static or shared java library on android build to use on eclipse or other java IDE??



Android.mk
LOCAL_PATH:= $(call my-dir)


include $(CLEAR_VARS)
LOCAL_MODULE := test
LOCAL_MODULE_TAGS := optional
LOCAL_SRC_FILES := $(call all-java-files-under, src)
include $(BUILD_JAVA_LIBRARY)

include $(call all-makefiles-under,$(LOCAL_PATH))

LOCAL_PATH:= $(call my-dir)


include $(CLEAR_VARS)
LOCAL_MODULE := test2
LOCAL_MODULE_TAGS := optional
LOCAL_SRC_FILES := $(call all-java-files-under, src)
include $(BUILD_STATIC_JAVA_LIBRARY)

include $(call all-makefiles-under,$(LOCAL_PATH))



Thanks,
Casper










Anushree Ganjam

未读,
2016年9月8日 10:42:032016/9/8
收件人 Android Building
Hi,
Even I am facing the same issue. Were you able to solve it ?
Please help 

Jiyong Park

未读,
2016年9月20日 10:26:352016/9/20
收件人 Android Building
From Android-M, the default compiler for java source code is changed from javac to jack. As explained in https://source.android.com/source/jack.html, jack does not generate the intermediate classes.jar files. It directly generates classes.dex files from *.java files.

Furthermore, using such intermediate files (such as classes.jar) is not a very good idea. As an app developer, you should depend on SDK/NDK only.

pingkai pang

未读,
2016年12月1日 10:22:432016/12/1
收件人 Android Building
Hi Jiyong,

Same issue.

My I ask how we can build our own static library and share with others?
In Android N, only generate .jack file, not classes.jar?

Deepak Garg

未读,
2017年1月25日 11:58:122017/1/25
收件人 Android Building
in Android M, you can achieve that by using LOCAL_JACK_ENABLED = disabled variable in your makefile.

In Android N it is more tricky...it is broken and the solution to this is yet to come in AOSP mainline of Android N.
Solution is available in master.

Checked in 7.1.1 Android N.

You need to make use of javac-check target. This has been implemented for this purpose.

make javac-check-$(LOCAL_MODULE)

So, if your module name is "ABCD"

make javac-check-ABCD

This generates a classes-full-debug.jar, in the common\obj\JAVA_LIBRARIES\ABCD_intermediates.

This is the jar which you can use in your Studio environment.

Most important, this solution is not yet visible in any of the tags on Android N branch. It is part of the master hence you need to add this solution to your branch manually.



On Thursday, April 21, 2016 at 8:18:03 AM UTC+5:30, KYUNG HO KIM wrote:

杜宏羽

未读,
2017年8月14日 12:50:382017/8/14
收件人 Android Building
Thank you, I have solved the problem.but how can i get release version class.jar file?

在 2017年1月26日星期四 UTC+8上午12:58:12,Deepak Garg写道:

Vamsee Krishnaa

未读,
2019年2月11日 11:04:162019/2/11
收件人 Android Building


On Thursday, April 21, 2016 at 8:18:03 AM UTC+5:30, KYUNG HO KIM wrote:
Thanks.
[1/1] /home/vamsi/ctos/out/soong/.minibootstrap/minibp /home/vamsi/ctos/out/soong/.bootstrap/build.ninja
[55/56] glob prebuilts/ndk/stl.bp
[80/80] /home/vamsi/ctos/out/soong/.bootstrap/bin/soong_build /home/vamsi/ctos/out/soong/build.ninja
/home/vamsi/ctos/out/build-ctosp_hydrogen-cleanspec.ninja is missing, regenerating...
/home/vamsi/ctos/out/build-ctosp_hydrogen.ninja is missing, regenerating...
[535/951] including system/sepolicy/Android.mk ...
system/sepolicy/Android.mk:88: warning: Be careful when using the SELINUX_IGNORE_NEVERALLOWS flag. It does not work in user builds and using it will not stop you from failing CTS.
[951/951] including vendor/xiaomi/msm8956-common/Android.mk ...
build/make/core/Makefile:28: warning: overriding commands for target `/home/vamsi/ctos/out/target/product/hydrogen/system/framework/qcrilhook.jar'
build/make/core/base_rules.mk:412: warning: ignoring old commands for target `/home/vamsi/ctos/out/target/product/hydrogen/system/framework/qcrilhook.jar'
[ 99% 5300/5301] glob vendor/qcom/opensource/interfaces/display/config/1.6/src
ninja: error: '/home/vamsi/ctos/out/target/common/obj/JAVA_LIBRARIES/sap-api-java-static_intermediates/classes-header.jar', needed by '/home/vamsi/ctos/out/target/common/obj/APPS/Bluetooth_intermediates/classes-full-debug.jar', missing and no known rule to make it
12:22:20 ninja failed with: exit status 1

#### failed to build some targets (02:13 (mm:ss)) ####

having issue with missing sap-api-java-static_intermediates/classes-header.jar 

Vaibhav S

未读,
2022年1月19日 21:25:532022/1/19
收件人 Android Building
Perfect answer!!

For someone who's working with Android.bp files.
Use make javac-check-MODULE_NAME to generate the classes.jar.

And if you wanna use it in the Android.bp file, write a java_import module.
Eg.
java_import {
    name: "random_jar_name",
    jars: ["libs/classes.jar"], // You can rename classes.jar in case if you're importing multiple jars in your Android.bp
    sdk_version: "current",
    installable: false, // This is not really needed,
}

Now, use this java_import module's name inside static_libs list.
Eg.
static_libs: [
        "androidx.core_core",
        "random_jar_name",
    ],

That's it.
回复全部
回复作者
转发
0 个新帖子