代码之家  ›  专栏  ›  技术社区  ›  Mehmet

没有此类属性:类的ABI网址:org.gradle.api.tasks.OutputFile文件

  •  0
  • Mehmet  · 技术社区  · 6 年前

    我对React Native的开发是全新的。我开发了一个小项目,并希望有一个发布APK。但是我会在发布版本上叠加。

    没有此类属性:类的ABI网址:org.gradle.api.tasks.OutputFile文件 网址:org.gradle.api.ProjectConfigurationException:出现问题 配置项目“:app”由以下原因引起: 网址:org.gradle.api.tasks.OutputFile文件

    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'
    }
    

    生成.gradle(示例MOBILEApp)

    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"
    }
    
    1 回复  |  直到 6 年前
        1
  •  23
  •   Mehmet    6 年前

    import com.android.build.OutputFile
    

    致生成.gradle(对于app)解决了这个问题

    推荐文章