ant 打包android工程 的问题

mahaiyun18 2013-01-10 10:37:02
通过ant打包android工程,别的问题都解决了,就是我的工程有JNI,标准的apk 在根目录有个libs文件夹,里面放的so文件,但是我现在不能将so打进去,也就是说我生成的apk压根没有libs目录,求解啊,ant怎么打包jni。求教啊!!
...全文
972 33 打赏 收藏 转发到动态 举报
写回复
用AI写文章
33 条回复
切换为时间正序
请发表友善的回复…
发表回复
niyueming 2014-08-19
  • 打赏
  • 举报
回复
引用 31 楼 u012633624 的回复:
还有楼主个人得我应该是没有将.so文件打包进去,我就按照你所说的加了这个 <!-- 打包成未签证的apk --> <target name="package" depends="dex, package-res-and-assets"> <echo>打包成未签证的apk....</echo> <exec executable="${apkbuilder}" failonerror="true"> <arg value="${out-unsigned-package-ospath}" /> <arg value="-u" /> <arg value="-z" /> <arg value="${resources-package-ospath}" /> <arg value="-f" /> <arg value="${dex-ospath}" /> <arg value="-rf" /> <arg value="${srcdir-ospath}" /> <!-- 打包*.so文件 --> <arg line="-nf ${external-lib-ospath}"/> </exec> </target> 加了这个就报错 BUILD FAILED Target "dex" does not exist in the project "Mobile_Net_Credit". It is used from target "package". 以下的是我写的: Total time: 603 milliseconds <?xml version="1.0" encoding="UTF-8"?> <project name="Mobile_Net_Credit" default="help"> <!-- 打包成未签证的apk --> <target name="Mobile_Net_Credit" depends="dex, package-res-and-assets"> <echo>打包成未签证的apk....</echo> <exec executable="${apkbuilder}" failonerror="true"> <arg value="${out-unsigned-package-ospath}" /> <arg value="-u" /> <arg value="-z" /> <arg value="${resources-package-ospath}" /> <arg value="-f" /> <arg value="${dex-ospath}" /> <arg value="-rf" /> <arg value="${srcdir-ospath}" /> <!-- 打包*.so文件 --> <arg line="-nf ${external-lib-ospath}"/> </exec> </target> 也报错,我知道name报错,可是我不是很明白这段话,请楼主帮帮忙吧!
<target name="Mobile_Net_Credit" depends="dex, package-res-and-assets"> 意思好像是这个句里的name=“package”
Darlinezhu88 2014-08-19
  • 打赏
  • 举报
回复
楼主,加我Q吧!我真心请你帮助!QQ:342329654 谢谢!一切尽在不言中。。。。。。。。
Darlinezhu88 2014-08-18
  • 打赏
  • 举报
回复
还有楼主个人得我应该是没有将.so文件打包进去,我就按照你所说的加了这个 <!-- 打包成未签证的apk --> <target name="package" depends="dex, package-res-and-assets"> <echo>打包成未签证的apk....</echo> <exec executable="${apkbuilder}" failonerror="true"> <arg value="${out-unsigned-package-ospath}" /> <arg value="-u" /> <arg value="-z" /> <arg value="${resources-package-ospath}" /> <arg value="-f" /> <arg value="${dex-ospath}" /> <arg value="-rf" /> <arg value="${srcdir-ospath}" /> <!-- 打包*.so文件 --> <arg line="-nf ${external-lib-ospath}"/> </exec> </target> 加了这个就报错 BUILD FAILED Target "dex" does not exist in the project "Mobile_Net_Credit". It is used from target "package". 以下的是我写的: Total time: 603 milliseconds <?xml version="1.0" encoding="UTF-8"?> <project name="Mobile_Net_Credit" default="help"> <!-- 打包成未签证的apk --> <target name="Mobile_Net_Credit" depends="dex, package-res-and-assets"> <echo>打包成未签证的apk....</echo> <exec executable="${apkbuilder}" failonerror="true"> <arg value="${out-unsigned-package-ospath}" /> <arg value="-u" /> <arg value="-z" /> <arg value="${resources-package-ospath}" /> <arg value="-f" /> <arg value="${dex-ospath}" /> <arg value="-rf" /> <arg value="${srcdir-ospath}" /> <!-- 打包*.so文件 --> <arg line="-nf ${external-lib-ospath}"/> </exec> </target> 也报错,我知道name报错,可是我不是很明白这段话,请楼主帮帮忙吧!
Darlinezhu88 2014-08-18
  • 打赏
  • 举报
回复
我也来麻烦楼主了,我最近我在研究ant打包,我的也许暂时没有楼上几位的复杂,我暂不用多渠道打包。。。好了正题:我的是用楼上所说的我是用命令自动生成的build.xml,我打包简单的项目是没有问题的,但是我的项目中又引用了另一个项目,另一个项目中又用到了jni技术,jni中有生成的.so文件,我单独的打主项目是没有问题,主项目引用另一个项目时,就不可以,可以打包,但是运行不了。。楼主有遇到过么?
行者歌途 2014-07-05
  • 打赏
  • 举报
