我正在尝试在手机上安装签名的APK,但是它一直失败。 当我gradlew assembleRelease时,将apk安装在手机上后,该应用会不断关闭,然后才能加载。
然后我尝试
react-native bundle --dev false --platform android --entry-file index.js
--bundle-output
./android/app/build/intermediates/assets/debug/index.android.bundle --
assets-dest ./android/app/build/intermediates/res/merged/debug
和
gradlew assembleDebug.
然后我在手机上安装apk时又遇到另一个错误,说我缺少开发服务器。
def enableSeparateBuildPerCPUArchitecture = true
def enableProguardInReleaseBuilds = false
android {
// because of firestore:
dexOptions {
javaMaxHeapSize "4g"
}
compileSdkVersion 27
defaultConfig {
applicationId "com.myapp"
minSdkVersion 16
targetSdkVersion 22
versionCode 1
versionName "1.0"
// ndk {
// abiFilters "armeabi-v7a", "x86"
// }
// because of firestore:
multiDexEnabled true
}
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) { // null for the universal-debug, universal-
release variants
output.versionCodeOverride =
versionCodes.get(abi) * 1048576 +
defaultConfig.versionCode
}
}
}
和错误日志:
0 info it worked if it ends with ok
1 verbose cli [ 'D:\\node.exe',
1 verbose cli 'D:\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli 'start' ]
2 info using npm@5.6.0
3 info using node@v8.11.1
4 verbose run-script [ 'prestart', 'start', 'poststart' ]
5 info lifecycle womencare@0.1.0~prestart: womencare@0.1.0
6 info lifecycle womencare@0.1.0~start: womencare@0.1.0
7 verbose lifecycle womencare@0.1.0~start: unsafe-perm in lifecycle true
8 verbose lifecycle womencare@0.1.0~start: PATH:
D:\node_modules\npm\node_modules\npm-lifecycle\node-gyp-
bin;C:\Users\thanos\womencare\react-native-firebase-
starter\node_modules\.bin;C:\Program Files (x86)\Common
Files\Oracle\Java\javapath;C:\WINDOWS\system32;
C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:
\WINDOWS\System32\WindowsPowerShell\v1.0\;C
:\WINDOWS\System32\OpenSSH\;D:\;D:\Git\cmd;C
:\Program Files
(x86)\Yarn\bin\;C:\Users\thanos\AppData\Local\Android\sdk\platform-
tools;;D:\Microsoft VS
Code\bin;C:\Users\thanos\AppData\Local\Microsoft
\WindowsApps;C:\Users\thanos\AppData\Roaming\npm;C:
\Users\thanos\AppData\Local\Yarn\bin;C:\Program Files
(x86)\Java\jdk1.8.0_171\bin;C:\Users\thanos\sdk-tools-windows-
4333796\tools\bin
9 verbose lifecycle womencare@0.1.0~start: CWD:
C:\Users\thanos\womencare\react-
native-firebase-starter
10 silly lifecycle womencare@0.1.0~start: Args: [ '/d /s /c', 'react-native
start' ]
11 silly lifecycle womencare@0.1.0~start: Returned: code: 11 signal: null
12 info lifecycle womencare@0.1.0~start: Failed to exec start script
13 verbose stack Error: womencare@0.1.0 start: `react-native start`
13 verbose stack Exit status 11
13 verbose stack at EventEmitter.<anonymous>
(D:\node_modules\npm\node_modules\npm-lifecycle\index.js:285:16)
13 verbose stack at emitTwo (events.js:126:13)
13 verbose stack at EventEmitter.emit (events.js:214:7)
13 verbose stack at ChildProcess.<anonymous>
(D:\node_modules\npm\node_modules\npm-lifecycle\lib\spawn.js:55:14)
13 verbose stack at emitTwo (events.js:126:13)
13 verbose stack at ChildProcess.emit (events.js:214:7)
13 verbose stack at maybeClose (internal/child_process.js:925:16)
13 verbose stack at Process.ChildProcess._handle.onexit
(internal/child_process.js:209:5)
14 verbose pkgid womencare@0.1.0
15 verbose cwd C:\Users\thanos\womencare\react-native-firebase-starter
16 verbose Windows_NT 10.0.17134
17 verbose argv "D:\\node.exe" "D:\\node_modules\\npm\\bin\\npm-cli.js"
"start"
18 verbose node v8.11.1
19 verbose npm v5.6.0
20 error code ELIFECYCLE
21 error errno 11
22 error womencare@0.1.0 start: `react-native start`
22 error Exit status 11
23 error Failed at the womencare@0.1.0 start script.
23 error This is probably not a problem with npm. There is likely additional
logging output above.
24 verbose exit [ 11, true ]