[英]Builds from Android Studio Windows start slower on device than builds from Android Studio Mac OS
I have an android project and up until a few weeks ago I worked on a macbook on it. 我有一个android项目,直到几周前我就在Macbook上工作。 The builds were starting instantly after Android Studio installed them on the device. 在Android Studio将其安装到设备上后,构建即刻开始。
After I've moved to a new windows laptop running the same version of Android Studio and JDK 8 I've noticed the builds start a lot slower. 当我转移到运行相同版本的Android Studio和JDK 8的新Windows笔记本电脑后,我注意到构建速度慢得多。 By that I mean that after AS has installed and ran the app, the app stays in a white screen for about 4-5 seconds on average (up to 15-20seconds) after the first activity runs. 我的意思是说,在AS安装并运行该应用程序之后,该应用程序在第一个活动运行后平均在白屏中停留约4-5秒(最多15-20秒)。
Videos: 影片:
Building on Mac OS: https://youtu.be/H55mfxOoBbM 在Mac OS上构建: https : //youtu.be/H55mfxOoBbM
Building on Windows: https://youtu.be/-7FphwiMvs8 在Windows上构建: https : //youtu.be/-7FphwiMvs8
It feels like when you're running in debug mode and it's waiting for the debug process to attach. 感觉就像当您在调试模式下运行时,它正在等待附加调试过程。 I don't remember if I changed the settings in my Android Studio on mac because I've been migrating the configs for over 3 years. 我不记得是否在Mac上的Android Studio中更改了设置,因为我已经迁移了3年以上的配置。
What do I have to do to fix this? 我必须怎么做才能解决此问题?
EDIT: My guess would be that the windows bulid triggers the jit compiler. 编辑:我的猜测将是Windows bulid触发jit编译器。
Android Studio 2.1.2 Android Studio 2.1.2
Java 1.8 u91 Java 1.8 u91
Project gradle file: 项目gradle文件:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.2'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
maven { url "https://jitpack.io" }
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Build gradle file: 构建gradle文件:
/*
* Gets the version name from the latest Git tag
*/
def getVersionName = { ->
def stdout = new ByteArrayOutputStream()
def command = 'git'
if (System.properties['os.name'].toLowerCase().contains('windows')) {
command = 'C:/Program Files/Git/cmd/git.exe'
}
exec {
commandLine command, 'describe', '--tags'
standardOutput = stdout
}
return stdout.toString().trim()
}
project.ext.versionPropsFile = file('version.properties')
def getBuildNumber() {
def Properties versionProps = new Properties()
versionProps.load(new FileInputStream(project.versionPropsFile))
def buildNumber = versionProps['artifactBuildNumber'].toInteger() + 1
versionProps['artifactBuildNumber'] = buildNumber.toString()
versionProps.store(versionPropsFile.newWriter(), null)
return buildNumber
}
def getReleaseVersionCode() {
def Properties versionProps = new Properties()
versionProps.load(new FileInputStream(project.versionPropsFile))
def code = versionProps['artifactReleaseVersionCode'].toInteger()
return code
}
def getDevVersionCode() {
def Properties versionProps = new Properties()
versionProps.load(new FileInputStream(project.versionPropsFile))
def code = versionProps['artifactDebugVersionCode'].toInteger()
return code
}
buildscript {
repositories {
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'io.fabric.tools:gradle:1.+'
}
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
repositories {
maven { url 'https://maven.fabric.io/public' }
}
android {
compileSdkVersion 24
buildToolsVersion "24.0.0"
defaultConfig {
applicationId "com.senic.nuimoapp"
minSdkVersion 18
targetSdkVersion 23
versionName getVersionName()
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
debug {
applicationIdSuffix ".debug"
versionNameSuffix "-" + getBuildNumber() + "-DEBUG"
}
}
productFlavors {
dev {
versionCode getDevVersionCode()
}
prod {
versionCode getReleaseVersionCode()
}
}
packagingOptions {
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/beans.xml'
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:24.0.0'
compile 'com.android.support:design:24.0.0'
compile 'com.android.support:support-v4:24.0.0'
compile 'com.android.support:recyclerview-v7:24.0.0'
compile 'com.google.android.gms:play-services-appindexing:9.2.0'
// View binder
compile 'com.jakewharton:butterknife:7.0.1'
// DB and ORM
compile 'com.j256.ormlite:ormlite-core:4.48'
compile 'com.j256.ormlite:ormlite-android:4.48'
// Json parser
compile 'org.immutables:gson:2.1.14'
// Nuimo sdk
compile 'com.senic:nuimo-android:0.5.1'
compile 'org.jetbrains.kotlin:kotlin-stdlib:1.0.0'
// compile project(':..:nuimo-android:nuimo')
// Bug tracker
compile('com.crashlytics.sdk.android:crashlytics:2.5.7@aar') {
transitive = true;
}
testCompile 'junit:junit:4.12'
// LIFX Lan SDK
compile 'com.github.getsenic:lifx-sdk-android:0.5.11@aar'
// Philips Hue SDK
compile files('libs/huelocalsdk.jar')
compile files('libs/huesdkresources.jar')
// OTA firmware update library
compile 'no.nordicsemi.android:dfu:0.6.3'
// Rest helper library
compile 'com.squareup.retrofit2:retrofit:2.1.0'
compile 'com.squareup.retrofit2:converter-gson:2.1.0'
// Upnp Library for Sonos or Raumfeld
compile files('libs/cling-core-2.1.0.jar')
compile files('libs/cling-support-2.1.0.jar')
compile files('libs/seamless-http-1.1.1.jar')
compile files('libs/seamless-util-1.1.1.jar')
compile files('libs/seamless-xml-1.1.1.jar')
compile 'org.eclipse.jetty:jetty-server:8.1.19.v20160209'
compile 'org.eclipse.jetty:jetty-client:8.1.19.v20160209'
compile 'org.eclipse.jetty:jetty-servlet:8.1.19.v20160209'
compile 'org.slf4j:slf4j-jdk14:1.7.20'
// Custom color picker (for Lifx and Philips Hue)
compile 'com.larswerkman:HoloColorPicker:1.5'
}
As per the 1st answer in this thread: https://code.google.com/p/android/issues/detail?id=215000#c1 按照该线程的第一个答案: https : //code.google.com/p/android/issues/detail?id=215000#c1
The culprit was... instant run . 罪魁祸首是…… 立即逃跑 。 Disabled it and it's just as fast as before. 禁用它,它和以前一样快。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.