运行 ./ gradlew assembleRelease 命令后遇到以下问题。在最新检查期间无法捕获任务':app:bundleReleaseJsAndAssets'属性'$ 1'的输入文件的快照。
无法列出'/Users/sateweb/Desktop/desktop/Prayer/WeR1Peace/node_modules/metro/node_modules/jest-haste-map/node_modules/.bin/sane'的内容。无法跟随符号链接。
我已经尝试删除并安装node_modules,还尝试清理build文件夹并重新构建。但是问题仍然存在。
我的android / build.gradle文件
buildscript {
repositories {
mavenCentral()
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.4'
classpath 'com.google.gms:google-services:3.2.1'
}
}
allprojects {
repositories {
mavenLocal()
google()
jcenter()
maven {
url "$rootDir/../node_modules/react-native/android"
}
}
}
task wrapper(type: Wrapper) {
gradleVersion = '4.4'
distributionUrl = distributionUrl.replace("bin", "all")
}
subprojects {
project.configurations.all {
resolutionStrategy.eachDependency { details ->
if (details.requested.group == 'com.android.support'
&& !details.requested.name.contains('multidex') ) {
details.useVersion "28.0.0"
}
}
}
}
我的android / 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 28
defaultConfig {
applicationId "com.wer1peace"
minSdkVersion 18
targetSdkVersion 28
versionCode 1
versionName "1.0"
ndk {
abiFilters "armeabi-v7a", "x86"
}
}
signingConfigs {
release {
if (project.hasProperty('MYAPP_RELEASE_STORE_FILE')) {
storeFile file(MYAPP_RELEASE_STORE_FILE)
storePassword MYAPP_RELEASE_STORE_PASSWORD
keyAlias MYAPP_RELEASE_KEY_ALIAS
keyPassword MYAPP_RELEASE_KEY_PASSWORD
}
}
}
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"
signingConfig signingConfigs.release
}
}
applicationVariants.all { variant ->
variant.outputs.each { output ->
def versionCodes = ["armeabi-v7a":1, "x86":2]
def abi = output.getFilter(OutputFile.ABI)
if (abi != null) {
output.versionCodeOverride =
versionCodes.get(abi) * 1048576 + defaultConfig.versionCode
}
}
}
}
dependencies {
compile(project(":react-native-google-signin")){
exclude group: "com.google.android.gms" // very important
}
compile project(':react-native-fbsdk')
compile project(':react-native-vector-icons')
compile project(':react-native-splash-screen')
compile project(':react-native-image-picker')
compile project(':react-native-gesture-handler')
compile project(':react-native-device-info')
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation "com.android.support:appcompat-v7:28.0.0"
implementation "com.facebook.react:react-native:+" // From node_modules
implementation 'com.facebook.android:facebook-android-sdk:[4,5)'
//Google Signin
implementation 'com.google.android.gms:play-services-auth:16.0.1' // should be at least 9.0.0
implementation project(':react-native-fbsdk')
implementation project(':react-native-vector-icons')
implementation project(':react-native-image-picker')
implementation project(':react-native-gesture-handler')
implementation project(':react-native-device-info')
implementation project(':react-native-splash-screen')
}
task copyDownloadableDepsToLibs(type: Copy) {
from configurations.compile
into 'libs'
}
apply plugin: 'com.google.gms.google-services'
我的package.json文件
{
"name": "app_name",
"version": "0.0.1",
"private": true,
"scripts": {
"start": "node node_modules/react-native/local-cli/cli.js start",
"test": "jest"
},
"dependencies": {
"apisauce": "^1.0.2",
"moment": "^2.24.0",
"native-base": "^2.12.1",
"q": "^1.5.1",
"react": "16.6.1",
"react-native": "0.57.7",
"react-native-device-info": "^1.5.0",
"react-native-elements": "^1.1.0",
"react-native-extended-stylesheet": "^0.11.1",
"react-native-fbsdk": "^0.8.0",
"react-native-gesture-handler": "^1.1.0",
"react-native-google-signin": "^2.0.0",
"react-native-image-picker": "^0.28.1",
"react-native-simple-toast": "0.0.8",
"react-native-splash-screen": "^3.2.0",
"react-native-vector-icons": "^6.4.2",
"react-navigation": "^3.8.1"
},
"devDependencies": {
"babel-jest": "24.7.1",
"jest": "24.7.1",
"metro-react-native-babel-preset": "0.53.1",
"react-test-renderer": "16.6.1"
},
"jest": {
"preset": "react-native"
},
"rnpm": {
"assets": [
"./src/resources/fonts"
]
}
}
package com. app_name;
import android.os.Bundle; // here
import com.facebook.react.ReactActivity;
import android.content.Intent;
import org.devio.rn.splashscreen.SplashScreen; // here
public class MainActivity extends ReactActivity {
/**
* Returns the name of the main component registered from JavaScript.
* This is used to schedule rendering of the component.
*/
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
MainApplication.getCallbackManager().onActivityResult(requestCode, resultCode, data);
}
@Override
protected void onCreate(Bundle savedInstanceState) {
SplashScreen.show(this, R.style.SplashScreenTheme); // here
super.onCreate(savedInstanceState);
}
@Override
protected String getMainComponentName() {
return "app_name";
}
}
package com.app_name;
import android.app.Application;
import com.facebook.react.ReactApplication;
import co.apptailor.googlesignin.RNGoogleSigninPackage;
import com.facebook.reactnative.androidsdk.FBSDKPackage;
import com.oblador.vectoricons.VectorIconsPackage;
import org.devio.rn.splashscreen.SplashScreenReactPackage;
import com.imagepicker.ImagePickerPackage;
import com.swmansion.gesturehandler.react.RNGestureHandlerPackage;
import com.learnium.RNDeviceInfo.RNDeviceInfo;
import com.facebook.react.ReactNativeHost;
import com.facebook.react.ReactPackage;
import com.facebook.react.shell.MainReactPackage;
import com.facebook.soloader.SoLoader;
import java.util.Arrays;
import java.util.List;
import com.facebook.CallbackManager;
import com.facebook.FacebookSdk;
import com.facebook.appevents.AppEventsLogger;
import com.facebook.FacebookSdk; //new
//Google Signin
import co.apptailor.googlesignin.RNGoogleSigninPackage; // <--- import
public class MainApplication extends Application implements ReactApplication {
private static CallbackManager mCallbackManager = CallbackManager.Factory.create();
protected static CallbackManager getCallbackManager() {
return mCallbackManager;
}
private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) {
@Override
public boolean getUseDeveloperSupport() {
return BuildConfig.DEBUG;
}
@Override
protected List<ReactPackage> getPackages() {
return Arrays.<ReactPackage>asList(
new MainReactPackage(),
new RNGoogleSigninPackage(),
new FBSDKPackage(mCallbackManager),
new VectorIconsPackage(),
new SplashScreenReactPackage(),
new ImagePickerPackage(),
new RNGestureHandlerPackage(),
new RNDeviceInfo()
);
}
@Override
protected String getJSMainModuleName() {
return "index";
}
};
@Override
public ReactNativeHost getReactNativeHost() {
return mReactNativeHost;
}
@Override
public void onCreate() {
super.onCreate();
// FacebookSdk.sdkInitialize(getApplicationContext());
AppEventsLogger.activateApp(this);
SoLoader.init(this, /* native exopackage */ false);
}
}
我希望没有任何问题地构建应用程序的发行版。
相反,我遇到了上面提到的错误。
解决方案:,我终于弄清楚了我需要通过此代码段在项目级别的build.gradle文件中明确设置编译SDK版本
subprojects {
afterEvaluate {project ->
if (project.hasProperty("android")) {
android {
compileSdkVersion 27
buildToolsVersion "27.0.2"
}
}
}
}
答案 0 :(得分:0)
您使用的是哪个版本的RN?您可以将React Native升级到最新版本,以解决此问题。 或者,您可以尝试删除 node_modules 中的 .bin 文件夹,然后再次重新安装依赖项。