Android的Maven的插件v3.4.0无法找到可绘制的资源构建的应用程序时, [英] Android-Maven-Plugin v3.4.0 cannot find drawable resources when building app

查看:121
本文介绍了Android的Maven的插件v3.4.0无法找到可绘制的资源构建的应用程序时,的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

最近我开始mavenizing我的Andr​​oid应用程序。其中一个对我的方式的障碍是以下几点: 在构建Maven插件无法找到它们在res目录布局中使用可绘制。 我已经使用Android快速启动原型第一tarted mavenizing:

Recently I started mavenizing my android application. One of the obstacles on my way is following: During build maven plugin cannot find drawables which are used in layouts in res directory. I've tarted mavenizing first by using android quick start archetype:

MVN原型:产生-DarchetypeArtifactId = Android的快速入门-DarchetypeGroupId = de.akquinet.android.archetypes -DarchetypeVersion = 1.0.8

mvn archetype:generate -DarchetypeArtifactId=android-quickstart -DarchetypeGroupId=de.akquinet.android.archetypes -DarchetypeVersion=1.0.8

然后我复制我所有的资源,通过原型所产生的资源目录。 IMHO这应该足够了。但这里是安装什么我得到后MVN清洁:

Then I've copied all my resources to the res directory generated by archetype. IMHO this should be sufficient. But here is what I get after mvn clean install:

[信息] --- Android的Maven的插件:3.4.0:APK(默认APK)@ missnanny,Android的应用程序 -   [信息]复制本地资产文件合并资产目录。   [信息] D:\环境\ AndroidSDK \ Android的SDK \平台工具\ aapt.exe [包,-f,-M,D:\程序\ myproj.com \ MyProj文\ MyProj文,Android的应用程序\ MyprojManifest.xml , - S,D:\程序\ myproj.com \ MyProj文\ MyProj文,Android的应用程序\资源,--auto-附加叠加,-A,D:\程序\ myproj.com \ MyProj文\ MyProj文,Android的应用程序\目标\产生-源\联合资产\资产,-I,D:\环境\ AndroidSDK \ Android的SDK \平台\ Android的7 \的android.jar,-F, D:\Programming\myproj.com\myproj\myproj-android-app\target\myproj-android-app-0.0.1-SNAPSHOT.ap_]

[INFO] --- android-maven-plugin:3.4.0:apk (default-apk) @ missnanny-android-app --- [INFO] Copying local assets files to combined assets directory. [INFO] D:\Environments\AndroidSDK\android-sdk\platform-tools\aapt.exe [package, -f, -M, D:\Programming\myproj.com\myproj\myproj-android-app\MyprojManifest.xml, -S, D:\Programming\myproj.com\myproj\myproj-android-app\res, --auto-add-overlay, -A, D:\Programming\myproj.com\myproj\myproj-android-app\target\generated-sources\combined-assets\assets, -I, D:\Environments\AndroidSDK\android-sdk\platforms\android-7\android.jar, -F, D:\Programming\myproj.com\myproj\myproj-android-app\target\myproj-android-app-0.0.1-SNAPSHOT.ap_]

[信息] D:\程序\ myproj.com \ MyProj文\ MyProj文,Android的应用程序\资源\布局\ layout_1.xml:8:错误:错误:未发现的资源匹配给定名称(在SRC与价值@绘制/图像)。

[INFO] D:\Programming\myproj.com\myproj\myproj-android-app\res\layout\layout_1.xml:8: error: Error: No resource found that matches the given name (at 'src' with value '@drawable/image').

我收到很多这样的错误。他们都是说没有资源可以找到一些layout.xml文件。我在日志中上述变化的项目和资源的名称。真正的名字是不是MyProj文日不同。但是这不应该的问题。在mavenizing我只复制资源转化为原型所产生的资源目录。 在资源文件夹中我有:

I'm getting many such errors. All of them are saying that no resource can be found for some layout.xml file. I've changed name of project and resources in the log above. The real name is th different than myproj. but that shouldn't matter. During mavenizing i've only copied resources into res directory generated by archetype. in res folder I've :

