【问题标题】:Gradle dont sync in new version Android studioGradle 在新版本的 Android Studio 中不同步
【发布时间】:2018-11-06 23:23:37
【问题描述】:

我想在我在 gradle 设置下尝试过的 android 设备中运行我的 react native 项目

应用级构建分级

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

    }
 }

模块级分级

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

当我尝试生成构建时,我的 android studio 中出现了上述错误?知道我该如何解决这个问题吗?

【问题讨论】:

  • compileSdkVersion 26 你没有警告说它会忽略任何低于 27 的 API 级别吗?今天早上发生在我身上(没有反应),我不得不降级 gradle 才能让我的项目再次运行
  • malarres : 你能把你的尝试贴出来让我了解一下

标签: android react-native build android-gradle-plugin


【解决方案1】:

你能把你的尝试贴出来让我了解一下吗

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

gradle-wrapper.properties 也一样

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2022-06-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-02-20
    • 2020-06-12
    • 1970-01-01
    相关资源
    最近更新 更多