我一直在研究React Native项目并为Android设备格式化它,而当我的虚拟设备在android studio中运行时,当我运行react-native run-android时遇到错误。
(node:6887) ExperimentalWarning: The fs.promises API is experimental
JS server already running.
Building and installing the app on the device (cd android && ./gradlew installDebug)...
这部分看起来像通常的输出
> Configure project :app
WARNING: Configuration 'compile' is obsolete and has been replaced with 'implementation' and 'api'.
It will be removed at the end of 2018. For more information see: http://d.android.com/r/tools/update-dependency-configurations.html
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:processDebugResources'.
> Android resource linking failed
Output: /Users/timothylowe/myApps/fulcrum/Fulcrum/android/app/build/intermediates/merged_manifests/debug/processDebugManifest/merged/AndroidManifest.xml:17: error: resource string/app_name (aka com.fulcrum:string/app_name) not found.
/Users/timothylowe/myApps/fulcrum/Fulcrum/android/app/build/intermediates/merged_manifests/debug/processDebugManifest/merged/AndroidManifest.xml:17: error: resource style/AppTheme (aka com.fulcrum:style/AppTheme) not found.
我认为这是我的问题所在,但除了重新启动机器外,我不确定从这里可以去哪里
error: failed processing manifest.
Command: /Users/timothylowe/.gradle/caches/transforms-1/files-1.1/aapt2-3.2.1-4818971-osx.jar/8a2fe804c00a7bb6586b8d1051c974fb/aapt2-3.2.1-4818971-osx/aapt2 link -I\
/Users/timothylowe/Library/Android/sdk/platforms/android-27/android.jar\
--manifest\
/Users/timothylowe/myApps/fulcrum/Fulcrum/android/app/build/intermediates/merged_manifests/debug/processDebugManifest/merged/AndroidManifest.xml\
-o\
/Users/timothylowe/myApps/fulcrum/Fulcrum/android/app/build/intermediates/processed_res/debug/processDebugResources/out/resources-debug.ap_\
-R\
@/Users/timothylowe/myApps/fulcrum/Fulcrum/android/app/build/intermediates/incremental/processDebugResources/resources-list-for-resources-debug.ap_.txt\
--auto-add-overlay\
--java\
/Users/timothylowe/myApps/fulcrum/Fulcrum/android/app/build/generated/not_namespaced_r_class_sources/debug/processDebugResources/r\
--custom-package\
com.fulcrum\
-0\
apk\
--output-text-symbols\
/Users/timothylowe/myApps/fulcrum/Fulcrum/android/app/build/intermediates/symbols/debug/R.txt\
--no-version-vectors
Daemon: AAPT2 aapt2-3.2.1-4818971-osx Daemon #0
Output: /Users/timothylowe/myApps/fulcrum/Fulcrum/android/app/build/intermediates/merged_manifests/debug/processDebugManifest/merged/AndroidManifest.xml:17: AAPT: error: resource string/app_name (aka com.fulcrum:string/app_name) not found.
/Users/timothylowe/myApps/fulcrum/Fulcrum/android/app/build/intermediates/merged_manifests/debug/processDebugManifest/merged/AndroidManifest.xml:17: AAPT: error: resource style/AppTheme (aka com.fulcrum:style/AppTheme) not found.
/Users/timothylowe/myApps/fulcrum/Fulcrum/android/app/build/intermediates/merged_manifests/debug/processDebugManifest/merged/AndroidManifest.xml:24: AAPT: error: resource string/app_name (aka com.fulcrum:string/app_name) not found.
error: failed processing manifest.
Command: /Users/timothylowe/.gradle/caches/transforms-1/files-1.1/aapt2-3.2.1-4818971-osx.jar/8a2fe804c00a7bb6586b8d1051c974fb/aapt2-3.2.1-4818971-osx/aapt2 link -I\
/Users/timothylowe/Library/Android/sdk/platforms/android-27/android.jar\
--manifest\
/Users/timothylowe/myApps/fulcrum/Fulcrum/android/app/build/intermediates/merged_manifests/debug/processDebugManifest/merged/AndroidManifest.xml\
-o\
/Users/timothylowe/myApps/fulcrum/Fulcrum/android/app/build/intermediates/processed_res/debug/processDebugResources/out/resources-debug.ap_\
-R\
@/Users/timothylowe/myApps/fulcrum/Fulcrum/android/app/build/intermediates/incremental/processDebugResources/resources-list-for-resources-debug.ap_.txt\
--auto-add-overlay\
--java\
/Users/timothylowe/myApps/fulcrum/Fulcrum/android/app/build/generated/not_namespaced_r_class_sources/debug/processDebugResources/r\
--custom-package\
com.fulcrum\
-0\
apk\
--output-text-symbols\
/Users/timothylowe/myApps/fulcrum/Fulcrum/android/app/build/intermediates/symbols/debug/R.txt\
--no-version-vectors
Daemon: AAPT2 aapt2-3.2.1-4818971-osx Daemon #0
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 1s
19 actionable tasks: 1 executed, 18 up-to-date
Could not install the app on the device, read the error above for details.
Make sure you have an Android emulator running or a device connected and have
set up your Android development environment:
https://facebook.github.io/react-native/docs/getting-started.html
不知道我需要做什么才能使其运行。
当我运行react-native run-ios时一切正常
我的Build.gradle(Project)文件看起来像这样
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext {
buildToolsVersion = "27.0.3"
minSdkVersion = 16
compileSdkVersion = 27
targetSdkVersion = 26
supportLibVersion = "27.1.1"
}
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
mavenLocal()
google()
jcenter()
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url "$rootDir/../node_modules/react-native/android"
}
}
}
task wrapper(type: Wrapper) {
gradleVersion = '4.4'
distributionUrl = distributionUrl.replace("bin", "all")
}
My build.gradle(Module:app)looks like this:
apply plugin: "com.android.application"
import com.android.build.OutputFile
/**
* The react.gradle file registers a task for each build variant (e.g. bundleDebugJsAndAssets
* and bundleReleaseJsAndAssets).
* These basically call `react-native bundle` with the correct arguments during the Android build
* cycle. By default, bundleDebugJsAndAssets is skipped, as in debug/dev mode we prefer to load the
* bundle directly from the development server. Below you can see all the possible configurations
* and their defaults. If you decide to add a configuration block, make sure to add it before the
* `apply from: "../../node_modules/react-native/react.gradle"` line.
*
* project.ext.react = [
* // the name of the generated asset file containing your JS bundle
* bundleAssetName: "index.android.bundle",
*
* // the entry file for bundle generation
* entryFile: "index.android.js",
*
* // whether to bundle JS and assets in debug mode
* bundleInDebug: false,
*
* // whether to bundle JS and assets in release mode
* bundleInRelease: true,
*
* // whether to bundle JS and assets in another build variant (if configured).
* // See http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Build-Variants
* // The configuration property can be in the following formats
* // 'bundleIn${productFlavor}${buildType}'
* // 'bundleIn${buildType}'
* // bundleInFreeDebug: true,
* // bundleInPaidRelease: true,
* // bundleInBeta: true,
*
* // whether to disable dev mode in custom build variants (by default only disabled in release)
* // for example: to disable dev mode in the staging build type (if configured)
* devDisabledInStaging: true,
* // The configuration property can be in the following formats
* // 'devDisabledIn${productFlavor}${buildType}'
* // 'devDisabledIn${buildType}'
*
* // the root of your project, i.e. where "package.json" lives
* root: "../../",
*
* // where to put the JS bundle asset in debug mode
* jsBundleDirDebug: "$buildDir/intermediates/assets/debug",
*
* // where to put the JS bundle asset in release mode
* jsBundleDirRelease: "$buildDir/intermediates/assets/release",
*
* // where to put drawable resources / React Native assets, e.g. the ones you use via
* // require('./image.png')), in debug mode
* resourcesDirDebug: "$buildDir/intermediates/res/merged/debug",
*
* // where to put drawable resources / React Native assets, e.g. the ones you use via
* // require('./image.png')), in release mode
* resourcesDirRelease: "$buildDir/intermediates/res/merged/release",
*
* // by default the gradle tasks are skipped if none of the JS files or assets change; this means
* // that we don't look at files in android/ or ios/ to determine whether the tasks are up to
* // date; if you have any other folders that you want to ignore for performance reasons (gradle
* // indexes the entire tree), add them here. Alternatively, if you have JS files in android/
* // for example, you might want to remove it from here.
* inputExcludes: ["android/**", "ios/**"],
*
* // override which node gets called and with what additional arguments
* nodeExecutableAndArgs: ["node"],
*
* // supply additional arguments to the packager
* extraPackagerArgs: []
* ]
*/
project.ext.react = [
entryFile: "index.js"
]
apply from: "../../node_modules/react-native/react.gradle"
/**
* Set this to true to create two separate APKs instead of one:
* - An APK that only works on ARM devices
* - An APK that only works on x86 devices
* The advantage is the size of the APK is reduced by about 4MB.
* Upload all the APKs to the Play Store and people will download
* the correct one based on the CPU architecture of their device.
*/
def enableSeparateBuildPerCPUArchitecture = false
/**
* Run Proguard to shrink the Java bytecode in release builds.
*/
def enableProguardInReleaseBuilds = false
android {
compileSdkVersion rootProject.ext.compileSdkVersion
buildToolsVersion '28.0.3'
defaultConfig {
applicationId "com.fulcrum"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
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 are e.g. debug, release
applicationVariants.all { variant ->
variant.outputs.each { output ->
// For each separate APK per architecture, set a unique version code as described here:
// http://tools.android.com/tech-docs/new-build-system/user-guide/apk-splits
def versionCodes = ["armeabi-v7a":1, "x86":2]
def abi = output.getFilter(OutputFile.ABI)
if (abi != null) { // null for the universal-debug, universal-release variants
output.versionCodeOverride =
versionCodes.get(abi) * 1048576 + defaultConfig.versionCode
}
}
}
}
dependencies {
compile project(':react-native-linear-gradient')
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation "com.android.support:appcompat- v7:${rootProject.ext.supportLibVersion}"
implementation "com.facebook.react:react-native:+" // From node_modules
}
// Run this once to be able to run the application with BUCK
// puts all compile dependencies into folder libs for BUCK to use
task copyDownloadableDepsToLibs(type: Copy) {
from configurations.compile
into 'libs'
}