windows7+cordova6.3.1+android sdk23+cordova-android5.1.1+gradle2.2.1

C:\Users\Administrator\hello>cordova requirements

Requirements check results for android:
Java JDK: installed .
Android SDK: installed
Android target: not installed
Android SDK not found. Make sure that it is installed. If it is not at the defau
lt location, set the ANDROID_HOME environment variable.
Gradle: not installed
Could not find gradle wrapper within Android SDK. Might need to update your Andr
oid SDK.
Looked here: D:\D_C\Androidsdk\tools\templates\gradle\wrapper
Error: Some of requirements check failed

解决方法:将下载好的放到D:\D_C\Androidsdk\下

To run dex in process, the Gradle daemon needs a larger heap.
It currently has approximately 910 MB.
For faster builds, increase the maximum heap size for the Gradle daemon to more
than 2048 MB.
To do this set org.gradle.jvmargs=-Xmx2048M in the project gradle.properties.
For more information see https://docs.gradle.org/current/userguide/build_environ
ment.html
:transformClassesWithDexForDebug FAILED

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ‘:transformClassesWithDexForDebug’.

com.android.build.api.transform.TransformException: java.lang.RuntimeException
: com.android.ide.common.process.ProcessException: java.util.concurrent.Executio
nException: java.lang.IllegalStateException: dx.jar is missing

  • Try:
    Run with –stacktrace
    BUILD FAILED
    option to get the stack trace. Run with –info or –debug option to get more lo
    g output.

Total time: 1.792 secs
Error: cmd: Command failed with exit code 1 Error output:
FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ‘:transformClassesWithDexForDebug’.

com.android.build.api.transform.TransformException: java.lang.RuntimeException
: com.android.ide.common.process.ProcessException: java.util.concurrent.Executio
nException: java.lang.IllegalStateException: dx.jar is missing

  • Try:
    Run with –stacktrace option to get the stack trace. Run with –info or –debug
    option to get more log output.
    Picked up _JAVA_OPTIONS: -Xmx512M

解决办法:cordova platform add android@5.1.1

:transformClassesWithDexForDebug FAILED

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ‘:transformClassesWithDexForDebug’.

java.lang.IllegalStateException: dx.jar is missing

  • Try:
    Run with –stacktrace option to get the stack trace. Run with –info or –debug
    option to get more log output.

BUILD FAILED

Total time: 1 mins 53.074 secs
Error: Error code 1 for command: cmd with args: /s,/c,”C:\Users\Administrator\he
llo\platforms\android\gradlew cdvBuildDebug -b C:\Users\Administrator\hello\plat
forms\android\build.gradle -Dorg.gradle.daemon=true -Pandroid.useDeprecatedNdk=t
rue”

解决办法:

这个问题我也遇到了,荡了好多帖子找到的解决方法。原因是最新版dx.jar文件可能不兼容导致。

先关闭IDE,

找到自己SDK下build-tools文件夹,打开后会有不止一个版本的文件夹。

选择一个版本较低的文件夹打开->打开lib文件夹->复制当前dx.jar文件;

向上返回,打开版本最新(高)的文件夹->打开lib文件夹->用复制的dx.jar文件替换当前文件(不放心可以先备份一个留着)。

FAILURE: Build failed with an exception.

  • What went wrong:
    A problem occurred configuring root project ‘android’.

BUILD FAILED

Total time: 9.672 secs

Could not resolve all dependencies for configuration ‘:_debugCompile’.
Could not find any version that matches com.android.support:support-v4:+.
Searched in the following locations:
https://repo1.maven.org/maven2/com/android/support/support-v4/maven-met
adata.xml
https://repo1.maven.org/maven2/com/android/support/support-v4/
https://jcenter.bintray.com/com/android/support/support-v4/maven-metada
ta.xml
https://jcenter.bintray.com/com/android/support/support-v4/
file:/D:/MES/LiteMES-Mobile-VS1/LiteMES-Mobile-VS/platforms/android/lib
s/
Required by:
:android:unspecified

  • Try:
    Run with –stacktrace option to get the stack trace. Run with –info or –debug
    option to get more log output.
    Error: Error code 1 for command: cmd with args: /s,/c,”D:\MES\LiteMES-Mobile-VS1
    \LiteMES-Mobile-VS\platforms\android\gradlew cdvBuildDebug -b D:\MES\LiteMES-Mob
    ile-VS1\LiteMES-Mobile-VS\platforms\android\build.gradle -Dorg.gradle.daemon=tru
    e -Pandroid.useDeprecatedNdk=true”

解决办法:platforms/android/build.gradle中添加:

repositories {
mavenCentral()
maven { url ‘http://maven.aliyun.com/nexus/content/groups/public/’ }
// 其他仓库源…
}

:processDebugResources FAILED

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ‘:processDebugResources’.

com.android.ide.common.process.ProcessException: org.gradle.process.internal.E
xecException: Process ‘command ‘D:\D_C\Androidsdk\build-tools\34.0.0\aapt.exe”
finished with non-zero exit value 1

  • Try:
    Run with –stacktrace option to get the stack trace. Run with –info or –debug
    option to get more log output.

BUILD FAILED

Total time: 14.464 secs
Error: Error code 1 for command: cmd with args: /s,/c,”D:\MES\LiteMES-Mobile-VS1
\LiteMES-Mobile-VS\platforms\android\gradlew cdvBuildDebug -b D:\MES\LiteMES-Mob
ile-VS1\LiteMES-Mobile-VS\platforms\android\build.gradle -Dorg.gradle.daemon=tru
e -Pandroid.useDeprecatedNdk=true”

解决办法:platforms/android/build.gradle中添加:

compileSdkVersion 28
buildToolsVersion “28.0.0”

为什么要这样呢?

Android中出现Error:In (declare-styleable) FontFamilyFont, unable to find attribute android:font 解决办法,今天由于项目要用到 support-v4 包,所以就导入v4 包到项目中,可是导入之后就出现 Error:In FontFamilyFont, unable to find attribute android:font 这个错误,如下图:

这里写图片描述

然后就是上网各种搜,看大多数都是说 compileSdkVersion 和buildToolsVersion 的版本不对应,所以才会出现这种问题,但是按照这种提示修改之后,问题依旧还在,然后就想会不会是 compileSdkVersion 和buildToolsVersion 的版本太低了,就把这两个的版本改成最新的,果然就没有问题了,希望此文章可以帮到遇到同样问题的你。

https://www.cnblogs.com/zhujiabin/p/8242600.html

发表评论