IDEA 12 CE, Android & OS X
Hi,
I use IntelliJ professionally and wanted to have a go at some Android development in my spare time. I've run into some problems though and I'm at a loss.
I've installed the Oracle 1.7 (u13) JDK and IntelliJ 12 CE and used the Android SDK Manager to download all the Android 4.2 stuff. I've even worked around the problem with having to set up a Java project to get IntelliJ to pick up the JDK.
The problem I'm having is that if I create a new "Android Module" project and point it at the Android 4.2 SDK in concert with the Java 1.7 SDK, I can't make the project:
java: Errors occurred while compiling module 'Torch' Compilation completed with 7 errors and 7 warnings in 2 sec 7 errors 7 warnings java: warning: java/lang/annotation/Target.class(java/lang/annotation:Target.class): major version 51 is newer than 50, the highest major version supported by this compiler. It is recommended that the compiler be upgraded. java: warning: java/lang/annotation/ElementType.class(java/lang/annotation:ElementType.class): major version 51 is newer than 50, the highest major version supported by this compiler. It is recommended that the compiler be upgraded. java: warning: java/lang/annotation/Retention.class(java/lang/annotation:Retention.class): major version 51 is newer than 50, the highest major version supported by this compiler. It is recommended that the compiler be upgraded. java: warning: java/lang/annotation/RetentionPolicy.class(java/lang/annotation:RetentionPolicy.class): major version 51 is newer than 50, the highest major version supported by this compiler. It is recommended that the compiler be upgraded. /Users/simon/IdeaProjects/Torch/src/uk/co/realityswitch/torch/Torch/MyActivity.java java: /Users/simon/IdeaProjects/Torch/src/uk/co/realityswitch/torch/Torch/MyActivity.java:3: package android.app does not exist java: /Users/simon/IdeaProjects/Torch/src/uk/co/realityswitch/torch/Torch/MyActivity.java:4: package android.os does not exist java: /Users/simon/IdeaProjects/Torch/src/uk/co/realityswitch/torch/Torch/MyActivity.java:6: cannot find symbol symbol: class Activity java: /Users/simon/IdeaProjects/Torch/src/uk/co/realityswitch/torch/Torch/MyActivity.java:11: cannot find symbol symbol : class Bundle location: class uk.co.realityswitch.torch.Torch.MyActivity java: warning: java/lang/Override.class(java/lang:Override.class): major version 51 is newer than 50, the highest major version supported by this compiler. It is recommended that the compiler be upgraded. java: warning: java/lang/annotation/Annotation.class(java/lang/annotation:Annotation.class): major version 51 is newer than 50, the highest major version supported by this compiler. It is recommended that the compiler be upgraded.
The IDE itself doesn't seem able to resolve classes from the Android SDK (see attachment).
Additionally, Although IntelliJ created the project and there's an ant build.xml, it doesn't process it into the "Ant Build" panel. If I manually add the this file to the Ant Build panel, I can use the targets in there to build the project successfully.
Incidentally, I can build the project without having to edit anything using ant on the command line.
I know and like the IntelliJ IDE and would prefer to use it over the Eclipse bundled with the Android SDK.
Attachment(s):
IDE.jpg
请先登录再写评论。
Hello,
It looks like a bug in the IDE: we're trying to compile project by JDK 1.6 used for running IDEA instead of JDK 1.7 configured in the project. Please, try to choose JDK 1.7 as project SDK and Android 4.2 as SDK for your module
I've attached some screenshots of the project settings - are they set appropriately? I'm not sure if there are any further settings that might need to be changed?
Attachment(s):
android_sdk.jpg
java_sdk.jpg
project.jpg
No, I asked you to try to set project SDK to JDK 1.7 (it's probably called "1.7") itself instead of "Android 4.2 SDK". Also, choose Android 4.2 SDK as MODULE sdk (File | Project Structure | Modules | Choose your module | Dependencies | Module SDK)
I see now; it was very late when I read that and I was pretty frustrated so I missed your meaning. In any case, those settings produce a more favourable compile but it was still broken because IntelliJ had picked up the wrong classpath for the Android SDK. It had decided on:
android_sdk_install_dir/platforms/android-17/data/res
I've since changed that to:
android_sdk_install_dir/platforms/android-17/android.jar
And added the sources at:
android_sdk_install_dir/sources/android-17
And finally the documentation at:
android_sdk_install_dir/docs/reference
The important stuff all seems to be working now: I can build the app, "quick documentation" is working, I can see source for the APIs and debug it on my handset. I'm very much looking forward to saying goodbye to Eclipse.
Further notes:
So, thanks Eugene!
Actually the problem should be already fixed in IDEA 12.1 EAP, so please try it