回复
引用 28 楼 gaoxiang_120 的回复:
楼主在吗。。 我也遇到了同样的问题,按照你说把assets目录下的所有文件都拷贝至 工程的 assets 文件夹里面去了。。但是 百度地图 还是用不鸟。。一点就崩溃。。 打包的时候没有报错,但是一大堆的警告,关于百度地图的。。楼主遇到过吗?? 我摘抄一小段。。麻烦看到帮忙分析一下。。弄了好久了,都没解决。。之前一个用高德地图的,用楼主你的办法解决了。 但是这次百度地图 怎么就不行呢?是这个百度地图的jar包 baidumapapi_v2_1_3.jar
[apply] warning: Ignoring InnerClasses attribute for an anonymous inner class
    [apply] (com.baidu.location.g$1) that doesn't come with an
    [apply] associated EnclosingMethod attribute. This class was probably produced by a
    [apply] compiler that did not target the modern .class file format. The recommended
    [apply] solution is to recompile the class from source, using an up-to-date compiler
    [apply] and without specifying any "-target" type options. The consequence of ignoring
    [apply] this warning is that reflective operations on this class will incorrectly
    [apply] indicate that it is *not* an inner class.
    [apply] warning: Ignoring InnerClasses attribute for an anonymous inner class
    [apply] (com.baidu.location.g$2) that doesn't come with an
    [apply] associated EnclosingMethod attribute. This class was probably produced by a
    [apply] compiler that did not target the modern .class file format. The recommended
    [apply] solution is to recompile the class from source, using an up-to-date compiler
    [apply] and without specifying any "-target" type options. The consequence of ignoring
    [apply] this warning is that reflective operations on this class will incorrectly
    [apply] indicate that it is *not* an inner class.
这个问题怎么解决的 能够告知下 谢谢
慢慢的写代码 2013-10-10
  • 打赏
  • 举报
回复
楼主在吗。。 我也遇到了同样的问题,按照你说把assets目录下的所有文件都拷贝至 工程的 assets 文件夹里面去了。。但是 百度地图 还是用不鸟。。一点就崩溃。。 打包的时候没有报错,但是一大堆的警告,关于百度地图的。。楼主遇到过吗?? 我摘抄一小段。。麻烦看到帮忙分析一下。。弄了好久了,都没解决。。之前一个用高德地图的,用楼主你的办法解决了。 但是这次百度地图 怎么就不行呢?是这个百度地图的jar包 baidumapapi_v2_1_3.jar
[apply] warning: Ignoring InnerClasses attribute for an anonymous inner class
    [apply] (com.baidu.location.g$1) that doesn't come with an
    [apply] associated EnclosingMethod attribute. This class was probably produced by a
    [apply] compiler that did not target the modern .class file format. The recommended
    [apply] solution is to recompile the class from source, using an up-to-date compiler
    [apply] and without specifying any "-target" type options. The consequence of ignoring
    [apply] this warning is that reflective operations on this class will incorrectly
    [apply] indicate that it is *not* an inner class.
    [apply] warning: Ignoring InnerClasses attribute for an anonymous inner class
    [apply] (com.baidu.location.g$2) that doesn't come with an
    [apply] associated EnclosingMethod attribute. This class was probably produced by a
    [apply] compiler that did not target the modern .class file format. The recommended
    [apply] solution is to recompile the class from source, using an up-to-date compiler
    [apply] and without specifying any "-target" type options. The consequence of ignoring
    [apply] this warning is that reflective operations on this class will incorrectly
    [apply] indicate that it is *not* an inner class.
louiscarman 2013-09-25
  • 打赏
  • 举报
回复
第三方jar包中的资源文件怎么打进去啊,,,我的一直打不进去。。调用第三方jar包的方法的时候就说资源找不到。。。
mahaiyun18 2013-01-11
  • 打赏
  • 举报
回复
引用 25 楼 ilittleone 的回复:
这个倒是没改过,默认的build文件你在工程下 proguard.config=proguard.cfg开启会自动支持的,,你那份修改的build我不会了 你在 sdk下的build.xml搜索下 proguard 在obfuscate标签处,还有一堆东西,自己研究下吧,看着头晕
嗯嗯 我再看看,谢谢你了
兔子和小鱼干 2013-01-11
  • 打赏
  • 举报
回复
这个倒是没改过,默认的build文件你在工程下 proguard.config=proguard.cfg开启会自动支持的,,你那份修改的build我不会了 你在 sdk下的build.xml搜索下 proguard 在obfuscate标签处,还有一堆东西,自己研究下吧,看着头晕
mahaiyun18 2013-01-11
  • 打赏
  • 举报
回复
引用 23 楼 ilittleone 的回复:
Java code?12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364# This is a configuration file for ProGuard.# http://progu……
谢谢你的帮助,我的意思是说 这个混淆文档我已经有了,什么该混淆什么不混淆已经写好了,只是不知道在build.xml怎么去调用。这个你知道么?
mahaiyun18 2013-01-10
  • 打赏
  • 举报
