'android-24'를 컴파일하려면 JDK 1.8 이상이 필요합니다.
Android Studio를 사용하고 최근에 오류가 발생했습니다.
오류 : ': app : compileDebugJavaWithJavac'작업에 대한 실행이 실패했습니다. compileSdkVersion 'android-24'를 컴파일하려면 JDK 1.8 이상이 필요합니다.
하지만 JDK 1.8이 이미 설치되어 있습니다.
: \ Users ..> java -version
java 버전 "1.8.0_91"Java (TM) SE 런타임
환경 (빌드 1.8.0_91-b15) Java HotSpot (TM) 64 비트 서버 VM
(빌드 25.91-b15, 혼합 모드)
그것을 고치는 방법? 감사
Android Studio에서
File
>> Project Structure
JDK 위치가 JDK 1.8 디렉토리를 가리키는 지 확인합니다.
참고 : 사용할 수 있습니다compileSdkVersion 24
며칠 동안 같은 문제가 있습니다. Windows에서 저에게서 일한 솔루션을 찾았습니다. (환경 변수도 설정했지만 필요한지 모르겠습니다.)
build.gradle 파일에 다음 행을 추가하십시오.
android {
...
defaultConfig {
...
jackOptions {
enabled true
}
}
compileOptions {
targetCompatibility 1.8
sourceCompatibility 1.8
}
}
출처 : https://code.google.com/p/android/issues/detail?id=203850
최신 jdk를 설치했지만이 작업을 수행 할 때까지 이전 버전을 사용했습니다.
app rt-click >> module settings >> sdk location >> (old jdk path)
이전 JDK 경로를 새 jdk 경로로 바꿉니다.
이제 매력처럼 작동합니다 :)
참고로 Ionic 프로젝트 에서이 오류가 발생했습니다. 모든 명령이 올바른 JDK를 가리키고 JAVA_HOME이 올바르게 설정되었습니다.
JDK 1.7 \ bin에 대한 내 PATH에 항목이 있었는데, 1.8 \ bin으로 대체하여 수정했습니다.
Mac의 명령 줄에서도 동일한 문제가 발생했지만 대답은 JAVA_HOME
무시되고 있다는 것입니다. 재정의되는 위치를 추적하려면 먼저 명령 줄에서 java를 확인하십시오.
$ java -version
java version "1.8.0_92"
Java(TM) SE Runtime Environment (build 1.8.0_92-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.92-b14, mixed mode)
그런 다음 Gradle이 사용중인 Java 버전을 확인합니다.
$ gradle -version
------------------------------------------------------------
Gradle 2.13
------------------------------------------------------------
Build time: 2016-04-25 04:10:10 UTC
Build number: none
Revision: 3b427b1481e46232107303c90be7b05079b05b1c
Groovy: 2.4.4
Ant: Apache Ant(TM) version 1.9.6 compiled on June 29 2015
JVM: 1.8.0_92 (Oracle Corporation 25.92-b14)
OS: Mac OS X 10.11.5 x86_64
이 시점에서 나는 여전히 문제의 원인을 찾지 못했습니다. 약간 파고 들었고 gradle.properties
내가 실행할 때 Java 8을 표시했지만 내 파일 에서 실제로 재정의되었음을 발견했습니다 gradle -version
.
org.gradle.daemon=true
org.gradle.java.home=/Library/Java/JavaVirtualMachines/jdk1.7.0_71.jdk/Contents/Home
org.gradle.jvmargs=-XX:MaxPermSize=512m -XX:-UseSplitVerifier -Xms512m -Xmx6144m
해결하려면, 난 그냥 삭제 된 java.home
라인에서 gradle.properties
. 다른 사람이 명령 줄에서 동일한 문제를 겪고있는 경우 도움이되기를 바랍니다.
Android Studio에서 열기 : File> Project Structure> SDK Location> Select jdk1.8.0_101.jdk> Home
또한 Windows의 명령 줄에서 동일한 문제가 발생했으며 동일한 힌트를 보여줍니다.
Error:Execution failed for task ':app:compileDebugJavaWithJavac'. `compileSdkVersion 'android-24' requires JDK 1.8 or later to compile.`
확인 JDK location
에서 Project Structure
.
Android Studio에서
File
>>Project Structure
JDK 위치가 JDK 1.8 디렉토리를 가리키는 지 확인합니다.
다음과 같아야합니다.
JDK Location
C:\Program Files\Java\jdk1.8.0_91
이미 올바른 위치를 JDK로 설정했습니다.
자바 버전 확인
D:\AndroidSelfTrainingProject\CustomBuildIdDemo>java -version
java version "1.8.0_91"
Java(TM) SE Runtime Environment (build 1.8.0_91-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.91-b14, mixed mode)
check the gradle version
.D:\AndroidSelfTrainingProject\CustomBuildIdDemo>gradle -v
------------------------------------------------------------
Gradle 2.10
------------------------------------------------------------
Build time: 2015-12-21 21:15:04 UTC
Build number: none
Revision: 276bdcded730f53aa8c11b479986aafa58e124a6
Groovy: 2.4.4
Ant: Apache Ant(TM) version 1.9.3 compiled on December 23 2013
JVM: 1.7.0_79 (Oracle Corporation 24.79-b02)
OS: Windows 7 6.1 amd64
JVM version should be 1.8. To fix it, we can add in the gradle.property In gradle.properties
in the .gradle
directory in your HOME_DIRECTORY
set org.gradle.java.home=/path_to_jdk_directory
. As for me, it is like:
org.gradle.java.home=C:/Program Files/Java/jdk1.8.0_91
To verify if it is set right, we can make a gradle build
task.
D:\AndroidSelfTrainingProject\CustomBuildIdDemo>gradle build
To honour the JVM settings for this build a new JVM will be forked. Please consider using the daemon
: https://docs.gradle.org/2.10/userguide/gradle_daemon.html.
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_environment.html
On Windows 10, I first checked Project Structure and it pointed to an old 1.7 jdk. I closed Android Studio then renamed the old jdks (and jre libraries for consistency) leaving the newest 1.8 library alone. When I restarted Android Studio and attempted to build the application it asked me for the Java JDK library and I gave the path to the newest 1.8 JDK library. On my system it was C:\Program Files\Java\jdk1.8.0_112.
참고URL : https://stackoverflow.com/questions/37933651/android-24-requires-jdk-1-8-or-later-to-compile
'Nice programing' 카테고리의 다른 글
Node.js를 통해 Amazon S3에 base64 인코딩 이미지 업로드 (0) | 2020.10.13 |
---|---|
python SimpleHTTPServer를 localhost에서만 실행할 수 있습니까? (0) | 2020.10.13 |
Java의 패턴과 일치하는 디렉토리의 파일 나열 (0) | 2020.10.13 |
Symfony2-자체 공급 업체 번들 생성-프로젝트 및 Git 전략 (0) | 2020.10.13 |
Rails에서 캐스케이드 삭제를 설정할 수 있습니까? (0) | 2020.10.13 |