问题描述
我目前正在尝试模拟(然后构建)Android版的Ionic App(带有Angular).我觉得有必要通过说自己不是Android开发人员来作为开头,这是我第一次必须设置环境,因此对于任何明显的"错误或遗漏的步骤表示歉意./p>
我无法克服此错误(在运行 ionic cordova模拟android --debug --consolelogs
后出现):
构建失败总时间:0.794秒[11:12:25]棉绒在1.74秒内完成错误:/path/to/app/platforms/android/gradlew:命令失败,退出代码为1错误输出:失败:生成失败,发生异常.* 在哪里:构建文件"/path/to/app/platforms/android/build.gradle"行:24* 什么地方出了错:评估根项目"android"时发生问题.>无法从此列表中找到要调用的方法maven():公共抽象org.gradle.api.artifacts.repositories.MavenArtifactRepository org.gradle.api.artifacts.dsl.RepositoryHandler#maven(groovy.lang.Closure)公共抽象org.gradle.api.artifacts.repositories.MavenArtifactRepository org.gradle.api.artifacts.dsl.RepositoryHandler#maven(org.gradle.api.Action)
当我尝试构建项目或同步Gradle时,我在Android Studio中收到类似消息:
无法从此列表中找到要调用的方法maven():公共抽象org.gradle.api.artifacts.repositories.MavenArtifactRepository org.gradle.api.artifacts.dsl.RepositoryHandler#maven(groovy.lang.Closure)公共抽象org.gradle.api.artifacts.repositories.MavenArtifactRepository org.gradle.api.artifacts.dsl.RepositoryHandler#maven(org.gradle.api.Action)打开文件
我的 build.gradle
文件中失败的行如下所示:
buildscript {储存库{专家()<这里jcenter()谷歌 ()}//切换Android Gradle插件版本要求,具体取决于//已安装的Gradle版本.这种依赖关系记录在//http://tools.android.com/tech-docs/new-build-system/version-compatibility//和https://issues.apache.org/jira/browse/CB-8143依赖项{classpath'com.android.tools.build:gradle:4.7'}}
对于上下文,我有:
下载了Android Studio,JDK和SDK工具,以及(尝试进行故障排除)通过自制软件安装了Gradle和Maven.
在我的 .bash_profile
中添加了以下路径(并确认文件路径包含它们所说的内容,并带有匹配的版本):
export ANDROID_HOME = $ HOME/Library/Android/sdk`导出JAVA_HOME = $(/usr/libexec/java_home)出口JRE_HOME = $ JAVA_HOME/jre导出PATH = $ PATH:$ JAVA_HOME/bin:$ JRE_HOME/bin导出M2_HOME =/usr/local/Cellar/maven/3.5.3/libexec导出M2 = $ M2_HOME/bin导出PATH = $ PATH:$ M2_HOME/bin导出PATH = $ PATH:/opt/gradle/gradle-4.7/bin
通过CLI sdkmanager接受了所有许可条款
通过AVD管理器创建虚拟设备
运行 ionic信息
返回以下内容:
cli软件包:(/Users/katesowles/.node/lib/node_modules)@ ionic/cli-utils:1.19.2离子(离子CLI):3.20.0全局软件包:科尔多瓦(Cordova CLI):7.0.1本地套餐:@ ionic/app-scripts:1.3.0Cordova平台:android 6.2.3浏览器4.1.0 ios 4.5.4离子框架:离子角3.0.1系统:Android SDK工具:26.1.1ios部署:1.9.2节点:v8.7.0npm:5.4.2操作系统:macOS High SierraXcode:Xcode 9.3 Build版本9E145环境变量:ANDROID_HOME:/Users/katesowles/Library/Android/sdk其他:后端:专业
正在运行 mvn --version
返回
Apache Maven 3.5.3(3383c37e1f9e9b3bc3df5050c29c8aff9f295297; 2018-02-24T11:49:05-08:00)Maven主页:/usr/local/Cellar/maven/3.5.3/libexecJava版本:1.8.0_171,供应商:Oracle CorporationJava主页:/Library/Java/JavaVirtualMachines/jdk1.8.0_171.jdk/Contents/Home/jre默认语言环境:en_US,平台编码:UTF-8操作系统名称:"mac os x",版本:"10.13.4",拱门:"x86_64",家族:"mac"
运行 gradle --version
返回
------------------------------------------------------------摇篮4.7------------------------------------------------------------建立时间:2018-04-18 09:09:12 UTC修订:b9a962bf70638332300e7f810689cb2febbd4a6cGroovy:2.4.12Ant:2017年2月2日编译的Apache Ant(TM)版本1.9.9JVM:1.8.0_171(Oracle Corporation 25.171-b11)作业系统:Mac OS X 10.13.4 x86_64
非常感谢您寻求超越此范围的方法,并希望它能够完成成功的构建!
之后
apply插件:"com.android.application"
您应该添加以下内容:
存储库{mavenCentral()专家{网址"https://repository-achartengine.forge.cloudbees.com/snapshot/"}//这样的依赖关系.}
如果您的身份验证专家可以使用:
存储库{mavenCentral()专家{证书 {用户名xxx密码xxx}网址'http://mymaven/xxxx/repositories/releases/'}}
这很重要.
注意::您将需要在buildscript之外定义存储库.buildscript配置块仅为构建脚本的类路径设置存储库和依赖项,而不为应用程序设置.查看此
I am currently attempting to emulate (and then build) and Ionic App (w/ Angular) for Android. I feel the need to preface this by saying am not an Android developer, this is the first time I've had to set up the environment so I apologize for any "obvious" mistakes or missed steps.
I have been unable to get past this error (appears after running ionic cordova emulate android --debug --consolelogs
):
BUILD FAILED
Total time: 0.794 secs
[11:12:25] lint finished in 1.74 s
Error: /path/to/app/platforms/android/gradlew: Command failed with exit code 1 Error output:
FAILURE: Build failed with an exception.
* Where:
Build file '/path/to/app/platforms/android/build.gradle' line: 24
* What went wrong:
A problem occurred evaluating root project 'android'.
> Could not find which method maven() to invoke from this list:
public abstract org.gradle.api.artifacts.repositories.MavenArtifactRepository org.gradle.api.artifacts.dsl.RepositoryHandler#maven(groovy.lang.Closure)
public abstract org.gradle.api.artifacts.repositories.MavenArtifactRepository org.gradle.api.artifacts.dsl.RepositoryHandler#maven(org.gradle.api.Action)
I get a similar message within Android Studio when I attempt to Build my project or sync Gradle:
Could not find which method maven() to invoke from this list:
public abstract org.gradle.api.artifacts.repositories.MavenArtifactRepository org.gradle.api.artifacts.dsl.RepositoryHandler#maven(groovy.lang.Closure)
public abstract org.gradle.api.artifacts.repositories.MavenArtifactRepository org.gradle.api.artifacts.dsl.RepositoryHandler#maven(org.gradle.api.Action)
Open File
The line in my build.gradle
file that's failing looks like this:
buildscript {
repositories {
maven () < HERE
jcenter()
google ()
}
// Switch the Android Gradle plugin version requirement depending on the
// installed version of Gradle. This dependency is documented at
// http://tools.android.com/tech-docs/new-build-system/version-compatibility
// and https://issues.apache.org/jira/browse/CB-8143
dependencies {
classpath 'com.android.tools.build:gradle:4.7'
}
}
For context, I have:
Downloaded Android Studio, JDK, and the SDK Tools as well as (in trying to troubleshoot) installed Gradle and Maven via homebrew.
Added the following paths to my .bash_profile
(and confirmed that the file paths contain what they say they do, with matching versions):
export ANDROID_HOME=$HOME/Library/Android/sdk`
export JAVA_HOME=$(/usr/libexec/java_home)
export JRE_HOME=$JAVA_HOME/jre
export PATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/bin
export M2_HOME=/usr/local/Cellar/maven/3.5.3/libexec
export M2=$M2_HOME/bin
export PATH=$PATH:$M2_HOME/bin
export PATH=$PATH:/opt/gradle/gradle-4.7/bin
Accepted all license terms via the CLI sdkmanager
Created a Virtual Device via the AVD Manager
Running ionic info
returns the following:
cli packages: (/Users/katesowles/.node/lib/node_modules)
@ionic/cli-utils : 1.19.2
ionic (Ionic CLI) : 3.20.0
global packages:
cordova (Cordova CLI) : 7.0.1
local packages:
@ionic/app-scripts : 1.3.0
Cordova Platforms : android 6.2.3 browser 4.1.0 ios 4.5.4
Ionic Framework : ionic-angular 3.0.1
System:
Android SDK Tools : 26.1.1
ios-deploy : 1.9.2
Node : v8.7.0
npm : 5.4.2
OS : macOS High Sierra
Xcode : Xcode 9.3 Build version 9E145
Environment Variables:
ANDROID_HOME : /Users/katesowles/Library/Android/sdk
Misc:
backend : pro
Running mvn --version
returns
Apache Maven 3.5.3 (3383c37e1f9e9b3bc3df5050c29c8aff9f295297; 2018-02-24T11:49:05-08:00)
Maven home: /usr/local/Cellar/maven/3.5.3/libexec
Java version: 1.8.0_171, vendor: Oracle Corporation
Java home: /Library/Java/JavaVirtualMachines/jdk1.8.0_171.jdk/Contents/Home/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "mac os x", version: "10.13.4", arch: "x86_64", family: "mac"
Running gradle --version
returns
------------------------------------------------------------
Gradle 4.7
------------------------------------------------------------
Build time: 2018-04-18 09:09:12 UTC
Revision: b9a962bf70638332300e7f810689cb2febbd4a6c
Groovy: 2.4.12
Ant: Apache Ant(TM) version 1.9.9 compiled on February 2 2017
JVM: 1.8.0_171 (Oracle Corporation 25.171-b11)
OS: Mac OS X 10.13.4 x86_64
Any help in finding a way past this and to a completed, successful build would be SO greatly appreciated!
After
apply plugin: 'com.android.application'
You should add this:
repositories {
mavenCentral()
maven {
url "https://repository-achartengine.forge.cloudbees.com/snapshot/"
} // some dependency like this.
}
If you have a maven with authentication you can use:
repositories {
mavenCentral()
maven {
credentials {
username xxx
password xxx
}
url 'http://mymaven/xxxx/repositories/releases/'
}
}
It is important order.
Note : You will need to define the repository outside of buildscript. The buildscript configuration block only sets up the repositories and dependencies for the classpath of your build script but not your application. see this
这篇关于无法从此列表中找到要调用的方法maven():的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!