[英]java.util.MissingResourceException - Error locating the logging class (MQTT Library)
I'm writing an Android app that uses MQTT. 我正在编写一个使用MQTT的Android应用。
On release build I get an exception on the line : 在发布版本上,我会遇到一个异常:
MqttClient client = new MqttClient(host, clientId, new MemoryPersistence());
On debug build, all works fine. 在调试版本上,一切正常。 I'm using mqtt-client-0.4.0.jar .
我正在使用mqtt-client-0.4.0.jar 。
The execption (that i get in release is) : 的执行(我得到释放是):
W/System.err: java.util.MissingResourceException: Error locating the logging class
W/System.err: at d.a.a.a.a.b.b.a(:2)
W/System.err: at d.a.a.a.a.e.<init>(Unknown Source:7)
W/System.err: at c.b.a.j.a(:2)
W/System.err: at c.b.a.j.<init>(Unknown Source:14)
W/System.err: at c.b.a.d.onStarted(:1)
W/System.err: at android.location.LocationManager$GnssStatusListenerTransport$GnssHandler.handleMessage(LocationManager.java:1424)
W/System.err: at android.os.Handler.dispatchMessage(Handler.java:106)
W/System.err: at android.os.Looper.loop(Looper.java:164)
W/System.err: at android.app.ActivityThread.main(ActivityThread.java:6626)
W/System.err: at java.lang.reflect.Method.invoke(Native Method)
W/System.err: at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
W/System.err: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:811)
I looked inside mqtt library and I found the source code that generates this error : 我查看了mqtt库,发现了生成此错误的源代码:
https://github.com/eclipse/paho.mqtt.java/blob/master/org.eclipse.paho.client.mqttv3/src/main/java/org/eclipse/paho/client/mqttv3/logging/LoggerFactory.java https://github.com/eclipse/paho.mqtt.java/blob/master/org.eclipse.paho.client.mqttv3/src/main/java/org/eclipse/paho/client/mqttv3/logging/LoggerFactory。爪哇
Line 76 : 第76行:
public static Logger getLogger(String messageCatalogName, String loggerID) {
String loggerClassName = overrideloggerClassName;
Logger logger = null;
if (loggerClassName == null) {
loggerClassName = jsr47LoggerClassName;
}
logger = getLogger(loggerClassName,
ResourceBundle.getBundle(messageCatalogName), loggerID, null) ;
if (null == logger) {
throw new MissingResourceException("Error locating the
logging class", CLASS_NAME, loggerID);
}
return logger;
}
if I add debuggable true
in the release block in the file build.gradle I don't get the error and the app works fine. 如果我在文件build.gradle的发行版块中添加了
debuggable true
,则不会出现错误,并且该应用程序可以正常运行。 But I don't want a debuggable release. 但是我不想发布可调试的版本。
Can you help me? 你能帮助我吗?
You can add the following lines to the proguard-rules.pro file: 您可以将以下行添加到proguard-rules.pro文件中:
-keep class org.eclipse.paho.clent.mqttv3.** {*;}
-keep class org.eclipse.paho.client.mqttv3.*$* { *; }
-keep class org.eclipse.paho.client.mqttv3.logging.JSR47Logger { *; }
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.