Jack Server--Android N AOSP编译--Failed to contact Jack server

Preparation

Today , I am officially responsible for the development and maintenance of the Android7.0(N) project module. I took this opportunity to git and make a set of system codes for research. During the compilation process, the Android7.0 system compilation tool chain uses a new Jack server to replace the previous compiler tools, which is different from the previous system, so there may be some small problems in the compilation process, which will be summarized later for you. introduce!
Jack server
1. Introduction
Let 's take a look at the official introduction of Jack server:
  Jack is a new Android toolchain that compiles Java source into Android dex bytecode. It replaces the previous Android toolchain, which consists of multiple tools, such as javac, ProGuard, jarjar, and dx.
Jack compiler tools is a new set of Android compiler tools used to convert Java code to Android dex byte code.
Second, Jack server advantages
1. It is suitable for AOSP, which means that this compiler is open source, and developers can also improve it.
2. Jack server can reduce compilation time
3. Use of third-party packages such as ProGuard will no longer be necessary.
Write picture description here
3. Introduction of .jack library file
Jack has its own file format, namely: .jack. This file contains some library files for pre-compiled dex code, making the pre-compilation process faster.
Write a picture description here
4. Jill tool
As you can see from the official introduction, Jill is still before the Jack compiler, and its use is to convert the existing .jar library into a new format. The library file format Jayce uses Adapter compiler Jack.
Write a picture description here
5. Jack compilation (focus)

After we understand the new feature of Jack server in Android 7.0, we can use Jack to compile our system.

Write a picture description here As shown in the

figure , we open the .jack file in the $HOME path and see the following parameters:

SERVER=true to open the jack server.

SERVER_PORT_SERVICE=8072 to set the TCP server port number for assembly and compilation

SERVER_PORT_ADMIN=8073 to set the TCP The server port number is used for the administrator's compilation management

SERVER_COUNT=1 Currently unused, generally default

SERVER_NB_COMPILE=4 Simultaneously compile the maximum thread

SERVER_TIMEOUT=60 If the server does not respond within 60s, then this service will be turned off

SERVER_LOG=${ SERVER_LOG:=$SERVER_DIR/jack-$SERVER_PORT_SERVICE.log} Log output location

JACK_VM_COMMAND=${JACK_VM_COMMAND:=java}


Problems encountered when starting the JVM command Jack compilation—Failed to contact Jack server

如果你在编译的过程中,出现了如下的问题:

warning: string 'bluetooth_map_email_settings_app_icon' has no default translation.
warning: string 'bluetooth_map_email_settings_cancel' has no default translation.
warning: string 'bluetooth_map_email_settings_count' has no default translation.
warning: string 'bluetooth_map_email_settings_intro' has no default translation.
warning: string 'bluetooth_map_email_settings_no_account_slots_left' has no default translation.
warning: string 'bluetooth_map_email_settings_save' has no default translation.
warning: string 'bluetooth_map_email_settings_title' has no default translation.
warning: string 'bluetooth_share_file_name' has no default translation.
warning: string 'incoming_file_confirm_Notification_caption' has no default translation.
warning: string 'incoming_file_toast_msg' has no default translation.
warning: string 'map_acceptance_timeout_message' has no default translation.
warning: string 'map_auth_notif_message' has no default translation.
warning: string 'map_auth_notif_ticker' has no default translation.
warning: string 'map_auth_notif_title' has no default translation.
warning: string 'map_authentication_timeout_message' has no default translation.
warning: string 'map_defaultname' has no default translation.
warning: string 'map_defaultnumber' has no default translation.
warning: string 'map_localPhoneName' has no default translation.
warning: string 'map_session_key_dialog_header' has no default translation.
warning: string 'map_session_key_dialog_title' has no default translation.
warning: string 'map_unknownName' has no default translation.
warning: string 'noti_caption' has no default translation.
warning: string 'permdesc_handoverStatus' has no default translation.
warning: string 'permlab_handoverStatus' has no default translation.
warning: string 'process' has no default translation.
warning: string 'sharedUserId' has no default translation.
[ 33% 13407/40165] Aidl: mediatek-framework <= vendor/mediatek/proprietary/frameworks/base/camera/mmsdk/java/com/mediatek/mmsdk/IMMSdkService.aidl
[ 33% 13408/40165] Aidl: mediatek-framework <= vendor/mediatek/proprietary/frameworks/base/camera/mmsdk/java/com/mediatek/mmsdk/IFeatureManager.aidl
[ 33% 13409/40165] Aidl: mediatek-framework <= vendor/mediatek/proprietary/frameworks/base/camera/mmsdk/java/com/mediatek/mmsdk/IEffectFactory.aidl
[ 33% 13410/40165] Aidl: mediatek-framework <= vendor/mediatek/proprietary/frameworks/base/camera/mmsdk/java/com/mediatek/mmsdk/IEffectHalClient.aidl
[ 33% 13411/40165] Aidl: mediatek-framework <= vendor/mediatek/proprietary/frameworks/base/camera/mmsdk/java/com/mediatek/mmsdk/IEffectHal.aidl
[ 33% 13412/40165] Aidl: mediatek-framework <= vendor/mediatek/proprietary/frameworks/base/camera/mmsdk/java/com/mediatek/mmsdk/IEffectListener.aidl
[ 33% 13413/40165] Protoc: out/target/common/obj/JAVA_LIBRARIES/sap-api-java-static_intermediates/src/proto/Proto.stamp <= hardware/ril/librilutils/proto/sap-api.proto
[ 33% 13414/40165] Aidl: android-support-v4 <= frameworks/support/v4/java/android/support/v4/media/session/IMediaSession.aidl
[ 33% 13415/40165] Aidl: android-support-v4 <= frameworks/support/v4/java/android/support/v4/os/IResultReceiver.aidl
[ 33% 13416/40165] Aidl: android-support-v4 <= frameworks/support/v4/java/android/support/v4/media/session/IMediaControllerCallback.aidl
[ 33% 13417/40165] Aidl: android-support-v4 <= frameworks/support/v4/java/android/support/v4/app/INotificationSideChannel.aidl
[ 33% 13418/40165] Export includes file:  -- out/target/product/tb6580p2_gmo512m_p/obj/SHARED_LIBRARIES/libja3m_intermediates/export_includes
[ 33% 13419/40165] Protoc: out/host/linux-x86/gen/STATIC_LIBRARIES/libaapt2_intermediates/proto/frameworks/base/tools/aapt2/Format.pb.cc <= frameworks/base/tools/aapt2/Format.proto
[ 33% 13420/40165] Updated header file out/host/linux-x86/gen/STATIC_LIBRARIES/libaapt2_intermediates/proto/frameworks/base/tools/aapt2/Format.pb.h.
[ 33% 13421/40165] Export includes file: out/host/linux-x86/gen/STATIC_LIBRARIES/libaapt2_intermediates/proto/frameworks/base/tools/aapt2/Format.pb.h -- out/host/linux-x86/obj/STATIC_LIBRARIES/libaapt2_intermediates/export_includes
[ 33% 13422/40165] Import includes file: out/host/linux-x86/obj/EXECUTABLES/aapt2_intermediates/import_includes
[ 33% 13423/40165] Ensure Jack server is installed and started
FAILED: /bin/bash -c "(prebuilts/sdk/tools/jack-admin install-server prebuilts/sdk/tools/jack-launcher.jar prebuilts/sdk/tools/jack-server-4.8.ALPHA.jar  2>&1 || (exit 0) ) && (JACK_SERVER_VM_ARGUMENTS=\"-Dfile.encoding=UTF-8 -XX:+TieredCompilation\" prebuilts/sdk/tools/jack-admin start-server 2>&1 || exit 0 ) && (prebuilts/sdk/tools/jack-admin update server prebuilts/sdk/tools/jack-server-4.8.ALPHA.jar 4.8.ALPHA 2>&1 || exit 0 ) && (prebuilts/sdk/tools/jack-admin update jack prebuilts/sdk/tools/jacks/jack-2.28.RELEASE.jar 2.28.RELEASE || exit 47; prebuilts/sdk/tools/jack-admin update jack prebuilts/sdk/tools/jacks/jack-3.36.CANDIDATE.jar 3.36.CANDIDATE || exit 47; prebuilts/sdk/tools/jack-admin update jack prebuilts/sdk/tools/jacks/jack-4.7.BETA.jar 4.7.BETA || exit 47 )"
Writing client settings in /home/user3/.jack-settings
Installing jack server in "/home/user3/.jack-server"
Communication error with Jack server (58), try 'jack-diagnose' or see Jack server log
Failed to contact Jack server: Problem reading /home/user3/.jack-server/client.pem. Try 'jack-diagnose'
Failed to contact Jack server: Problem reading /home/user3/.jack-server/client.pem. Try 'jack-diagnose'
[ 33% 13423/40165] host C++: aapt2 <= frameworks/base/tools/aapt2/Main.cpp
[ 33% 13423/40165] host C++: dexdump2 <= art/dexdump/dexdump.cc
[ 33% 13423/40165] Compiling SDK Stubs: out/target/common/obj/JAVA_LIBRARIES/android_stubs_current_intermediates/classes.jar
Note:Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
ninja: build stopped: subcommand failed.
make: *** [ninja_wrapper] Error 1

 

