源码打包成apk(源码打包成appx)

今天给各位分享源码打包成apk的知识,其中也会对源码打包成appx进行解释,如果能碰巧解决你现在面临的问题,别忘了关注本站,现在开始吧!

本文目录一览:

如何用Android 源码生成APK签名文件

我们很多应用需要用到系统签名,可以通过生成系统签名文件,在生成apk时使用这个签名,然后可以安装到机器中,不需要放在源码里编译,重新刷系统。

先附上 50和 20机器人通用的debugkey(图已经省略)

在Linux环境中,以Android源码目录为根目录。

其中的platform.pk8是制作系统签名需要的文件。

1、在这个目录下,执行

生成临时文件platform.pem

2、接着执行以下命令,将在目录下生成platform.p12文件,它本质上应该就是一个数字证书

3、然后再执行以下命令出现以下信息,表示成功生成platform.jks

这个名字可以改成debug.keystore. 它的后缀本身是没有关系,eclipse和AS都识别 platform.jks

4、然后在打包 apk 的时候选择platform.jks文件,就可以直接用adb命令安装apk到机器中了。

xxxx表示需要安装的apk路径

5、签名的 Key store password和Key password都是android

网上下的APP源码,问问大佬怎么变成APK格式

到网上搜索下安卓开发环境搭建,用eclipse打开这个文件夹运行编译就可以了。

源码打包apk使用RecyclerView时遇到的坑

最近在做一个系统通知栏的项目叫MsgCenter。使用Android studio开发的.

使用了脚本拷贝与复制

LIBS="/Users/love/Desktop/moran2/MsgCenter/app/libs"

SRC="/Users/love/Desktop/moran2/MsgCenter/app/src/main/java/*"

RES="/Users/love/Desktop/moran2/MsgCenter/app/src/main/res"

ANDROIDMANIFEST="app/src/main/AndroidManifest.xml"

DES="/Users/love/Desktop/moran2/MsgCenter/MsgCenter"

mkdir -p $DES/src

cp -r LIBS DES

cp -r SRC DES/src

cp -r RES DES

cp -r JNI DES

cp ANDROIDMANIFEST DES

cp ANDROIDMK DES

然后提交到服务器打包报错:

E/AndroidRuntime: FATAL EXCEPTION: main

Process: net.imoran.notification.lib, PID: 2630

java.lang.ExceptionInInitializerError

at net.imoran.notification.lib.windowmanager.NotificationWindowManager.getInstance(NotificationWindowManager.java:115)

at net.imoran.notification.lib.service.StarStatusService.onBind(StarStatusService.java:32)

at android.app.ActivityThread.handleBindService(ActivityThread.java:3158)

at android.app.ActivityThread.-wrap2(ActivityThread.java)

at android.app.ActivityThread H.handleMessage(ActivityThread.java:1582) at android.os.Handler.dispatchMessage(Handler.java:111) at android.os.Looper.loop(Looper.java:207) at android.app.ActivityThread.main(ActivityThread.java:5795) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit MethodAndArgsCaller.run(ZygoteInit.java:834)

at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:724)

Caused by: android.view.InflateException: Binary XML file line #7: Binary XML file line #7: Error inflating class android.support.v7.widget.RecyclerView

at android.view.LayoutInflater.inflate(LayoutInflater.java:539)

at android.view.LayoutInflater.inflate(LayoutInflater.java:423)

at android.view.LayoutInflater.inflate(LayoutInflater.java:374)

at net.imoran.notification.lib.manager.NotificationManager.initRootView(NotificationManager.java:51)

at net.imoran.notification.lib.windowmanager.NotificationWindowManager.initAdapterView(NotificationWindowManager.java:200)

at net.imoran.notification.lib.windowmanager.NotificationWindowManager.init(NotificationWindowManager.java:123)

at net.imoran.notification.lib.windowmanager.NotificationWindowManager.init(NotificationWindowManager.java:34)

at net.imoran.notification.lib.windowmanager.NotificationWindowManager InnerNotificationWindowManager.(NotificationWindowManager.java:111) at net.imoran.notification.lib.windowmanager.NotificationWindowManager.getInstance(NotificationWindowManager.java:115) at net.imoran.notification.lib.service.StarStatusService.onBind(StarStatusService.java:32) at android.app.ActivityThread.handleBindService(ActivityThread.java:3158) at android.app.ActivityThread.-wrap2(ActivityThread.java) at android.app.ActivityThread H.handleMessage(ActivityThread.java:1582)

at android.os.Handler.dispatchMessage(Handler.java:111)

