[英]gradle failure - command line
I am trying to create and build an android project with command line tools only (on win7). 我正在尝试仅使用命令行工具(在win7上)创建和构建android项目。
so far i succeeded in creating an app and building it with gradle via command line. 到目前为止,我成功创建了一个应用程序,并通过命令行使用gradle进行了构建。 but i needed to use an external library in my app, named objectbox .
但是我需要在我的应用程序中使用一个名为objectbox的外部库。 after using its classes i am getting gradle error and dont know how to resolve it.
使用其类后,我得到gradle错误,不知道如何解决它。 i got the debug level messages from gradle with this command:
我使用以下命令从gradle获取了调试级别消息:
gradlew assemble --debug
and seems the relevant part that the problem lies starts from this: 似乎问题所在的相关部分从此开始:
01:15:27.177 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.ivyresolve.CachingModuleVersionRepository] Detected non-existence of artifact 'com.squareup.okio:okio:1.11.0:okio.jar' in resolver cache 01:15:27.177 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.ivyresolve.CachingModuleVersionRepository]在解析器中检测到工件'com.squareup.okio:okio:1.11.0:okio.jar'不存在快取
i found the template of resolver cache from a healthy entry like this: 我从像这样的健康条目中找到了解析器缓存模板:
01:15:27.177 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.ivyresolve.CachingModuleVersionRepository] Found artifact 'com.google.code.findbugs:jsr305:3.0.2:jsr305.jar' in resolver cache: C:\\Users\\User.gradle\\caches\\modules-2\\files-2.1\\com.google.code.findbugs\\jsr305\\3.0.2\\25ea2e8b0c338a877313bd4672d3fe056ea78f0d\\jsr305-3.0.2.jar 01:15:27.177 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.ivyresolve.CachingModuleVersionRepository]在解析器缓存中找到工件'com.google.code.findbugs:jsr305:3.0.2:jsr305.jar': C:\\ Users \\ User.gradle \\ caches \\ modules-2 \\ files-2.1 \\ com.google.code.findbugs \\ jsr305 \\ 3.0.2 \\ 25ea2e8b0c338a877313bd4672d3fe056ea78f0d \\ jsr305-3.0.2.jar
and found okio-1.11.0.jar at this path: 并在以下路径中找到okio-1.11.0.jar:
C:\\Users\\User.gradle\\caches\\modules-2\\files-2.1\\com.squareup.okio\\okio\\1.11.0\\840897fcd7223a8143f1d9b6f69714e7be34fd50 C:\\ Users \\ User.gradle \\ caches \\ modules-2 \\ files-2.1 \\ com.squareup.okio \\ okio \\ 1.11.0 \\ 840897fcd7223a8143f1d9b6f69714e7be34fd50
plus some other relevant dirs and files too. 再加上其他一些相关的目录和文件。
I made some changes and tests, but no success. 我做了一些更改和测试,但没有成功。 please help me find the possible cause and solve this last problem.
请帮助我找到可能的原因并解决最后一个问题。
and this is the contents of my build.gradle: 这是我的build.gradle的内容:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.11.+'
}
}
apply plugin: 'android'
android {
compileSdkVersion 'android-16'
buildToolsVersion '26.0.1'
buildTypes {
release {
runProguard false
proguardFile getDefaultProguardFile('proguard-android.txt')
}
}
}
//=======================================================
dependencies {
compile fileTree(dir: 'libs', include: '*.jar')
}
buildscript {
ext.objectboxVersion = '1.0.1' // check for latest version
repositories {
jcenter()
maven { url "http://objectbox.net/beta-repo/" }
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.3'
classpath "io.objectbox:objectbox-gradle-plugin:$objectboxVersion"
}
}
allprojects {
repositories {
jcenter()
maven { url "http://objectbox.net/beta-repo/" }
}
}
//==============
apply plugin: 'com.android.application'
apply plugin: 'io.objectbox'
seems finally i overcame the problem. 似乎终于我克服了这个问题。
first i created an android gradle project with this command executed in an empty folder: 首先,我用一个在空文件夹中执行的命令创建了一个android gradle项目:
android create project --gradle --gradle-version 2.3.0 --activity Main --package me_at_gmail_dot_com.myprojectname --target 1 --path .
this is my working build.gradle file: 这是我的工作build.gradle文件:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.0'
}
}
apply plugin: 'android'
android {
compileSdkVersion 'android-16'
buildToolsVersion '26.0.1'
buildTypes {
release {
minifyEnabled false
proguardFile getDefaultProguardFile('proguard-android.txt')
}
}
}
/*dependencies {
compile fileTree(dir: 'libs', include: '*.jar')
}*/
//===============================================
buildscript {
ext.objectboxVersion = '1.0.1' // check for latest version
repositories {
jcenter()
maven { url "http://objectbox.net/beta-repo/" }
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.0'
classpath "io.objectbox:objectbox-gradle-plugin:$objectboxVersion"
}
}
allprojects {
repositories {
jcenter()
maven { url "http://objectbox.net/beta-repo/" }
}
}
//=============
apply plugin: 'com.android.application'
apply plugin: 'io.objectbox'
I used android gradle plugin v2.3.0 because seemed it was the highest version available in the defined repository; 我使用了android gradle插件v2.3.0,因为它似乎是已定义存储库中可用的最高版本; with v2.3.3 i was getting a vague error, then i went to the repo to see if it actually exists.
在v2.3.3中,我收到了一个模糊的错误,然后我去了仓库查看它是否确实存在。
also u see i commented out my libs folder, because i was getting an error about a library name conflict, so i guessed it is the cause, and seems there was no need to objectbox jars that i had put there (i had built them beforehand). 您还看到我注释了我的libs文件夹,因为我遇到有关库名冲突的错误,所以我猜想是原因,而且似乎不需要将我放在那里的对象箱罐(我已经预先构建了它们) )。
another thing: i changed runProguard false to minifyEnabled false (see this: https://stackoverflow.com/a/27387994/2982512 ) 另一件事:我将runProguard false更改为minifyEnabled false (请参阅: https : //stackoverflow.com/a/27387994/2982512 )
and this is my gradle-wrapper.properties: 这是我的gradle-wrapper.properties:
#Wed Apr 10 15:27:10 PDT 2013
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=http\://services.gradle.org/distributions/gradle-3.3-all.zip
i changed only the last line in accordance with android gradle plugin version (see this: https://developer.android.com/studio/releases/gradle-plugin.html#updating-gradle ) 我仅根据android gradle插件版本更改了最后一行(请参阅: https : //developer.android.com/studio/releases/gradle-plugin.html#updating-gradle )
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.