Tag: android proguard

如何使用proguard牙签规则?

我在我的项目中使用TP。 我正在使用TP注入一些对象。 但是当我在应用程序中使用proguard规则时。 它在调试模式下工作正常但是在释放模式下给出null对象,所有通过@Inject注解注入的对象。

运行时崩溃与Proguard启用房间持久性库

当启用了proguard时,我一直面对房间稳定版本的崩溃 FATAL EXCEPTION: main Process: .debug, PID: 27841 java.lang.RuntimeException: Unable to create application .DebugBaseApplication: java.lang.RuntimeException: cannot find implementation for .database.c. c_Impl does not exist at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5015) at android.app.ActivityThread.-wrap1(ActivityThread.java) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1573) at android.os.Handler.dispatchMessage(Handler.java:111) at android.os.Looper.loop(Looper.java:207) at android.app.ActivityThread.main(ActivityThread.java:5811) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:791) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:681) Caused by: java.lang.RuntimeException: cannot find implementation for .database.c. c_Impl does not exist […]

无法在Kotlin中构建发布版本

在将我的Android项目转换为Kotlin后,我无法构建发布版本,错误似乎与Proguard有关。 我看到155个警告 Warning:com.example.app.activity.MainActivity$1: can’t find referenced field ‘android.view.View decorView’ in program class com.example.app.activity.MainActivity Warning:com.example.app.activity.MainActivity$2: can’t find referenced field ‘android.os.Handler handler’ in program class com.example.app.activity.MainActivity 并且构建失败 Error:Execution failed for task ‘:MyApp:transformClassesAndResourcesWithProguardForFreeRelease’. > Job failed, see logs for details 如果我在build.grade中将这些指令从true更改为false,则构建成功。 minifyEnabled true shrinkResources true 有什么问题可能是什么建议? 编辑: proguard文件如下: ProGuard的-android.txt # This is a configuration file for ProGuard. # […]

取消选中BottomNavigationView中没有虚拟物品或反射的所有物品

我正在尝试从设计库中使用BottomNavigationView。 除了我希望每个导航项目启动一个活动外,一切正常,因此我想取消选中导航栏中的所有项目,使它们看起来相同。 我已经尝试了几种解决方案,其中大部分都不起作用,而最后一种解决方案确实有效,但感觉非常不好。 首先我做了这个: ViewGroup nav = (ViewGroup) bottomNav; for(int i=0; i < nav.getChildCount(); i++) { nav.getChildAt(i).setSelected(false); } 这似乎什么都不做。 然后我试着: int size = bottomNav.getMenu().size(); for (int i = 0; i < size; i++) { bottomNav.getMenu().getItem(i).setChecked(false); } 其中只有最后一项检查,而不是第一个。 最后我尝试在菜单中添加一个虚拟物品, bottomNav.getMenu().findItem(R.id.dummmy_item).setChecked(true); bottomNav.findViewById(R.id.dummmy_item).setVisibility(View.GONE); 这几乎可以工作,但它隐藏了下面的标题,这对我的情况来说很重要。 然后我找到了这个答案: https : //stackoverflow.com/a/41372325/4888701并编辑我的上述解决方案,包括。 具体而言,我添加了proguard规则,并使用了确切的帮助类,并调用该方法。 它看起来是正确的,似乎工作。 但是对我来说感觉很不好,因为: 我正在使用一个虚拟菜单项目,以便不能查看可见项目 它增加了相当多的代码应该是一个小的视觉修正。 我已经读过,如果可能,应该避免反思。 有没有其他的,最好是简单的方法来实现这个,或者这是最好的,我们有当前版本的图书馆? (作为一个便笺,我想知道在这个解决方案中的proguard规则是否有必要,它是做什么的?我对proguard一无所知,但是这个项目是从其他人启用的。

与Proguard和Kotlin“找不到引用类”

我遇到了proguard和kotlin的一个奇怪的问题。 我逐渐将一个项目编程转换为kotlin – 目前为止,这个项目已经非常好了,但是在转换某些类时,我却遇到了proguard错误。 我还不能确定这些类的特殊属性是如何破坏的 – 它们似乎与其他类没有区别。 作为一个例子InputStreamWithSource只是: package org.ligi.passandroid.model import java.io.InputStream class InputStreamWithSource(val source: String, val inputStream: InputStream) 它完全在IDE中工作 – 我可以部署到一个设备 – 也所有的UI测试运行良好。 只是当试图组装发布项目我得到proguard错误我不明白: Warning: org.ligi.passandroid.ui.FileUnzipControllerSpec: can't find referenced class org.ligi.passandroid.model.InputStreamWithSource Warning: org.ligi.passandroid.ui.FileUnzipControllerSpec: can't find referenced class org.ligi.passandroid.model.InputStreamWithSource Warning: org.ligi.passandroid.ui.InputStreamProvider: can't find referenced class org.ligi.passandroid.model.InputStreamWithSource Warning: org.ligi.passandroid.ui.InputStreamProvider: can't find referenced class org.ligi.passandroid.model.InputStreamWithSource Warning: org.ligi.passandroid.ui.InputStreamProvider: […]

Kotlin:需要编程Kotlin数据类?

我有一个数据类定义如下 package com.mypackage.model object Model { data class News(val photo: String, val title: String, val description: String) } 当我使用Proguard(即发布版本)进行编译时,我收到并存储在模型中的数据全部为空。 他们仍然在那里即ArrayList listOfNews有预期的检索大小。 但是他们所有的内容都是空的。 调试构建这是好的。 为了解决这个问题,我使用这个proguard规则,并解决了这个问题。 -keep class com.mypackage.model.** { *; } 这是预期的吗? 即所有数据类应该被保护?

Kotlin和Proguard

在将我的Android项目转换为Kotlin后,我无法构建发布版本,错误似乎与Proguard有关。 我看到155个警告 Warning:com.example.app.activity.MainActivity$1: can't find referenced field 'android.view.View decorView' in program class com.example.app.activity.MainActivity Warning:com.example.app.activity.MainActivity$2: can't find referenced field 'android.os.Handler handler' in program class com.example.app.activity.MainActivity 并且构建失败 Error:Execution failed for task ':MyApp:transformClassesAndResourcesWithProguardForFreeRelease'. > Job failed, see logs for details 如果我在build.grade中将这些指令从true更改为false,则构建成功。 minifyEnabled true shrinkResources true 有什么问题可能是什么建议? 编辑: proguard文件如下: ProGuard的-android.txt # This is a configuration file for ProGuard. # […]