at android.os.Looper.loop(Looper.java:207)

at android.app.ActivityThread.main(ActivityThread.java:5795)

at java.lang.reflect.Method.invoke(Native Method)

at com.android.internal.os.ZygoteInit MethodAndArgsCaller.run(ZygoteInit.java:834) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:724) Caused by: android.view.InflateException: Binary XML file line #7: Error inflating class android.support.v7.widget.RecyclerView at android.view.LayoutInflater.createView(LayoutInflater.java:645) at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:764) at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704) at android.view.LayoutInflater.rInflate(LayoutInflater.java:835) at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:798) at android.view.LayoutInflater.inflate(LayoutInflater.java:515) at android.view.LayoutInflater.inflate(LayoutInflater.java:423) at android.view.LayoutInflater.inflate(LayoutInflater.java:374) at net.imoran.notification.lib.manager.NotificationManager.initRootView(NotificationManager.java:51) at net.imoran.notification.lib.windowmanager.NotificationWindowManager.initAdapterView(NotificationWindowManager.java:200) at net.imoran.notification.lib.windowmanager.NotificationWindowManager.(NotificationWindowManager.java:123) at net.imoran.notification.lib.windowmanager.NotificationWindowManager.(NotificationWindowManager.java:34) at net.imoran.notification.lib.windowmanager.NotificationWindowManager InnerNotificationWindowManager.clinit(NotificationWindowManager.java:111)

at net.imoran.notification.lib.windowmanager.NotificationWindowManager.getInstance(NotificationWindowManager.java:115)

at net.imoran.notification.lib.service.StarStatusService.onBind(StarStatusService.java:32)

at android.app.ActivityThread.handleBindService(ActivityThread.java:3158)

at android.app.ActivityThread.-wrap2(ActivityThread.java)

at android.app.ActivityThread H.handleMessage(ActivityThread.java:1582) at android.os.Handler.dispatchMessage(Handler.java:111) at android.os.Looper.loop(Looper.java:207) at android.app.ActivityThread.main(ActivityThread.java:5795) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit MethodAndArgsCaller.run(ZygoteInit.java:834)

at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:724)

Caused by: java.lang.reflect.InvocationTargetException

at java.lang.reflect.Constructor.newInstance(Native Method)

at android.view.LayoutInflater.createView(LayoutInflater.java:619)

at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:764)

at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704)

at android.view.LayoutInflater.rInflate(LayoutInflater.java:835)

at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:798)

at android.view.LayoutInflater.inflate(LayoutInflater.java:515)

at android.view.LayoutInflater.inflate(LayoutInflater.java:423)

at android.view.LayoutInflater.inflate(LayoutInflater.java:374)

at net.imoran.notification.lib.manager.NotificationManager.initRootView(NotificationManager.java:51)

at net.imoran.notification.lib.windowmanager.NotificationWindowManager.initAdapterView(NotificationWindowManager.java:200)

at net.imoran.notification.lib.windowmanager.NotificationWindowManager.init(NotificationWindowManager.java:123)

at net.imoran.notification.lib.windowmanager.NotificationWindowManager.init(NotificationWindowManager.java:34)

at net.imoran.notification.lib.windowmanager.NotificationWindowManager InnerNotificationWindowManager.(NotificationWindowManager.java:111) at net.imoran.notification.lib.windowmanager.NotificationWindowManager.getInstance(NotificationWindowManager.java:115) at net.imoran.notification.lib.service.StarStatusService.onBind(StarStatusService.java:32) at android.app.ActivityThread.handleBindService(ActivityThread.java:3158) at android.app.ActivityThread.-wrap2(ActivityThread.java) at android.app.ActivityThread H.handleMessage(ActivityThread.java:1582)

at android.os.Handler.dispatchMessage(Handler.java:111)

at android.os.Looper.loop(Looper.java:207)

at android.app.ActivityThread.main(ActivityThread.java:5795)

at java.lang.reflect.Method.invoke(Native Method)

at com.android.internal.os.ZygoteInit MethodAndArgsCaller.run(ZygoteInit.java:834) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:724) Caused by: java.lang.NoClassDefFoundError: Failed resolution of: Landroid/support/v7/recyclerview/R styleable;

at android.support.v7.widget.RecyclerView.init(RecyclerView.java:590)

at android.support.v7.widget.RecyclerView.init(RecyclerView.java:551)

at java.lang.reflect.Constructor.newInstance(Native Method)

at android.view.LayoutInflater.createView(LayoutInflater.java:619)

at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:764)

at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704)

at android.view.LayoutInflater.rInflate(LayoutInflater.java:835)

