我已经多次运行react-native run-android
来开发应用程序,在模拟器和手机上但现在当我创建发布版本时,apk已成功构建但当我尝试运行时物理设备它立即崩溃没有错误日志。在模拟器上运行相同的版本构建工作正常,因此我不确定这里存在什么问题,并且在没有任何崩溃日志的情况下很难调试。
这是我的project build.gradle
文件
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.2'
classpath 'com.google.gms:google-services:3.2.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
mavenCentral()
maven { url 'https://jitpack.io' }
mavenLocal()
jcenter()
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url "$rootDir/../node_modules/react-native/android"
}
}
}
app build.gradle
android {
compileSdkVersion 27
buildToolsVersion '27.0.3'
defaultConfig {
applicationId "in.calc"
minSdkVersion 16
targetSdkVersion 27
versionCode 27
versionName "3.0.0-beta-1"
/*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 true // If true, also generate a universal APK
// include "armeabi-v7a", "x86"
include "armeabi-v7a", "arm64-v8a"
}
}
buildTypes {
release {
signingConfig signingConfigs.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, 'arm64-v8a': 2]
def abi = output.getFilter(OutputFile.ABI)
if (abi != null) { // null for the universal-debug, universal-release variants
output.versionCodeOverride = versionCodes.get(abi) * 100000 + variant.versionCode
}
}
}
}
dependencies {
implementation(project(':react-native-admob')) {
exclude group: 'com.google.android.gms'
}
implementation(project(':react-native-firebase')) {
transitive = false
}
implementation("com.google.android.gms:play-services-gcm:15.0.1") {
force = true
}
implementation("com.google.android.gms:play-services-ads:15.0.1") {
force = true
}
implementation("com.google.android.gms:play-services-base:15.0.1") {
force = true
}
implementation("com.google.firebase:firebase-core:15.0.2") {
force = true
}
implementation("com.google.firebase:firebase-messaging:15.0.2") {
force = true
}
implementation project(':react-native-video-exoplayer')
implementation project(':react-native-share')
implementation project(':react-native-fetch-blob')
implementation project(':react-native-orientation')
implementation project(':react-native-youtube')
implementation project(':react-native-vector-icons')
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation "com.android.support:appcompat-v7:27.1.1"
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'
}
apply plugin: 'com.google.gms.google-services'
package.json
{
"name": "calc",
"version": "0.0.1",
"private": true,
"scripts": {
"start": "node node_modules/react-native/local-cli/cli.js start",
"build-ios": "react-native bundle --entry-file index.js --platform ios --dev false --bundle-output ios/prudent/main.jsbundle --assets-dest ios",
"build-android": "react-native bundle --entry-file index.js --platform android --dev false --bundle-output android/main.jsbundle",
"test": "jest"
},
"dependencies": {
"axios": "^0.18.0",
"moment": "^2.22.1",
"react": "^16.3.1",
"react-native": "0.55.4",
"react-native-admob": "^2.0.0-beta.5",
"react-native-auto-height-image": "^1.0.0",
"react-native-elements": "^1.0.0-beta5",
"react-native-fetch-blob": "^0.10.8",
"react-native-firebase": "4.1.0",
"react-native-htmlview": "^0.12.1",
"react-native-orientation": "^3.1.3",
"react-native-share": "^1.0.27",
"react-native-vector-icons": "^4.6.0",
"react-native-youtube": "^1.1.0",
"react-navigation": "^1.5.12",
"react-native-video": "^2.0.0"
},
"devDependencies": {
"babel-jest": "22.4.3",
"babel-preset-react-native": "4.0.0",
"jest": "22.4.3",
"react-test-renderer": "16.3.1"
},
"jest": {
"preset": "react-native"
}
}
任何帮助都将不胜感激。
答案 0 :(得分:1)
对于寻找答案的人来说,我在寻找答案时发现了多种原因。对我而言,问题是android.useDeprecatedNdk=true
中缺少gradle.properties
。
除此之外,我遇到了abi分裂的问题,本文Mixing 32- and 64-bit Dependencies in Android更好地解释了这一问题。
基本上,一旦遇到64位库,android会将32位库抛出窗口,不幸的是,对于本机的大部分是32位,这就是整个应用程序崩溃的原因。因此,诀窍是排除可能包含在apk中的任何64位库,这些库迫使android回退到使用32位系统。一旦谷歌决定强制执行64 bit support for apps by 2019,这将导致一些问题。
有助于调试上述情况的链接