Tap*_*jee 79 android cordova build.gradle ionic-framework ionic3
在为Android构建Ionic 3应用程序时,突然出现以下错误。
Could not find org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.3.60-eap-25
我们已经从Android Studio中的一个解决方案在这里,但我在我的build.gradle没有变化用下面的代码后,我仍然得到错误。
buildscript {
    repositories {
        ...
        maven { url 'https://dl.bintray.com/kotlin/kotlin-eap' }
    }
}
allprojects {
    repositories {
        ...
        maven { url 'https://dl.bintray.com/kotlin/kotlin-eap' }
    }
}
更新Cordova并添加上述解决方案后,我的build.gradle文件如下所示。
buildscript {
    repositories {
        google()
        jcenter()
        maven { url 'https://dl.bintray.com/kotlin/kotlin-eap' }
    }
    dependencies {
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
        classpath 'com.android.tools.build:gradle:3.3.0'
    }
}
allprojects {
    repositories {
        google()
        jcenter()
        maven { url 'https://dl.bintray.com/kotlin/kotlin-eap' }
    }
    //This replaces project.properties w.r.t. build settings
    project.ext {
      defaultBuildToolsVersion="28.0.3" //String
      defaultMinSdkVersion=19 //Integer - Minimum requirement is Android 4.4
      defaultTargetSdkVersion=28 //Integer - We ALWAYS target the latest by default
      defaultCompileSdkVersion=28 //Integer - We ALWAYS compile with the latest by default
    }
}
task clean(type: Delete) {
    delete rootProject.buildDir
}
还是一样的错误。
Mis*_*ith 75
The problem lies in the cordova-support-google-services plugin for Cordova.
This plugin's build.gradle looks like this as of today (October 24th, 2019):  
dependencies {
    classpath 'com.android.tools.build:gradle:+'
    classpath 'com.google.gms:google-services:4.2.0'
}
More exactly the problem lies in this dependency:
classpath 'com.android.tools.build:gradle:+'
That is an extremely brittle way of specifying dependencies. The '+' sign here means "fetch the most recent version available in the repo".
If a newer version is published in the repo, and it breaks the build, then everyone with this plugin has their projects broken.
This happened today. The broken version that is being fetched is com.android.tools.build:gradle:4.0.0. It requires some Kotlin stuff. 
That is why you need to ALWAYS freeze dependencies to reliably build your project. Never trust the newer stuff. This dependency compiles fine just as it did yesterday:
classpath 'com.android.tools.build:gradle:3.5.1'
For those using Cordova or Ionic, you can make a quick fix to be able to build the project by freezing the dependency in the file:
<projectroot>/platforms/android/cordova-support-google-services/<project>-build.gradle
This is not a definitive solution though. If you reinstall the android platform via Cordova the error will show up again. The project maintainer should either freeze the dependency or fix it to support gradle 4.0.0. In the meantime just use a fixed fork of this plugin.
Dan*_*ead 30
cordova-support-google-services今天更新为版本1.3.2,该版本将类路径从 
classpath 'com.android.tools.build:gradle:+' 
至
classpath 'com.android.tools.build:gradle:3.+' 
这似乎修复了kotlin错误
我通过执行以下操作成功构建了我的:
我编辑了平台-> android-> cordova-support-google-services-> myAppName-build.gradle
并改变了
maventCentral()
至
    maven { url "https://maven.google.com" }
    maven { url 'https://dl.bintray.com/kotlin/kotlin-eap' }
那解决了kotlin错误,然后我得到了另一个错误,通过更改
classpath 'com.google.gms:google-services:4.2.0'
至
classpath 'com.google.gms:google-services:4.1.0'
然后,它成功构建。
Lui*_*lez 29
这是解决方案。
问题恰好是maven存储库(在此处),但是问题出在cordova-support-google-services插件中的build.gradle ,所以我添加了所需的行,现在一切正常,我已经创建了一个pull要求原始回购(此处)。但是与此同时,您可以执行我的操作,只需将package.json中的当前版本替换为我的仓库即可:
之前:
...
"cordova-support-google-services": "^1.3.1",
...
后:
...
"cordova-support-google-services": "https://github.com/LuisEGR/cordova-support-google-services.git",
...
之后,您将必须:
npm install 这是一个临时解决方案,可以接受对主存储库的拉取请求并更新npm包
就是这样,现在您可以再次构建项目。
我正在使用Ionic 4,有些插件需要使用cordova-support-google-services,以防万一您的package.json中没有该错误,可能是其他插件造成的,如果是的话,请添加package.json,以便我们找出哪个是问题。
更新24 / OCT:
我已经按照许多人的建议在仓库中更改了解决方案,现在该解决方案仅用于修复依赖项:从:com.android.tools.build :gradle:+ 到类路径com.android.tools.build:gradle: 3. +,如果您想查看更改内容,这已经在我的仓库中
Solution for ionic v3 and cordova
@Mister Smith solution solved my problem
you have to go to the file
platforms/android/cordova-support-google-services
then
Replace
classpath 'com.android.tools.build:gradle:+'
by
classpath 'com.android.tools.build:gradle:3.5.1'
@Alternative solution I have found is to
setup kotlin in your system :)
在我的项目中,我这样修复。(我在科特林的项目)
buildscript{
    repositories {
         google()
         jcenter()
         ......
         maven { url 'https://dl.bintray.com/kotlin/kotlin-eap' }
    }
}
allprojects {
    repositories {
         google()
         jcenter()
         ......
         maven { url 'https://dl.bintray.com/kotlin/kotlin-eap' }
   }
}
小智 5
作为对@MisterSmith 的建议采取后续措施的进一步临时解决方案,请使用钩子重新应用该锁:
<hook src="scripts/fix_android_dep.sh" type="after_platform_add"/>
用这个过于冗长的bash代码:
#!/usr/bin/env bash
## temporary fix for android studio EAP issue
## SOURCE: /sf/answers/4097564691/
if [ -d "platforms/android/cordova-support-google-services" ]; then
  file="platforms/android/cordova-support-google-services/app-build.gradle"
  from="classpath 'com.android.tools.build:gradle:+'"
  to="classpath 'com.android.tools.build:gradle:3.5.1'"
  change=`sed "s/$from/$to/" < "$file"`
  echo "$change" > "$file"
fi
| 归档时间: | 
 | 
| 查看次数: | 12498 次 | 
| 最近记录: |