Build.Gradle:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
mavenLocal()
jcenter()
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url "$rootDir/../node_modules/react-native/android"
}
}
}
build.gradle/app:
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
applicationId "com.emptyprojecttemplate"
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 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 fileTree(dir: "libs", include: ["*.jar"])
compile "com.android.support:appcompat-v7:23.0.1"
compile "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'
}
您的stacktrace以:错误:无法找到符号导入com.facebook.React.reactApplication
开始,这似乎表明它无法找到React库导入。
我将在Github上为您提供一个答案,请阅读:
https://github.com/transistorsoft/react-native-background-geolocation/issues/294
如果其他人也遇到了同样的问题:确保正确添加了新的存储库。根据Android文档,每个maven repo都应该在自己的maven{}块中。
这就是为什么
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url "$rootDir/../node_modules/react-native/android"
url 'some new extra repo'
}
打破依赖关系。正确的版本是
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url "$rootDir/../node_modules/react-native/android"
}
maven {
url 'some new extra repo'
}
React原生android错误:找不到符号
最后的手段
可能值得创建一个新的测试项目(使用最新版本),比如react-native init anotherproject
,看看它是否运行。
每当我尝试运行“react-native run-android” 我失败了: 任务“:app:PackageDebug”执行失败 我试着结账给previus提交。我尝试删除android/app/build和re-build,我尝试删除debug.keystore并再次启动它。 他们都没有解决这个问题。 我之前在android虚拟设备中成功运行了我的应用程序,并且我已经把我的应用程序上传到了go
失败:生成失败,出现异常。 > 错误:任务“:app:CompiledEbugJavaWithJavac”执行失败。 编译失败;有关详细信息,请参阅编译器错误输出。
我只是想继续我的应用程序,而我得到了这个编译错误,我不知道它是从哪里开始的: 这是我的分级文件:
我已经尝试了多种解决方案在线无法使构建工作 我得到任务“:app:mergereleaseResources”的执行失败。 [raw/app]C:\users\lenovo\documents\github\marist-mobile-app\android\app\src\main\res\raw\app.json[raw/app]C:\users\lenovo\documents\github