RES /绘制 RES /绘制,华电国际 RES /绘制,MDPI RES /绘制,LDPI RES /布局 RES /生 RES /值 RES /值-PL

res/drawable res/drawable-hdpi res/drawable-mdpi res/drawable-ldpi res/layout res/raw res/values res/values-pl

我想提一提,是没有问题的加载绘制在AndroidManifest.xml中的应用程序图标。所有的问题都conneced与布局,并在drawable.xml选择

I'd like to mention that there is no problem loading drawable in AndroidManifest.xml for application icon. All problems are conneced with layout and selectors in drawable.xml

我POM:

<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>
<parent>
    <groupId>pl.comapny.groupid</groupId>
    <artifactId>projectid</artifactId>
    <version>0.0.1-SNAPSHOT</version>
</parent>
<artifactId>appname-android-app</artifactId>
<packaging>apk</packaging>
<name>appname-android-app</name>

<properties>
    <platform.version> 2.1.2 </platform.version>
</properties>

<dependencies>

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

    <dependency>
        <groupId>pl.company.groupid</groupId>
        <artifactId>artifact</artifactId>
        <version>${project.version}</version>           
    </dependency>

</dependencies>

<build>
    <resources>
      <resource>
         <directory>${project.basedir}/res</directory>
         <filtering>true</filtering>
      </resource>
    </resources>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-resources-plugin</artifactId>
            <!-- <executions>
                <execution>  
                    <phase>initialize</phase>
                    <goals>
                        <goal>copy-resources</goal>
                    </goals>
                    <configuration>
                        <outputDirectory>${project.basedir}/res</outputDirectory>
                        <resources>
                            <resource>
                                <directory>${project.basedir}/src/templates/res</directory>
                                <targetPath>${project.basedir}/res</targetPath>
                                <filtering>true</filtering>
                            </resource>
                        </resources>
                    </configuration>
                </execution>
            </executions> -->
        </plugin>
        <plugin>
            <groupId>com.jayway.maven.plugins.android.generation2</groupId>
            <artifactId>android-maven-plugin</artifactId>
            <version>3.4.0</version> <!--3.4.0, 3.1.1, 3.0.0-alpha-14-->
            <configuration>
                <androidManifestFile>${project.basedir}/AndroidManifest.xml</androidManifestFile>
                <assetsDirectory>${project.basedir}/assets</assetsDirectory>
                <resourceDirectory>${project.basedir}/res</resourceDirectory> 
                <!-- <nativeLibrariesDirectory>${project.basedir}/src/main/native</nativeLibrariesDirectory> -->
                <sdk>
                    <platform>7</platform>
                </sdk>
                <undeployBeforeDeploy>true</undeployBeforeDeploy>
            </configuration>
            <extensions>true</extensions>
        </plugin>

        <plugin>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>2.3.2</version>
            <configuration>
                <source>1.6</source>
                <target>1.6</target>
            </configuration>
        </plugin>
    </plugins>
</build>

推荐答案

好吧,我已经成功地解决我的问题。这是很愚蠢。有问题,这是破坏了一些9片图像。这导致生成失败。看来,日食Android插件接受它被标记为9​​片图像可绘,但实际上他们都没有,和内部就可以完成。至于Maven的Andr​​oid插件情况有所不同。但还是恕我直言错误消息我得到的是inapropriate - 那里让我的重点不是真正的问题。我已经失去了很多时间..我敢肯定,我会找到一个解决方案更快,如果有没有这些错误消息说,没有资源的发现,是否符合给定的名字。这些错误应该由插件被跳过。

Ok, I've managed to solve my problem. This was really stupid. There were problems with some 9 patch images which are corrupted. This resulted in build failure. It seems that eclipse android plugin accepts drawables which are marked as 9 patch image, but in fact they are not, and build can be completed ... As for maven android plugin situation is different. But still imho error messages I was getting were inapropriate - there made me focused not on real problem. I've lost a lot of time.. and I'm sure I would find a solution much faster if there weren't those error messages saying that "no resource found that matches given name". Those errors should be skipped by plugin.

这篇关于Android的Maven的插件v3.4.0无法找到可绘制的资源构建的应用程序时,的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