我目前正在尝试为Android模拟(然后构建)和Ionic App(w / Angular)。我觉得有必要通过说而不是一个Android开发人员来说明这一点,这是我第一次设置环境所以我为任何“明显的”错误或错过的步骤道歉。 / p>
我无法解决此错误(在运行Router.js:100 Uncaught TypeError: Cannot read property 'Component' of undefined
at eval (Router.js:100)
at Object../node_modules/react-router/es/Router.js (client-2bb593ab57065d662f04.bundle.js:2713)
at r (client-2bb593ab57065d662f04.bundle.js:1)
at eval (MemoryRouter.js:10)
at Object../node_modules/react-router/es/MemoryRouter.js (client-2bb593ab57065d662f04.bundle.js:2697)
at r (client-2bb593ab57065d662f04.bundle.js:1)
at eval (index.js:2)
at Object../node_modules/react-router/es/index.js (client-2bb593ab57065d662f04.bundle.js:2725)
at r (client-2bb593ab57065d662f04.bundle.js:1)
at eval (index.jsx:15)
后显示):
ionic cordova emulate android --debug --consolelogs
当我尝试构建项目或同步Gradle时,我在Android Studio中收到类似的消息:
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)
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
文件中失败的行如下所示:
build.gradle
对于上下文,我有:
通过自制软件安装了Gradle和Maven,下载了Android Studio,JDK和SDK工具以及(尝试进行故障排除)。
为我的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'
}
}
添加了以下路径(并确认文件路径包含他们所说的内容以及匹配版本):
.bash_profile
通过CLI sdkmanager接受所有许可条款
通过AVD Manager创建虚拟设备
运行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
会返回以下内容:
ionic info
运行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
返回
mvn --version
运行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"
返回
gradle --version
任何帮助我找到一条经过这个过程以及完成的成功构建的方法都会非常感激!
答案 0 :(得分:0)
之后
apply plugin: 'com.android.application'
你应该添加:
repositories {
mavenCentral()
maven {
url "https://repository-achartengine.forge.cloudbees.com/snapshot/"
} // some dependency like this.
}
如果你有认证的maven,你可以使用:
repositories {
mavenCentral()
maven {
credentials {
username xxx
password xxx
}
url 'http://mymaven/xxxx/repositories/releases/'
}
}
这是重要的顺序。
注意:您需要在buildscript之外定义存储库。 buildscript配置块仅为构建脚本的类路径设置存储库和依赖项,但不为应用程序设置。 see this