Android 我在设置以前的react本机项目时发现错误?
我克隆了一个react原生项目和安装纱线,并运行npm安装命令。但当我运行react native run android时,终端会给我错误信息Android 我在设置以前的react本机项目时发现错误?,android,android-studio,react-native,bitbucket,react-native-android,Android,Android Studio,React Native,Bitbucket,React Native Android,我克隆了一个react原生项目和安装纱线,并运行npm安装命令。但当我运行react native run android时,终端会给我错误信息 :app:processDebugResources FAILED FAILURE: Build failed with an exception. * What went wrong: Execution failed for task ':app:processDebugResources'. > com.android.ide.comm
:app:processDebugResources FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:processDebugResources'.
> com.android.ide.common.process.ProcessException: Failed to execute aapt
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
下面是我的app/build.gradle文件
apply plugin: "com.android.application"
import com.android.build.OutputFile
project.ext.react = [
entryFile: "index.js"
]
apply from: "../../node_modules/react-native/react.gradle"
def enableSeparateBuildPerCPUArchitecture = false
def enableProguardInReleaseBuilds = false
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
applicationId "com.granite"
minSdkVersion 16
targetSdkVersion 22
versionCode 1
versionName "1.0"
ndk {
abiFilters "armeabi-v7a", "x86"
}
}
splits {
abi {
reset()
enable enableSeparateBuildPerCPUArchitecture
universalApk false // If true, also generate a universal APK
include "armeabi-v7a", "x86"
}
}
buildTypes {
release {
minifyEnabled enableProguardInReleaseBuilds
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
}
}
applicationVariants.all { variant ->
variant.outputs.each { output ->
if (abi != null) { // null for the universal-debug, universal-release variants
output.versionCodeOverride =
versionCodes.get(abi) * 1048576 + defaultConfig.versionCode
}
}
}
}
dependencies {
compile project(':react-native-blur')
compile project(':react-native-image-picker')
compile project(':instabug-reactnative')
compile project(':appcenter-crashes')
compile project(':appcenter-analytics')
compile project(':appcenter')
compile project(':react-native-text-input-mask')
compile project(':react-native-i18n')
compile project(':react-native-vector-icons')
compile fileTree(dir: "libs", include: ["*.jar"])
compile "com.android.support:appcompat-v7:23.0.1"
compile "com.facebook.react:react-native:+" // From node_modules
}
task copyDownloadableDepsToLibs(type: Copy) {
from configurations.compile
into 'libs'
}
我的npm和纱线安装是成功的。buildtools版本23.0.1我也将其更改为26.0.1,但这并不能解决错误
如何解决此问题???因此,假设npm和纱线安装成功(首先解决此处的问题) 这个工具有时很棘手,或者说有点脆弱。在大多数情况下,重新运行“react native run android”命令或重新启动并再次运行就足够了 或者检查buildTools的版本: 编辑1(参见注释)
你检查过它的版本是否正确吗? 您可以查看android sdk文件夹下的内容
check it in Powershell
cd $ENV:Android_home\build-tools
ls
(或导航到您的android文件夹(android\Sdk\build tools))
因此,您的buildToolsVersion必须匹配其中一个文件夹名称
对于“23.0.1”,文件([projectname]/android/app/build.gradle)
应该是这样的
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {......
我的npm和纱线安装是成功的。buildtools版本23.0.1我也将其更改为26.0.1,但这并不能解决错误,您是否检查了它的版本是否正确?您可以在Powershell cd$ENV:android\u home\build tools ls中查看android sdk文件夹下的内容(或导航到您的android文件夹(android\sdk\build tools)),因此您的buildtools版本必须匹配文件([projectname]/android/app/build.gradle)中“23.0.1”的一个文件夹名称应该看起来像这个android{compileSdkVersion 23 buildToolsVersion“23.0.1”defaultConfig{是的,我有签入sdk,我有很多文件夹,比如23.0.1、26.0.1等等。但是我的问题通过添加“multiDexEnabled true”解决了在app/build.gradle中…但我不知道问题是什么,如果你有超过64k个方法,那么这应该是个问题。根据:如果我能帮助你解决问题,我将非常感谢你提高费率或分数