gpt4 book ai didi

android - Maven + RoboGuice + ActionBarSherlock + RoboGuice-Sherlock

转载 作者:太空宇宙 更新时间:2023-11-03 10:48:24 26 4
gpt4 key购买 nike

我正在尝试使用 android-quickstart 原型(prototype)创建一个 Android 基础项目,并添加 RoboGuice、ActionBarSherlock 依赖项以及 RoboGuice-Sherlock 以将两者结合起来。

这是我的 pom.xml:

   <?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.myapp</groupId>
<artifactId>BaseApp</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>apk</packaging>
<name>BaseApp</name>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<platform.version> 4.1.1.4
</platform.version>
<android.plugin.version>3.6.0</android.plugin.version>
</properties>

<dependencies>
<dependency>
<groupId>com.google.android</groupId>
<artifactId>android</artifactId>
<version>${platform.version}</version>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>org.roboguice</groupId>
<artifactId>roboguice</artifactId>
<version>2.0</version>
</dependency>

<dependency>
<groupId>com.google.code.findbugs</groupId>
<artifactId>jsr305</artifactId>
<version>1.3.9</version>
</dependency>

<dependency>
<groupId>com.actionbarsherlock</groupId>
<artifactId>actionbarsherlock</artifactId>
<version>4.4.0</version>
<type>apklib</type>
</dependency>


<dependency>
<groupId>com.github.rtyley</groupId>
<artifactId>roboguice-sherlock</artifactId>
<version>1.5</version>
</dependency>

</dependencies>



<build>
<finalName>${project.artifactId}</finalName>
<pluginManagement>
<plugins>
<plugin>
<groupId>com.jayway.maven.plugins.android.generation2</groupId>
<artifactId>android-maven-plugin</artifactId>
<version>${android.plugin.version}</version>
<extensions>true</extensions>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>com.jayway.maven.plugins.android.generation2</groupId>
<artifactId>android-maven-plugin</artifactId>
<configuration>
<sdk>
<platform>16</platform>
</sdk>
</configuration>
</plugin>
</plugins>
</build>
</project>

但是 m2eclipse 无法使用此 Pom.xml,因为它无法找到 apklib 依赖项。具体来说,我在 Eclipse 中的“问题”选项卡下收到以下消息:

dependency=[com.actionbarsherlock:actionbarsherlock:apklib:4.4.0:compile] not found in workspace    pom.xml /BaseApp    line 1  me.gladwell.eclipse.m2e.android.markers.dependency.apklib

我试过删除 <type>apklib</type>行,但我的 ABS 资源(即所需的主题)没有导入到项目中。

我读过 several questions apklib 类型仅适用于命令行,如果我想坚持使用 IDE,我需要手动将 ABS 作为库导入。我做到了,但随后 RoboGuice 崩溃了,因为该项目变成了一个库项目,显然,库项目中的资源 ID 不再是最终的。 (我得到的编译时错误是“注释属性 InjectView.value 的值必须是常量表达式”)。作为引用,这是我唯一的 Activity :

public class HelloAndroidActivity extends RoboSherlockActivity {

@InjectView(R.id.helloworld) TextView textView;

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
textView.setText("Roboguice says Hello World");
}

}

是否有任何正确的方法可以使用 maven 和 Eclipse 创建包含这三个元素的基础项目?

最佳答案

原来我不小心点击了项目属性上的“是库”复选框。现在它可以与作为库手动导入的 ABS 一起使用。

可惜不能直接使用Maven :(

关于android - Maven + RoboGuice + ActionBarSherlock + RoboGuice-Sherlock,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18203957/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com