Android的新Jack编译器真的那么慢吗? [英] Is Androids new Jack compiler really that slow?

查看:188
本文介绍了Android的新Jack编译器真的那么慢吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的一些Android项目中,我发现自从使用新的Jack编译器以来,构建过程相当缓慢.我需要它来使用lambdas之类的Java 8功能.

但是漫长的建造时间有点令人不安.因此,我建立了一个新的Android项目.它仅包含一个带有一个按钮的MainActivity,该按钮会在您单击时做出反应.

package de.xappo.myapplication;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;

public class MainActivity extends AppCompatActivity {

    Button button;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        button = (Button) findViewById(R.id.button);
        button.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(final View view) {
                Toast.makeText(MainActivity.this, "Button clicked!", Toast.LENGTH_LONG).show();
            }
        });
    }
}

除了布局文件外,没有任何其他内容,该布局文件仅在RelativeLayout中包含一个TextViewButton.

如您在图片中所见,所有千斤顶任务加在一起大约需要75秒.这正常吗?这个无孔示例应用程序在没有插孔的情况下可以在不到22秒的时间内完成构建.那么,这种大差异正常吗?

我已经在gradle.properties文件中管理过Java堆大小:

org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8

还有什么事情可以改善杰克的编译性能吗?还是您知道在jack上计划进行任何更新以缩短构建时间?

解决方案

按照 retrolambda ./p>

On some of my Android projects I see that building got quite slow since using the new Jack compiler. I need it to use Java 8 features like lambdas.

But the long building time is a bit disturbing. So I set up a new Android project. It contains just a MainActivity with one button which reacts on your click.

package de.xappo.myapplication;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;

public class MainActivity extends AppCompatActivity {

    Button button;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        button = (Button) findViewById(R.id.button);
        button.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(final View view) {
                Toast.makeText(MainActivity.this, "Button clicked!", Toast.LENGTH_LONG).show();
            }
        });
    }
}

There is nothing else except from the layout file which just contains a a TextView and a Button within a RelativeLayout.

As you can see in the picture all the jack gradle tasks together take about 75 seconds. Is this normal? This hole example app builds in less than 22 seconds without jack. So is this big difference normal?

I already managed Java heap size within my gradle.properties file:

org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8

Is there still any thing to do to improve jack compiling performance? Or do you know about any updates planned on jack to improve building time?

解决方案

As per this announcement, the Jack toolchain on Android is deprecated and java8 support will be directly integrated into Android's standard javac and dx toolchain. I switched to Jack for java8 support, but then transitioned to retrolambda because Jack was so slow.

这篇关于Android的新Jack编译器真的那么慢吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