我正在尝试将 cocos2d 包含到一个预先存在的应用程序中。我已经以 Eclipse 的方式完成了一些事情,例如设置“isLibrary”并将库项目添加到 Eclipse 中的构建路径,并且我在应用程序的 pom.xml 中具有以下依赖项:
<dependency>
<groupId>cocos2d_android</groupId>
<artifactId>cocos2d_android</artifactId>
<version>1.0.0-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
我以为这会解决这个问题,但是当我构建时,这个库似乎没有包含在内。我知道这一点是因为当我启动一个 Activity,SimpleGame,引用 cocos2d 源中的一个类时,Activity 结束,我在 DDMS 中得到这个堆栈跟踪:
E/AndroidRuntime(10621): 致命异常: main
E/Android运行时(10621): java.lang.NoClassDefFoundError: org.cocos2d.opengl.CCGLSurfaceView
E/AndroidRuntime(10621): 在 com.xyz.game.SimpleGame.onCreate(SimpleGame.java:22)
...
我在寻找两件事:
1) 一种查看某个类/jar/任何东西是否打包到我的 apk 中的可靠方法,因为现在在我的应用程序中达到这一点的步骤又长又复杂
2) 主应用程序或库项目的 Manifest 或 pom.xml 中似乎缺少某些内容 - 需要向 Maven 发出信号以选择另一个项目的内容 - 它是什么?
我正在使用插件的 Maven 3.0.4 和 3.0.0-alpha-13,为 8 级及更高级别构建。
最佳答案
1) a reliable way to see if a certain class/jar/whatever was packaged up into my apk, as the steps to get to this point in my app are long and complicated right now
从命令行构建项目(即 mvn clean install),maven 将在构建的每个阶段/目标期间输出详细日志,在 dex 目标中,您可以看到如下内容:
[INFO] --- android-maven-plugin:3.1.1:dex (default-dex) @ myproject ---
[INFO] C:\Program Files\Java\jdk1.6.0_21\jre\bin\java [-Xmx1024M, -jar, C:\Progr am Files\Android\android-sdk-r16\platform-tools\lib\dx.jar, --dex, --output=C:\workspace\myproject\target\classes.dex, C:\workspace\myproject\target\classes, C:\maven\repository\cocos2d_android\cocos2d_android\1.0.0-SNAPSHOT\cocos2d_android-1.0.0-SNAPSHOT.apklib, C:\maven\repository\com\google\code\gson\gson\1.7.1\gson-1.7.1.jar, ... ...]
Android 库项目实际上被 dex-ed 为 cocos2d_android-1.0.0-SNAPSHOT.apklib 和一些其他常规的 jar 库存档。
2) Something in the Manifest or pom.xml for either the main app or the library project seems to be missing - something needed to signal to Maven to pick up this other project - what is it?
它是 ApkLib,它只是 Android 库项目(src/、res/、AndroidManifest.xml 等)的 zip 存档。我们通常会创建/实现自己的 Android Library Project,并将依赖的 Android Project 作为多模块 maven 项目,但是,如果您需要引用其他开发人员编写的 Android Library Project,则没有必要这样做。感谢开发者,android-maven-plugin 已经支持非 Maven Android 库项目,查看 Compatible with non-Maven Android Library Projects :
The generated .apklib file will have the layout of a standard Android/Eclipse library project. This means that regardless of your Maven layout, the layout inside the .apklib file will be that source code is in "src/" instead of "src/main/java/", but still interpreted correctly when used in an Android/Maven application project. This is to be compatible with non-Maven developers' library projects, which is important to grow the Android developer community.
Use other non-Maven developers' libraries
It also means we can take any external Android library project zip file (from non-Maven developers) and do mvn install:install-file ... on it and simply start using it as a dependency.
Share your .apklib with non-Maven developers
To share your .apklib file with a non-Maven developer, they will probably feel more comfortable if you rename it to .zip. They can then simply unpack it in a directory and use it from there.
所以解决方法是:
将您的 Android Library 项目正确打包到 zip 存档中,然后将其重命名为 something.apklib。
使用 mvn install:install-file 将 something.apklib 安装到您的 Maven 本地存储库中。
在任何需要依赖库的 Android 项目中,只需使用:
<dependency>
<groupId>cocos2d_android</groupId>
<artifactId>cocos2d_android</artifactId>
<version>1.0.0-SNAPSHOT</version>
<type>apklib</type>
</dependency>
查看 Samples在 android-maven-plugin 网站上查看如何正确使用 apklib。
关于android - 添加 Eclipse "Android Library"项目并通过 Maven 构建,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9931039/
我正在尝试测试是否存在表单。我是Rails新手。我的new.html.erb_spec.rb文件的内容是:require'spec_helper'describe"messages/new.html.erb"doit"shouldrendertheform"dorender'/messages/new.html.erb'reponse.shouldhave_form_putting_to(@message)with_submit_buttonendendView本身,new.html.erb,有代码:当我运行rspec时,它失败了:1)messages/new.html.erbshou
当我使用Bundler时,是否需要在我的Gemfile中将其列为依赖项?毕竟,我的代码中有些地方需要它。例如,当我进行Bundler设置时:require"bundler/setup" 最佳答案 没有。您可以尝试,但首先您必须用鞋带将自己抬离地面。 关于ruby-我需要将Bundler本身添加到Gemfile中吗?,我们在StackOverflow上找到一个类似的问题: https://stackoverflow.com/questions/4758609/
我在从html页面生成PDF时遇到问题。我正在使用PDFkit。在安装它的过程中,我注意到我需要wkhtmltopdf。所以我也安装了它。我做了PDFkit的文档所说的一切......现在我在尝试加载PDF时遇到了这个错误。这里是错误:commandfailed:"/usr/local/bin/wkhtmltopdf""--margin-right""0.75in""--page-size""Letter""--margin-top""0.75in""--margin-bottom""0.75in""--encoding""UTF-8""--margin-left""0.75in""-
如何在buildr项目中使用Ruby?我在很多不同的项目中使用过Ruby、JRuby、Java和Clojure。我目前正在使用我的标准Ruby开发一个模拟应用程序,我想尝试使用Clojure后端(我确实喜欢功能代码)以及JRubygui和测试套件。我还可以看到在未来的不同项目中使用Scala作为后端。我想我要为我的项目尝试一下buildr(http://buildr.apache.org/),但我注意到buildr似乎没有设置为在项目中使用JRuby代码本身!这看起来有点傻,因为该工具旨在统一通用的JVM语言并且是在ruby中构建的。除了将输出的jar包含在一个独特的、仅限ruby
尝试通过RVM将RubyGems升级到版本1.8.10并出现此错误:$rvmrubygemslatestRemovingoldRubygemsfiles...Installingrubygems-1.8.10forruby-1.9.2-p180...ERROR:Errorrunning'GEM_PATH="/Users/foo/.rvm/gems/ruby-1.9.2-p180:/Users/foo/.rvm/gems/ruby-1.9.2-p180@global:/Users/foo/.rvm/gems/ruby-1.9.2-p180:/Users/foo/.rvm/gems/rub
为了将Cucumber用于命令行脚本,我按照提供的说明安装了arubagem。它在我的Gemfile中,我可以验证是否安装了正确的版本并且我已经包含了require'aruba/cucumber'在'features/env.rb'中为了确保它能正常工作,我写了以下场景:@announceScenario:Testingcucumber/arubaGivenablankslateThentheoutputfrom"ls-la"shouldcontain"drw"假设事情应该失败。它确实失败了,但失败的原因是错误的:@announceScenario:Testingcucumber/ar
我有一个ModularSinatra应用程序,我正在尝试将Bootstrap添加到应用程序中。get'/bootstrap/application.css'doless:"bootstrap/bootstrap"end我在views/bootstrap中有所有less文件,包括bootstrap.less。我收到这个错误:Less::ParseErrorat/bootstrap/application.css'reset.less'wasn'tfound.Bootstrap.less的第一行是://CSSReset@import"reset.less";我尝试了所有不同的路径格式,但它
我正在使用puppet为ruby程序提供一组常量。我需要提供一组主机名,我的程序将对其进行迭代。在我之前使用的bash脚本中,我只是将它作为一个puppet变量hosts=>"host1,host2"我将其提供给bash脚本作为HOSTS=显然这对ruby不太适用——我需要它的格式hosts=["host1","host2"]自从phosts和putsmy_array.inspect提供输出["host1","host2"]我希望使用其中之一。不幸的是,我终其一生都无法弄清楚如何让它发挥作用。我尝试了以下各项:我发现某处他们指出我需要在函数调用前放置“function_”……这
我正在使用Sequel构建一个愿望list系统。我有一个wishlists和itemstable和一个items_wishlists连接表(该名称是续集选择的名称)。items_wishlists表还有一个用于facebookid的额外列(因此我可以存储opengraph操作),这是一个NOTNULL列。我还有Wishlist和Item具有续集many_to_many关联的模型已建立。Wishlist类也有:selectmany_to_many关联的选项设置为select:[:items.*,:items_wishlists__facebook_action_id].有没有一种方法可以
我正在编写一个gem,我必须在其中fork两个启动两个webrick服务器的进程。我想通过基类的类方法启动这个服务器,因为应该只有这两个服务器在运行,而不是多个。在运行时,我想调用这两个服务器上的一些方法来更改变量。我的问题是,我无法通过基类的类方法访问fork的实例变量。此外,我不能在我的基类中使用线程,因为在幕后我正在使用另一个不是线程安全的库。所以我必须将每个服务器派生到它自己的进程。我用类变量试过了,比如@@server。但是当我试图通过基类访问这个变量时,它是nil。我读到在Ruby中不可能在分支之间共享类变量,对吗?那么,还有其他解决办法吗?我考虑过使用单例,但我不确定这是