1

I've upgraded to Android Studio 3.0 and Gradle too pointing to the latest 4.1 version, the app started reporting a Runtime Exception

java.util.MissingResourceException: Can't find bundle for base name org.eclipse.paho.client.mqttv3.internal.nls.logcat, locale en_US at java.util.ResourceBundle.throwMissingResourceException(ResourceBundle.java:1557) at java.util.ResourceBundle.getBundleImpl(ResourceBundle.java:1380) at java.util.ResourceBundle.getBundle(ResourceBundle.java:770) at org.eclipse.paho.client.mqttv3.logging.LoggerFactory.getLogger(LoggerFactory.java:72) at org.eclipse.paho.client.mqttv3.MqttAsyncClient.(MqttAsyncClient.java:103) at org.eclipse.paho.android.service.MqttConnection.connect(MqttConnection.java:289)  at org.eclipse.paho.android.service.MqttService.connect(MqttService.java:357)  at org.eclipse.paho.android.service.MqttAndroidClient.doConnect(MqttAndroidClient.java:508)  at org.eclipse.paho.android.service.MqttAndroidClient.access$200(MqttAndroidClient.java:81)  at org.eclipse.paho.android.service.MqttAndroidClient$MyServiceConnection.onServiceConnected(MqttAndroidClient.java:154)  at android.app.LoadedApk$ServiceDispatcher.doConnected(LoadedApk.java:1634)  at android.app.LoadedApk$ServiceDispatcher$RunConnection.run(LoadedApk.java:1663)  at android.os.Handler.handleCallback(Handler.java:789)  at android.os.Handler.dispatchMessage(Handler.java:98)  at android.os.Looper.loop(Looper.java:164)  at android.app.ActivityThread.main(ActivityThread.java:6541)  at java.lang.reflect.Method.invoke(Native Method)  at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767) 

Pavan Kunchapu
  • 263
  • 3
  • 9

1 Answers1

1

Android Studio 3.0 with Gradle 4.1 incorporated several changes one major impacting thing is new dependency configurations. If your module referring any local(libs folder) jar file(s) and if that jar(s) file contains resources(ResourceBundles), then they are stripped from final artifact.

If it is a AAR file you can refer inside extracted_aar_file/libs/exctract_the_referred_library. Then observe Resources are removed.

To fix this, follow the solution given here. The solution is application to any jar with resources. But as it is a temporary fix, try to loose couple by creating a separate library module in your project like this enter image description here and refer it in the dependent module (it may be app module or some other library module) like this.

dependencies {
    implementation project(path: ':jarResourceBundleFixer')
    ...
}

NOTE: I faced problem with local jars from libs folder, the same problem might occur if you are referring like implementation 'group:name.of.jar.with.resources' But the same fix should work even in that case.

Alexander Farber
  • 21,519
  • 75
  • 241
  • 416
Pavan Kunchapu
  • 263
  • 3
  • 9