1

我正在尝试将在 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
4

1 回答 1

1

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

请按照以下步骤操作:1)下载 sdk 17+ 版本 2)下载maven-android-sdk-deployer项目,并阅读安装说明 3)通过更改属性 4.1 编辑 pom.xml 文件(根)。 1.4 和 16 中的任何一个,具体取决于 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 plugin 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项目并编译

于 2013-12-06T19:44:35.527 回答