Attention! Here is the key to solving the problem:

Communication error with Jack server (58), try 'jack-diagnose' or see Jack server log

Failed to contact Jack server: Problem reading /home/user3/.jack-server/client.pem. Try 'jack-diagnose'

 
This problem is that in the new feature of Android N, the same used TCP port will be regarded as the only one, so two files need to be modified in this case. The specific steps are as follows:
1. Modify the .jack file under the $HOME path:
write the picture description here
2. Modify the .jack-settings file under the $HOME path:
write the picture description
here (Note: the TCP port numbers of the two files here It must be unused, and the port configuration of the two files must be the same!)
3.jack-admin kill-server
4.jack-admin uninstall-server
5.cd prebuilts/sdk/tools->touch jack
6.jack-admin restart-server

OK! You're done!


The above content is reproduced from: https://blog.csdn.net/xz10561/article/details/53886691

----------------------------------------------------------------------------------------------------------------------


background

Many people in development, pull down a new set of code will have the following errors:

1.Failed to contact Jack server;
2.No Jack Server running;//jack server 被kill

This is because Android 7.0 uses Jack to compile and does not support simultaneous online compilation by multiple people. There is a port occupancy problem.

Friends who don't understand Jack's compilation can read my blog:

http://blog.csdn.net/Simon_Crystin/article/details/62426402

Solution

The detailed solution is given below:

All we need to do is change the port.

Under normal circumstances, Android7.0 (N) compilation will fail three times. Compile once to generate a new file, and let's lead you to climb the pit.

The first compilation error:
a .jack-settings file will be generated in your root directory (hidden files, if you cannot find them in the root directory, please set them to show hidden files)

Enter the modified port:

gives the modified result:

write picture description here

There are two points to note here
: 1: The default two ports are 8076 and 8077, you change it to be different from others;
2: The port is set in the range of 0-65536, 0-1024 is best not to use, it is usually a familiar port

After the change is completed, you go to compile again, and an error will be reported at this time;

The second compilation error:
a config.properties file will be generated under .jack-server in the root directory to
give the modified result:
write picture description here

Note: The modification here should be consistent with the above.

After completing this step, and then continuing to compile, an error will be reported:
No Jack Server running;

At this time, execute ls-al in the .jack-server folder to
view the file permissions: as shown in the
figure:
write picture description here

We can see that the config.properties permission is rwx, which means readable, writable, and executable. We need to remove the x permission. As for why the x permission should be removed? The log in jack-server says very clearly:

config.properties must have permission rw ------- but have rwx------

write picture description here

Execute ls-al again to see that the modification is successful. (This is linux permission management, if you don't know it, you can learn it.)

Compile again, it should be successful.

Anyway, the solution for port occupancy is like this. You can see that you have reached the first step, just go to the next step.


The above content is reproduced from: https://blog.csdn.net/Simon_Crystin/article/details/70059457

-------------------------------------------------------------------------------------------------------------



The following is a personal summary:

1. Jack server is a unique compilation tool for Android N. When compiling the system source code, the make command will be used to start automatically. If there is no install, it will be installed.

2. The command tools of Jack server are in prebuilt/sdk/tools:

Go to the path where the script is located cd prebuilt/sdk/tools

安装Jack server:./jack-admin install-server jack-launcher.jar jack-server-4.8.ALPHA.jar

卸载Jack server:./jack-admin uninstall-server

Dynamic Jack server: ./jack-admin start-server

Kill the jack server process: ./jack-admin kill-server

3.install will automatically install in the .jack-server folder in the user's root directory, and automatically generate .jack and .jack-settings files. The files in .jack-server are as follows:


The two files in the red circle are generated after the Jack server is successfully started.

4. After an error related to the Jack server occurs, you can first go to the log, under .jack-server/logs/.

5. If it prompts Caused by: java.net.BindException: Address already in use, it means that the port is occupied. It is likely that other users in the same server have also started the Jack server, and the default TCP port used by the Jack server is the same. So at this time to change the port. The ports in the .jack, .jack-settings, and ./jack-server/config.properties mentioned earlier should be changed to the same ones.

6. The system used by multiple users must reconfigure the port using Jack-server. If not reconfigured, then when one is using, the other needs to ./jack-admin kill-server.

7. When compiling AOSP lower than 7.0, you need to kill the Jack server, that is, execute ./jack-admin kill-server, otherwise the compilation will report an error.


Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326088808&siteId=291194637