回复
还有没有哪位大神知道啊,帮帮忙
兔子和小鱼干 2013-01-10
  • 打赏
  • 举报
回复
这个脚本是自己写的吧?这个就不清楚了
mahaiyun18 2013-01-10
  • 打赏
  • 举报
回复
<target name="mk" >



<exec dir="./jni" executable="make" os="Linux" failonerror="true">

</exec>

</target> 

<target name="mkclr" >

<exec dir="./jni" executable="make" os="Linux" failonerror="true">

<arg line=" clean" />

</exec>

</target> 

可是我加了之后apk中仍然没有libs目录,也许是我配置有问题,那个dir是 so文件的目录吗?
mahaiyun18 2013-01-10
  • 打赏
  • 举报
回复
引用 5 楼 ilittleone 的回复:
你看看你的build.xml有没有问题,你先备份下。重新使用系统生成的,如果系统生成的没问题就是你build.xml写的有问题了 生成build.xml不需要脚本,应该是xml写的问题了
系统生成的只有几行脚本,你对ant脚本熟悉吗,网上有人说这样写,你看看
兔子和小鱼干 2013-01-10
  • 打赏
  • 举报
回复
你看看你的build.xml有没有问题,你先备份下。重新使用系统生成的,如果系统生成的没问题就是你build.xml写的有问题了 生成build.xml不需要脚本,应该是xml写的问题了
mahaiyun18 2013-01-10
  • 打赏
  • 举报
回复
引用 3 楼 ilittleone 的回复:
你可以把项目下的build.xml 删除然后cd你的主项目 然后ant debug或者release 一直这样打包。不知道你怎么操作的
我们这个必须要用build.xml 因为我的目的是为了解决多渠道号的问题,要一次生成n多个apk。所以你刚才的命令怎么才能转换成脚本呢,还是写脚本的
兔子和小鱼干 2013-01-10
  • 打赏
  • 举报
回复
你可以把项目下的build.xml 删除然后cd你的主项目
然后ant debug或者release
一直这样打包。不知道你怎么操作的
mahaiyun18 2013-01-10
  • 打赏
  • 举报
回复
引用 1 楼 ilittleone 的回复:
android update project -p . ant debug or ant release
你好我是用build.xml脚本来写的 请问怎么写,能说详细些吗
兔子和小鱼干 2013-01-10
  • 打赏
  • 举报
回复
android update project -p . ant debug or ant release
兔子和小鱼干 2013-01-10
  • 打赏
  • 举报
回复
# This is a configuration file for ProGuard.
# http://proguard.sourceforge.net/index.html#manual/usage.html

# Optimizations: If you don't want to optimize, use the
# proguard-android.txt configuration file instead of this one, which
# turns off the optimization flags.  Adding optimization introduces
# certain risks, since for example not all optimizations performed by
# ProGuard works on all versions of Dalvik.  The following flags turn
# off various optimizations known to have issues, but the list may not
# be complete or up to date. (The "arithmetic" optimization can be
# used if you are only targeting Android 2.0 or later.)  Make sure you
# test thoroughly if you go this route.
-optimizations !code/simplification/arithmetic,!code/simplification/cast,!field/*,!class/merging/*
-optimizationpasses 5
-allowaccessmodification
-dontpreverify

# The remainder of this file is identical to the non-optimized version
# of the Proguard configuration file (except that the other file has
# flags to turn off optimization).

-dontusemixedcaseclassnames
-dontskipnonpubliclibraryclasses
-verbose

-keepattributes *Annotation*
-keep public class com.google.vending.licensing.ILicensingService
-keep public class com.android.vending.licensing.ILicensingService

# For native methods, see http://proguard.sourceforge.net/manual/examples.html#native
-keepclasseswithmembernames class * {
    native <methods>;
}

# keep setters in Views so that animations can still work.
# see http://proguard.sourceforge.net/manual/examples.html#beans
-keepclassmembers public class * extends android.view.View {
   void set*(***);
   *** get*();
}

# We want to keep methods in Activity that could be used in the XML attribute onClick
-keepclassmembers class * extends android.app.Activity {
   public void *(android.view.View);
}

# For enumeration classes, see http://proguard.sourceforge.net/manual/examples.html#enumerations
-keepclassmembers enum * {
    public static **[] values();
    public static ** valueOf(java.lang.String);
}

-keep class * implements android.os.Parcelable {
  public static final android.os.Parcelable$Creator *;
}

-keepclassmembers class **.R$* {
    public static <fields>;
} 我想说这个keep可以不要

# The support library contains references to newer platform versions.
# Don't warn about those in case this app is linking against an older
# platform version.  We know about them, and they are safe.
-dontwarn android.support.**
http://proguard.sourceforge.net/index.html#manual/examples.html 基本就是这样子,具体看你的代码了,第三方的jar一般不需要混淆,反射的,native的统统不能混淆 官方的injar outjar那些可以无视
加载更多回复(13)

80,351

社区成员

发帖
与我相关
我的任务
社区描述
移动平台 Android
androidandroid-studioandroidx 技术论坛(原bbs)
社区管理员
  • Android
  • yechaoa
  • 失落夏天
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