我正试图为现有的react原生项目添加如下内容:
flavorDimensions "default"
productFlavors {
flavourone {
dimension "default"
applicationId "com.example.flavourone"
}
flavourtwo {
dimension "default"
applicationId "com.example.flavourtwo"
}
}
Error: Duplicate resources
我尝试了一系列不同的解决方案,清理项目,运行package.json中的命令以捆绑到temp目录等。我认为build.gradle文件没有正确配置以支持添加口味,或者我没有正确地执行。
任何帮助都将非常感谢,下面是我的gradle文件(很少重命名为示例):
project.ext.react = [
entryFile: "index.js",
]
//using custom react gradle here to get around https://stackoverflow.com/questions/52464842/react-native-duplicate-resources
apply from: "../../node_modules/react-native-sentry/sentry.gradle"
apply from: "../react.gradle"
//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
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
defaultConfig {
applicationId "com.example"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 1
versionName "1.0"
missingDimensionStrategy 'react-native-camera', 'general'
multiDexEnabled true
ndk.abiFilters 'armeabi-v7a', 'arm64-v8a', 'x86', 'x86_64'
}
flavorDimensions "default"
productFlavors {
flavourone {
dimension "default"
applicationId "com.example.flavourone"
}
flavourtwo {
dimension "default"
applicationId "com.example.flavourtwo"
}
}
sourceSets {
main {
jniLibs.srcDirs = ['libs']
}
debug {
res.srcDirs = ['src/debug/res']
// this uses the debug's res directory which contains a "debug" icon
}
release {
java.srcDirs = ['src/debugRelease/java']
// this avoids copying across code from the debugRelease java directory
}
}
signingConfigs {
release {
(removed)
}
}
splits {
abi {
reset()
enable enableSeparateBuildPerCPUArchitecture
universalApk false // If true, also generate a universal APK
include "armeabi-v7a", "x86", "arm64-v8a", "x86-64"
}
}
buildTypes {
release {
minifyEnabled enableProguardInReleaseBuilds
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
(removed)
}
}
// 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, "arm64-v8a": 3, "x86-64": 4]
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 {
(removed)
}
// 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'
}
在创建APK之前,我使用package.json中的命令(react-native bundle--entry-file index.js--Platform Android--dev false--bundle-output android/app/src/main/assets/index.android.bundle--assets-dest android/app/src/main/res
)。
似乎一旦我运行这个命令,我的默认drawables就会与flavortwo drawables发生冲突,并最终得到重复的资源
在Android/app/src/main/res drawable-hdpi、drawable-mdpi、drawable-xhdpi、drawable-xxhdpi和raw文件夹中删除它并添加到Android/app/build.gradle
文件中
android {
...
aaptOptions {
cruncherEnabled = false
}
然后./Dradlew在android studio中清理
、无效缓存/restart
,然后构建签名的APK。
我目前在react Native上有点挣扎。我想拥有的是一个基于react原生的库项目,然后我可以包括在我的一些应用程序。 通过启动dev-server没有任何问题,但是只要我启动Android应用程序,就会得到folowwing logcat输出: 请注意,我执行了操作,但仍然显示错误。 稍后,我想从Android库项目中创建一个aar,并通过Maven访问它。
我开始使用atom文本编辑器开发android应用程序。只要我用JS和JSX编写代码,它就可以正常工作。 我必须做的功能是不可用的反应原生,所以我需要写java代码一样https://facebook.github.io/react-native/docs/native-modules-android.html 演讲模块。Java语言 我不想在atom中编写Java代码,因为建议不起作用。我们可以
我正在尝试对现有的android项目进行本地集成,但在android studio中构建项目时出现了以下异常。 原因:java.lang.Exception:React Native CLI无法确定Android项目配置。这可能是由于配置错误。配置输出:[root:/Users/muratoner/Desktop/backup/Sabanci.Projects/Mobile/hrweb-ract-
在React Native中,进行开发构建时,您可以摇动设备或使用菜单按钮打开开发人员菜单。如何将其他自定义项添加到此菜单?我还没有找到任何关于添加另一项的文档,但我认为从“开发”菜单中选择“在服务器环境(开发、产品等)之间切换”会非常方便,而不是针对每个环境进行单独的构建测试。
我正在尝试生成android apk用于反应原生。通过https://facebook.github.io/react-native/docs/signed-apk-android.html#content给出的文档 1)生成密钥库 2) 设置 gradle 变量 3)将签名配置添加到应用程序的 gradle 配置 # 4) 生成签名 apk 以通过 android studio 发布 (buil