我的Android Studio项目用于构建更快,但现在需要很长时间才能构建.可能导致延误的任何想法?我试过/sf/answers/1902031491/但没有效果.我没有运行可能会中断构建的Anti病毒.我的应用程序也不是那么大(大约5MB),它曾经在几秒钟内构建,但不确定发生了什么变化.
10:03:51 Gradle build finished in 4 min 0 sec
10:04:03 Session 'app': running
10:10:11 Gradle build finished in 3 min 29 sec
10:10:12 Session 'app': running
10:20:24 Gradle build finished in 3 min 42 sec
10:28:18 Gradle build finished in 3 min 40 sec
10:28:19 Session 'app': running
10:31:14 Gradle build finished in 2 min 56 sec
10:31:14 Session 'app': running
10:38:37 Gradle build finished in 3 min 30 sec
10:42:17 Gradle …Run Code Online (Sandbox Code Playgroud) 我已经调查了一段时间,可能看到这里最流行的答案与aar和transitive依赖关系有关,但不知何故,我仍然不清楚如何使这个工作.
所以:
我有给定gradle配置的android库:
apply plugin: 'android-library'
apply plugin: 'android-maven'
version = "1.0.0"
group = "com.somepackage"
buildscript {
repositories {
mavenCentral()
mavenLocal()
}
dependencies {
classpath 'com.github.dcendents:android-maven-plugin:1.0'
}
}
android {
compileSdkVersion 19
buildToolsVersion '19.0.3'
defaultConfig {
minSdkVersion 10
}
}
repositories {
maven { url 'http://www.bugsense.com/gradle/' }
}
dependencies {
provided 'com.google.android.gms:play-services:+'
provided 'com.android.support:appcompat-v7:+'
compile 'com.google.code.gson:gson:2.2.4'
compile 'com.bugsense.trace:bugsense:3.6'
compile 'commons-net:commons-net:3.3'
}
Run Code Online (Sandbox Code Playgroud)
然后我将它部署到本地maven repo gradle install.部署库的POM文件如下所示:
<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<groupId>com.sprezzat</groupId> …Run Code Online (Sandbox Code Playgroud) 我使用com.android.tools.build:gradle:3.1.1了最新版本的摇篮(https://services.gradle.org/distributions-snapshots/gradle-4.8-20180417000132+0000-all.zip).
当我使用compileOnly依赖时,其中一些不会编译,有些会.例如
compileOnly "com.android.support:support-v4:27.1.1"
Run Code Online (Sandbox Code Playgroud)
完美的工作
compileOnly "com.facebook.stetho:stetho:1.5.0"
Run Code Online (Sandbox Code Playgroud)
给出编译错误:
Android dependency 'com.facebook.stetho:stetho:1.5.0' is set to compileOnly/provided which is not supported
Run Code Online (Sandbox Code Playgroud)
我的印象比任何依赖都可以编译.没有其他说明(https://developer.android.com/studio/build/gradle-plugin-3-0-0-migration.html#new_configurations).这两个库都具有传递依赖性.
任何帮助将不胜感激.
我只使用crashlytics作为例子.
有什么区别
compile('com.crashlytics.sdk.android:crashlytics:2.6.8@aar') { transitive = true; }
Run Code Online (Sandbox Code Playgroud)
和
compile 'com.crashlytics.sdk.android:crashlytics:2.6.8'
Run Code Online (Sandbox Code Playgroud) android gradle crashlytics android-gradle-plugin crashlytics-android
我使用本指南将我的Android库(带有依赖项)发布到AWS S3 maven存储库.
在一个新项目中,我将S3存储桶添加为Maven存储库,如果我将以下内容添加到新项目的build.gradle文件中,我可以成功使用它:
implementation ('com.mydomain:my_library:1.4:release@aar') {
transitive=true
}
Run Code Online (Sandbox Code Playgroud)
("transitive = true"是必需的,以便包含库的依赖项.)
但是,我希望其他人能够使用我已经看过很多其他库的简化版本:
implementation 'com.mydomain:my_library:1.4'
Run Code Online (Sandbox Code Playgroud)
当我这样做,我得到"无法解析符号"在代码中的错误和(当然)得到"不存在"的错误,当我尝试建立我的项目.
我的图书馆的POM文件如下所示.有什么我可以在那里改变所以我可以使用上面的"简化"实现行,或者我还能做些什么呢?
注意:我尝试将"<packaging> pom </ packaging>"替换为"<packaging> aar </ packaging>",使缓存无效,然后再次运行,但行为完全相同.
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<groupId>com.mydomain</groupId>
<artifactId>my_library</artifactId>
<version>1.4</version>
<packaging>pom</packaging>
<dependencies>
<dependency>
<groupId>com.android.support</groupId>
<artifactId>appcompat-v7</artifactId>
<version>27.1.1</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.android.support.constraint</groupId>
<artifactId>constraint-layout</artifactId>
<version>1.1.3</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.android.support</groupId>
<artifactId>design</artifactId>
<version>27.1.1</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>io.reactivex.rxjava2</groupId>
<artifactId>rxandroid</artifactId>
<version>2.1.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>io.reactivex.rxjava2</groupId>
<artifactId>rxjava</artifactId>
<version>2.2.4</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.github.instacart.truetime-android</groupId>
<artifactId>library-extension-rx</artifactId>
<version>3.3</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.google.dagger</groupId>
<artifactId>dagger-android</artifactId>
<version>2.15</version> …Run Code Online (Sandbox Code Playgroud)