我已将Google Play Services作为库项目添加到Intelli-J的Android项目中,但看起来资源仍未被IDE识别。当应用程序试图膨胀地图时,出现以下错误:Intellij IDEA无法识别Android库资源
ERROR/AndroidRuntime(16002): FATAL EXCEPTION: main
java.lang.NoClassDefFoundError: com.google.android.gms.R$styleable
at com.google.android.gms.maps.GoogleMapOptions.createFromAttributes(Unknown Source)
at com.google.android.gms.maps.SupportMapFragment.onInflate(Unknown Source)
这是布局XML中片段的代码。
<fragment
xmlns:map="http://schemas.android.com/apk/res-auto"
android:id="@+id/map"
android:layout_width="match_parent"
android:layout_height="200dp"
class="com.google.android.gms.maps.SupportMapFragment"
map:cameraZoom="13"
map:mapType="normal"
map:uiCompass="false"
map:uiRotateGestures="true"
map:uiScrollGestures="false"
map:uiTiltGestures="true"
map:uiZoomGestures="true" />
在maps_attrs.xml
在谷歌播放项目,<declare-styleable name="MapAttrs">
“MapAttrs” 以红色突出显示。
在Eclipse中编译时,代码的功能正确。
有谁知道如何让IDEA识别资源?
检查库的项目配置正确,并添加到依赖关系为主营项目。 JAR文件,如果库项目应该启用** Export **选项。 [检查此问题](http://youtrack.jetbrains.com/issue/IDEA-96525)了解如何在IDEA中导入无源代码的库项目。如果没有帮助,请分享一个示例项目来重现问题。 – CrazyCoder 2013-02-13 23:40:37
一个示例项目在这里:https://github.com/TheDirtyCalvinist/MapStyleable 据我所知,项目属性中的一切都是正确的。我没有发现类的问题,只是资源属性,在这种情况下,可修改的属性。 – 2013-02-14 16:18:19
看来,Intellij错误地生成了google-play-services R.java文件。当在Eclipse中构建google-play-services库时,R.java会被填写,但不会在Intellij中填写。 – 2013-02-14 17:30:33