我对React Native的发展是全新的.我开发了一个小项目,想发布一个APK.Bu我在发布构建时进行堆栈.

错误是

类:org没有这样的属性:ABI.格雷德尔.应用程序编程接口.任务.输出文件

build.gradle(app)

apply plugin: "com.android.application"


project.ext.react = [
    resourcesDirRelease: "$buildDir/intermediates/res/merged/release",
]

apply from: "../../node_modules/react-native/react.gradle"


def enableSeparateBuildPerCPUArchitecture = false

/**
 * Run Proguard to shrink the Java bytecode in release builds.
 */
def enableProguardInReleaseBuilds = false

android {
    compileSdkVersion rootProject.ext.compileSdkVersion

    defaultConfig {
        applicationId "com.ninjakod.vehiclevalue"
        minSdkVersion rootProject.ext.minSdkVersion
        targetSdkVersion rootProject.ext.targetSdkVersion
        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"
        }
    }
    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
            }
        }
    }
    buildTypes {
        release {
            minifyEnabled enableProguardInReleaseBuilds
            proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
            signingConfig signingConfigs.release
        }
    }
    // 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
            }
        }
    }
    buildToolsVersion '27.0.3'
}

dependencies {
    compile project(':react-native-admob')
    implementation project(':react-native-admob')
    implementation fileTree(dir: "libs", include: ["*.jar"])
    implementation "com.android.support:appcompat-v7:${rootProject.ext.supportLibVersion}"
    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'
}

build.gradle(SampleMobileApp)

buildscript {
    repositories {
        jcenter()
        maven {
            url 'https://maven.google.com/'
            name 'Google'
        }
        google()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.2.0-alpha11'

        // 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"
        }
        maven {
            url 'https://maven.google.com/'
            name 'Google'
        }
    }
}

ext {
    buildToolsVersion = "26.0.3"
    minSdkVersion = 16
    compileSdkVersion = 26
    targetSdkVersion = 26
    supportLibVersion = "26.1.0"
}

推荐答案

好吧,我找到了解决办法.添加

import com.android.build.OutputFile

go 建造.gradle(应用程序)解决了这个问题

React-native相关问答推荐

Reaction-原生NavBottom设计背景

构建 iOS Expo 应用时出现 React-Native xcodebuild 错误 65

React Native Android:how to remove "overscroll effect" of ScrollView

Android Studio 为构建设置 node 目录(Cause: error=2, No such file or directory)

可能的未处理promise 拒绝(id:0):错误: "getLoginData" is read-only

检索元素的父项时出错:找不到与给定名称android:TextAppearance.Material.Widget.Button.Colored匹配的资源

如何通过 node ID 获取真实元素?

如何为 Picker 提供默认的Please select...选项?

React-Native 应用程序的 Jest 测试 Animated.View

从组件的 style属性中获取 CSS 属性值

在 UIManager 中找不到RNCSafeAreaView

如何在 React Native 上获取设备的 ip?

Ipad 上的 React Native - 错误 - could not connect to development server

React Native + React (for web) 种子元素

区别需要MainQueueSetup 和dispatch_get_main_queue?

如何在react-native中显示toast消息

将 setState 与 promise 一起使用后出现错误

React native - 以编程方式判断是否启用了远程 JS 调试

Android 是否支持 React Native 的 LayoutAnimation?

以编程方式读取 app.json(或 exp.json)