react-native run-android 问题(mac)
react-native run-android 一些问题问题1: error Failed to launch emulator. Reason: No emulators found as an output of emulator -list-avds.解决:确保装了android sdk ,你需要能找到目录,比如在mac上cd~/Library/Android/sdk可以看到这些文件确保环
react-native run-android 一些问题
- 问题1: error Failed to launch emulator. Reason: No emulators found as an output of
emulator -list-avds
.
解决:
- 确保装了android sdk ,你需要能找到目录,比如在mac上
可以看到这些文件cd ~/Library/Android/sdk
- 确保环境变量正确
vim ~/.bash_profile
# 打开.bash_profile 文件,里面有以下这些环境变量导出.确保正确可以通过
# echo $ANDROID_HOME/tools 查看路径是否正确,如果报错请检查
export ANDROID_HOME=~/Library/Android/sdk
export PATH=$ANDROID_HOME/tools:$PATH
export PATH=$ANDROID_HOME/tools/bin:$PATH
export PATH=$ANDROID_HOME/platform-tools:$PATH
export PATH=$ANDROID_HOME/emulator:$PATH
- 如果以上都对,则 通过安装
android-platform-tools
brew install android-platform-tools
以上三步可解决error Failed to launch emulator. Reason: No emulators found as an output of emulator -list-avds
的问题
-
问题2: Could not initialize class org.codehaus.groovy.runtime.InvokerHelper
解决: 查看java jdk版本 ,终端输入java -version
目标java jdk 版本要1.8以上去官网找1.8版本!
这个是jdk下载地址,需要登录才能下载:https://www.oracle.com/java/technologies/javase/javase-jdk8-downloads.html
通常是jdk版本过低,可以参照以下进行安装,并配置
https://blog.csdn.net/deliciousion/article/details/78046007
配置好之后,问题解决 -
问题3:
* What went wrong:
A problem occurred configuring root project 'proger'.
> Could not resolve all artifacts for configuration ':classpath'.
> Could not resolve org.ow2.asm:asm:6.0.
Required by:
project : > com.android.tools.build:gradle:3.5.3
project : > com.android.tools.build:gradle:3.5.3 > com.android.tools.build:builder:3.5.3
解决:
buildscript {
ext {
buildToolsVersion = "29.0.2"
minSdkVersion = 16
compileSdkVersion = 29
targetSdkVersion = 29
}
repositories {
google()
jcenter()
maven {
url 'https://maven.google.com/'
name 'Google'
}
}
dependencies {
classpath("com.android.tools.build:gradle:3.3.2")
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
修改为以下,为buildscript
添加上了这段maven编译地址
maven {
url 'https://maven.google.com/'
name 'Google'
}
修改完后为:
buildscript {
ext {
buildToolsVersion = "29.0.2"
minSdkVersion = 16
compileSdkVersion = 29
targetSdkVersion = 29
}
repositories {
google()
jcenter()
maven {
url 'https://maven.google.com/'
name 'Google'
}
}
dependencies {
classpath("com.android.tools.build:gradle:3.3.2")
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
- 问题5:
* What went wrong:
A problem occurred configuring project ':app'.
> Failed to notify project evaluation listener.
> org.gradle.api.file.ProjectLayout.directoryProperty(Lorg/gradle/api/provider/Provider;)Lorg/gradle/api/file/DirectoryProperty;
解决:
通过清除Gradle缓存
rm -rf ~/.gradle/caches && ./gradlew --stop && ./gradlew cleanBuildCache && ./gradlew bundleRelease
如果不能解决 ,尝试 方法2:
For everyone cloning that project, with Android studio 4, I needed to :
Change Android Gradle project version from 3.3.2 to 4.01 : https://stackoverflow.com/a/63206864
Error was Unable to find method 'org.gradle.api.file.ProjectLayout.directoryProperty(Lorg/gradle/api/provider/Provider;)Lorg/gradle/api/file/DirectoryProperty;'.
Create gradle.properties in root project folder with : android.useAndroidX=true
Error was This project uses AndroidX dependencies, but the 'android.useAndroidX' property is not enabled. Set this property to true in the gradle.properties file and retry.
注意 ⚠️ 千万要重装弄node_modules
更多推荐
所有评论(0)