at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:798)

at android.view.LayoutInflater.inflate(LayoutInflater.java:515)

at android.view.LayoutInflater.inflate(LayoutInflater.java:423)

at android.view.LayoutInflater.inflate(LayoutInflater.java:374)

at net.imoran.notification.lib.manager.NotificationManager.initRootView(NotificationManager.java:51)

at net.imoran.notification.lib.windowmanager.NotificationWindowManager.initAdapterView(NotificationWindowManager.java:200)

at net.imoran.notification.lib.windowmanager.NotificationWindowManager.init(NotificationWindowManager.java:123)

at net.imoran.notification.lib.windowmanager.NotificationWindowManager.init(NotificationWindowManager.java:34)

at net.imoran.notification.lib.windowmanager.NotificationWindowManager InnerNotificationWindowManager.(NotificationWindowManager.java:111) at net.imoran.notification.lib.windowmanager.NotificationWindowManager.getInstance(NotificationWindowManager.java:115) at net.imoran.notification.lib.service.StarStatusService.onBind(StarStatusService.java:32) at android.app.ActivityThread.handleBindService(ActivityThread.java:3158) at android.app.ActivityThread.-wrap2(ActivityThread.java) at android.app.ActivityThread H.handleMessage(ActivityThread.java:1582)

at android.os.Handler.dispatchMessage(Handler.java:111)

at android.os.Looper.loop(Looper.java:207)

at android.app.ActivityThread.main(ActivityThread.java:5795)

at java.lang.reflect.Method.invoke(Native Method)

at com.android.internal.os.ZygoteInit MethodAndArgsCaller.run(ZygoteInit.java:834) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:724) Caused by: java.lang.ClassNotFoundException: Didn't find class "android.support.v7.recyclerview.R styleable" on path: DexPathList[[zip file "/flysystem/app/mor-notification.apk"],nativeLibraryDirectories=[/system/lib64/mor-notification, /flysystem/app/mor-notification.apk!/lib/arm64-v8a, /vendor/lib64, /system/lib64]]

at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)

at java.lang.ClassLoader.loadClass(ClassLoader.java:511)

at java.lang.ClassLoader.loadClass(ClassLoader.java:469)

at android.support.v7.widget.RecyclerView.init(RecyclerView.java:590)

at android.support.v7.widget.RecyclerView.init(RecyclerView.java:551)

at java.lang.reflect.Constructor.newInstance(Native Method)

at android.view.LayoutInflater.createView(LayoutInflater.java:619)

at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:764)

at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704)

at android.view.LayoutInflater.rInflate(LayoutInflater.java:835)

at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:798)

at android.view.LayoutInflater.inflate(LayoutInflater.java:515)

at android.view.LayoutInflater.inflate(LayoutInflater.java:423)

at android.view.LayoutInflater.inflate(LayoutInflater.java:374)

at net.imoran.notification.lib.manager.NotificationManager.initRootView(NotificationManager.java:51)

at net.imoran.notification.lib.windowmanager.NotificationWindowManager.initAdapterView(NotificationWindowManager.java:200)

at net.imoran.notification.lib.windowmanager.NotificationWindowManager.init(NotificationWindowManager.java:123)

at net.imoran.notification.lib.windowmanager.NotificationWindowManager.init(NotificationWindowManager.java:34)

at net.imoran.notification.lib.windowmanager.NotificationWindowManager InnerNotificationWindowManager.(NotificationWindowManager.java:111) at net.imoran.notification.lib.windowmanager.NotificationWindowManager.getInstance(NotificationWindowManager.java:115) at net.imoran.notification.lib.service.StarStatusService.onBind(StarStatusService.java:32) at android.app.ActivityThread.handleBindService(ActivityThread.java:3158) at android.app.ActivityThread.-wrap2(ActivityThread.java) at android.app.ActivityThread H.handleMessage(ActivityThread.java:1582)

at android.os.Handler.dispatchMessage(Handler.java:111)

at android.os.Looper.loop(Looper.java:207)

at android.app.ActivityThread.main(ActivityThread.java:5795)

at java.lang.reflect.Method.invoke(Native Method)

at com.android.internal.os.ZygoteInit MethodAndArgsCaller.run(ZygoteInit.java:834) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:724) Suppressed: java.lang.ClassNotFoundException: android.support.v7.recyclerview.R styleable

at java.lang.Class.classForName(Native Method)

at java.lang.BootClassLoader.findClass(ClassLoader.java:781)

at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)

at java.lang.ClassLoader.loadClass(ClassLoader.java:504)

... 28 more

Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack trace available

