没有这样的属性:类的ABI:org.gradle.api.tasks.OutputFile

Meh*_*met 2 android gradle android-gradle-plugin react-native

我是React Native开发的新手。我开发了一个小项目,想要发布APK。不,我去发布构建堆栈。谁能帮我?谢谢。

错误是

没有这样的属性:类的ABI:org.gradle.api.tasks.OutputFile org.gradle.api.ProjectConfigurationException:配置项目':app'时发生问题原因:groovy.lang.MissingPropertyException:无此类属性:类的ABI :org.gradle.api.tasks.OutputFile

build.gradle(应用程序)

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'
}
Run Code Online (Sandbox Code Playgroud)

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"
}
Run Code Online (Sandbox Code Playgroud)

小智 13

替换 build.gradle(:app) 中的这一行

def abi = output.getFilter(OutputFile.ABI)
Run Code Online (Sandbox Code Playgroud)

和:

def abi = output.getFilter(com.android.build.OutputFile.ABI)
Run Code Online (Sandbox Code Playgroud)


Meh*_*met 12

好吧,我找到了解决方案。新增中

import com.android.build.OutputFile
Run Code Online (Sandbox Code Playgroud)

到build.gradle(for app)解决了这个问题

  • 我无法欺骗 Android Studio 删除该行,通过使用“def abi = output.getFilter(com.android.build.OutputFile.ABI)”显式命名该类,我可以使其工作 (8认同)
  • 每次我尝试添加时,Android studio 都会自动删除这一行,沮丧的是我一直按 CMD + Z 来撤消 Android Studio 所做的更改,并且它不断删除我不断添加的行,直到构建完成,最后,我赢得了 Android Studio 输了!这解决了这个愚蠢的问题。谢谢 (2认同)