其他分享
首页 > 其他分享> > android – Maven RoboGuice ActionBarSherlock RoboGuice-Sherlock

android – Maven RoboGuice ActionBarSherlock RoboGuice-Sherlock

作者:互联网

我正在尝试使用android-quickstart原型创建一个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的“Problems”选项卡下收到以下消息:

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的值必须是常量表达式”).作为参考,这是我唯一的活动:

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创建这三个元素的基础项目?

解决方法:

结果我不小心点击了Project Properties上的“Is Library”复选框.现在它可以手动导入ABS作为库.

很遗憾虽然不能直接使用Maven

标签:android,actionbarsherlock,maven,roboguice
来源: https://codeday.me/bug/20190709/1408594.html