在Android-MenuDrawer中编译错误

时间:2013-12-03 20:25:44

标签: android maven intellij-idea navigation-drawer drawer

我正在尝试将在Eclipse中开发的应用程序迁移到Intellij Idea,该应用程序使用ActionBarSherlock和Android-MenuDrawer(SimonVT)

我在使用Maven导入Android-MenuDrawer库时遇到问题。使用ActionBarSherlock编译很好,我可以在项目中很好地使用它,但不能使用MenuDrawer。

当我尝试使用Maven编译时,给出了以下错误:

[ERROR] COMPILATION ERROR : 
[INFO] -------------------------------------------------------------
[ERROR] /D:/Android/menudrawer/menudrawer/src/net/simonvt/menudrawer/MenuDrawer.java:[854,40] cannot find symbol
  symbol:   variable LAYOUT_DIRECTION_RTL
  location: class net.simonvt.menudrawer.MenuDrawer
[ERROR] /D:/Android/menudrawer/menudrawer/src/net/simonvt/menudrawer/MenuDrawer.java:[861,40] cannot find symbol
  symbol:   variable LAYOUT_DIRECTION_RTL
  location: class net.simonvt.menudrawer.MenuDrawer
[ERROR] /D:/Android/menudrawer/menudrawer/src/net/simonvt/menudrawer/MenuDrawer.java:[873,14] cannot find symbol
  symbol: method onRtlPropertiesChanged(int)
[ERROR] /D:/Android/menudrawer/menudrawer/src/net/simonvt/menudrawer/MenuDrawer.java:[882,80] cannot find symbol
  symbol:   variable LAYOUT_DIRECTION_RTL
  location: class net.simonvt.menudrawer.MenuDrawer
[ERROR] /D:/Android/menudrawer/menudrawer/src/net/simonvt/menudrawer/MenuDrawer.java:[871,5] method does not override or implement a method from a supertype
[ERROR] /D:/Android/menudrawer/menudrawer/src/net/simonvt/menudrawer/MenuDrawer.java:[1325,72] cannot find symbol
  symbol:   variable LAYOUT_DIRECTION_RTL
  location: class net.simonvt.menudrawer.MenuDrawer
[ERROR] /D:/Android/menudrawer/menudrawer/src/net/simonvt/menudrawer/ViewHelper.java:[44,57] cannot find symbol
  symbol:   variable JELLY_BEAN_MR1
  location: class android.os.Build.VERSION_CODES
[ERROR] /D:/Android/menudrawer/menudrawer/src/net/simonvt/menudrawer/ViewHelper.java:[45,21] cannot find symbol
  symbol:   method getLayoutDirection()
  location: variable v of type android.view.View
[ERROR] /D:/Android/menudrawer/menudrawer/src/net/simonvt/menudrawer/ViewHelper.java:[48,20] cannot find symbol
  symbol:   variable LAYOUT_DIRECTION_LTR
  location: class android.view.View

1 个答案:

答案 0 :(得分:1)

我可以找到错误。 问题是android sdk的依赖性,actal是4.1.1.4(api 16)是maven存储库中的最后一个。但该项目需要api 17 +

请按以下步骤操作: 1)下载sdk 17+的版本 2)下载maven-android-sdk-deployer项目,并阅读安装说明 3)通过更改属性4.1.1.4和16来编辑pom.xml文件(根) 通过以下任何一种方式,具体取决于SDK:

<android.version>4.2.2_r2</android.version>
<android.platform>17</android.platform>

<android.version>4.3_r2</android.version>
<android.platform>18</android.platform>

<android.version>4.4_r1</android.version>
<android.platform>19</android.platform>

并编辑

<dependency>
    <groupId>com.google.android</groupId>
    <artifactId>android</artifactId>
    <version>${android.version}</version>
</dependency>

通过

<dependency>
    <groupId>android</groupId>
    <artifactId>android</artifactId>
    <version>${android.version}</version>
</dependency>

还需要将maven插件3.6.0的版本更新为3.8.0。

改变这个:

<plugin>
    <groupId>com.jayway.maven.plugins.android.generation2</groupId>
    <artifactId>android-maven-plugin</artifactId>
    <version>3.6.0</version>
    <configuration>
        <sdk>
            <platform>${android.platform}</platform>
        </sdk>
    </configuration>
    <extensions>true</extensions>
</plugin>

由此:

<plugin>
    <groupId>com.jayway.maven.plugins.android.generation2</groupId>
    <artifactId>android-maven-plugin</artifactId>
    <version>3.8.0</version>
    <configuration>
        <sdk>
            <platform>${android.platform}</platform>
        </sdk>
    </configuration>
    <extensions>true</extensions>
</plugin>

4)编辑pom.xml(menudrawer文件夹) 编辑以下内容:

<dependency>
    <groupId>com.google.android</groupId>
    <artifactId>android</artifactId>
    <scope>provided</scope>
</dependency>

通过

<dependency>
    <groupId>android</groupId>
    <artifactId>android</artifactId>
    <scope>provided</scope>
</dependency>

为maven项目充电并编译