Gradle不要在新版Android Studio中同步

时间:2018-05-28 11:15:57

标签: android react-native build android-gradle

我想在android设备中运行我的反应原生项目我试过下面的gradle设置

App level build gradle

buildscript {
repositories {
    jcenter()
    mavenCentral()
    maven { url 'https://maven.google.com' }
    google()
}
dependencies {
    classpath 'com.android.tools.build:gradle:3.0.1'

    }
 }

allprojects {
repositories {
    mavenLocal()
    jcenter()
    //google()
    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' }

    maven {
        url "https://maven.google.com"
       }

    }
 }

模块级别gradle

apply plugin: "com.android.application"

import com.android.build.OutputFile



 project.ext.react = [
    entryFile: "index.js"
 ]

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


def enableSeparateBuildPerCPUArchitecture = false


 def enableProguardInReleaseBuilds = false

android {
compileSdkVersion 26
buildToolsVersion '26.0.2'

defaultConfig {
    applicationId "com.showstockconnect"
    minSdkVersion 16
    targetSdkVersion 26
    versionCode 3
    versionName "1.0.3"
    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 project(':react-native-android-location-services-dialog-box')
compile project(':react-native-fetch-blob')
compile project(':react-native-splash-screen')
compile fileTree(dir: "libs", include: ["*.jar"])
compile "com.android.support:appcompat-v7:26.0.1"
compile "com.facebook.react:react-native:+"  // From node_modules
compile project(':react-native-maps')
//noinspection GradleCompatible
compile 'com.google.android.gms:play-services-base:11.8.0'
compile 'com.google.android.gms:play-services-maps:11.8.0'
compile 'com.google.android.gms:play-services-location:11.8.0'

 }


  task copyDownloadableDepsToLibs(type: Copy) {
from configurations.compile
 into 'libs'
}

enter image description here

当我尝试生成构建时,我的android工作室出现了上述错误?我怎么能解决这个问题?

1 个答案:

答案 0 :(得分:0)

  

你可以发布你的尝试,这样我就可以了解这个

在左侧,您可以看到升级后build.gradle是如何发生的,右侧是我如何离开它(降级)

enter image description here

{p}同样的事情gradle-wrapper.properties enter image description here