07-20 14:14:31.557 2630-2664/net.imoran.notification.lib I/System: FinalizerDaemon: finalize objects = 2695

从log中我们可以看到,

1.Binary XML file line #22: Binary XML file line #39: Error inflating class android.support.v7.widget.RecyclerView

2.同时还有这样的 java.lang.NoClassDefFoundError: Failed resolution of: Landroid/support/v7/recyclerview/R$styleable

3.Caused by: java.lang.ClassNotFoundException: Didn't find class "android.support.v7.recyclerview.R$styleable"

一开始只注意到了第一点,于是在网络上查呀查:

就发现大家的说法就是 在eclipse或者android studio上 因为sdk的版本不match,等等的。有的人说把android.support.v7.recyclerview.jar这个包换掉,换成match的版本的就好了,但我这边因为开发方式不一样,就又断掉了。但是却让我知道了是版本的问题

后来

有的人说是

1.AndroidManifest.xml中的targetSDKVersion不对,fix - NOK。

2.build.gradle中的某些属性不对。fix - NOK

因为App是独立的apk,就去这5.0,6.0 andorid 的源码中去找android.support.v7.recyclerview.

同时又注意到了这两点错误

2.同时还有这样的 java.lang.NoClassDefFoundError: Failed resolution of: Landroid/support/v7/recyclerview/R$styleable

3.Caused by: java.lang.ClassNotFoundException: Didn't find class "android.support.v7.recyclerview.R$styleable"

从Log中我们可以看到

at android.support.v7.widget.RecyclerView.init(RecyclerView.java:440)

at android.support.v7.widget.RecyclerView.init(RecyclerView.java:409)

RecyclerView的409 和 440 行出错

就发现了在 frameworks/support/v7/recyclerview/src/android/support/v7/widget/RecyclerView.java中

使用到了R.styleable.RecyclerView这个属性,而第2,3点log中出现的就是R$styleable 的错误。

明确了:在android6.0版本RecyclerView类中用到了R.styleable.RecyclerView这个资源。而android5.0的版本中的RecyclerView类没用到R.styleable.RecyclerView

回到frameworks/support/v7/recyclerview/目录下就会发现

-----------5.0 没有res/ 文件夹

-----------6.0 则有

那么现在中场总结一下,因为andorid5.0中的RexyclerView类中没有使用res资源,而6.0却使用了。同时6.0的res/资源是存在的。只能说明,我们没有引用到,或者说是没有把对应的资源加载,进行编译。

问题又来了:res/资源是在哪里加载的?

----------》 Android.mk 文件下有这么一段

发现了android-support-v7-recyclerview的身影

那这内容是什么意思?

1.LOCAL_STATIC_JAVA_LIBARIES 本地静态java库。

2.LOCAL_RESOURCE_DIR 本地资源文件,默认是product package和device package下面相应的res路径和$(LOCAL_PATH)/res

3.LOCAL_AAPT_FLAGS += -c ldpi -c mdpi

上面指定了编译时打包 ldpi 和mdpi 如果系统默认的是hdpi的话,那就是这三种都会装入包中

在中场总结的时候,已经明确,是因为res资源没有加载。

所以只需要在LOCAL_RESOURCE_DIR中加上frameworks/support/v7/recyclerview/res就可以了

Android.mk文件内容变成:

再次编译,正常运行。

======================================================================================================

其实就是因为android的版本升级,RecyclerView 中的创建LayoutManager的方式发生了改变,旧版本里少了个 R.styleable.RecyclerView, 而在新环境下又没将其编译进去,故有此错。

各位少侠也可以在 package 中的res/attrs.xml 下面自己定义一个`````

总体来说将的不是很清楚, 还请大家见谅 。。

关于源码打包成apk和源码打包成appx的介绍到此就结束了,不知道你从中找到你需要的信息了吗 ?如果你还想了解更多这方面的信息,记得收藏关注本站。

1、本网站名称:源码村资源网
2、本站永久网址:https://www.yuanmacun.com
3、本网站的文章部分内容可能来源于网络,仅供大家学习与参考,如有侵权,请联系站长进行删除处理。
4、本站一切资源不代表本站立场,并不代表本站赞同其观点和对其真实性负责。
5、本站一律禁止以任何方式发布或转载任何违法的相关信息,访客发现请向站长举报
6、本站资源大多存储在云盘,如发现链接失效,请联系我们我们会第一时间更新。
源码村资源网 » 源码打包成apk(源码打包成appx)

1 评论

您需要 登录账户 后才能发表评论

发表评论

欢迎 访客 发表评论