I'm trying to create an application that uses Wifi Aware but my WifiAwareManager returns null. How can I properly initialize the class so that it does not return null? What is the cause of this behavior? I'm quite sure that Pixel 2 XL does support Wifi Aware, am I wrong?
final WifiAwareManager wifiAwareManager = (WifiAwareManager) getSystemService(Context.WIFI_AWARE_SERVICE);
if (wifiAwareManager.isAvailable()) {
System.out.println("aware avaiable");
} else {
System.out.println("aware not avaiable");
}
The logcat is:
2018-10-11 12:45:53.926 4003-4003/com.example.lucapalmieri.awarecheckE/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.lucapalmieri.awarecheck, PID: 4003
java.lang.IllegalStateException: Could not execute method for android:onClick
at android.support.v7.app.AppCompatViewInflater$DeclaredOnClickListener.onClick(AppCompatViewInflater.java:389)
at android.view.View.performClick(View.java:6294)
at android.view.View$PerformClick.run(View.java:24770)
at android.os.Handler.handleCallback(Handler.java:790)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6494)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Method.invoke(Native Method)
at android.support.v7.app.AppCompatViewInflater$DeclaredOnClickListener.onClick(AppCompatViewInflater.java:384)
at android.view.View.performClick(View.java:6294)
at android.view.View$PerformClick.run(View.java:24770)
at android.os.Handler.handleCallback(Handler.java:790)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6494)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'boolean android.net.wifi.aware.WifiAwareManager.isAvailable()' on a null object reference
at com.example.lucapalmieri.awarecheck.MainActivity.check(MainActivity.java:71)
at java.lang.reflect.Method.invoke(Native Method)
at android.support.v7.app.AppCompatViewInflater$DeclaredOnClickListener.onClick(AppCompatViewInflater.java:384)
at android.view.View.performClick(View.java:6294)
at android.view.View$PerformClick.run(View.java:24770)
at android.os.Handler.handleCallback(Handler.java:790)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6494)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
Cause isAvailiable is added only from api level 26 as WifiAwareManager. I assume you are using android with version lower than Android 8.0
https://developer.android.com/reference/android/net/wifi/aware/WifiAwareManager.html#isAvailable()
Related
when i capture images with multiple buttons from multiple fragment, this error occurs.Could someone explain about this error?
at android.app.ActivityThread$StopInfo.run(ActivityThread.java:3950)
at android.os.Handler.handleCallback(Handler.java:790)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6494)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
Caused by: android.os.TransactionTooLargeException: data parcel size 4252508 bytes
at android.os.BinderProxy.transactNative(Native Method)
at android.os.BinderProxy.transact(Binder.java:764)
at android.app.IActivityManager$Stub$Proxy.activityStopped(IActivityManager.java:4623)
at android.app.ActivityThread$StopInfo.run(ActivityThread.java:3934)
at android.os.Handler.handleCallback(Handler.java:790)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6494)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)```
I was working on a project which used exclusively strings literals in the code and layout, so I extracted them to strings.xml to later localize. Unfortunately after extracting all the strings and when trying to run I get a runtime error:
2020-06-16 13:54:20.482 22717-22717/com.Applikation.OReels.android E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.Applikation.OReels.android, PID: 22717
java.lang.RuntimeException: Unable to create application com.Applikation.progressplay.Android.ProgressPlayApplication: android.content.res.Resources$NotFoundException: String resource ID #0x7f0f0062
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5743)
at android.app.ActivityThread.-wrap1(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1656)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6494)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
Caused by: android.content.res.Resources$NotFoundException: String resource ID #0x7f0f0062
at android.content.res.Resources.getText(Resources.java:339)
at android.content.res.Resources.getString(Resources.java:433)
at com.Applikation.progressplay.Android.Shared.DataManager.DataManager.createServerMessage(DataManager.kt:183)
at com.Applikation.progressplay.Android.Shared.DataManager.DataManager.<init>(DataManager.kt:33)
at com.Applikation.progressplay.Android.Shared.DataManager.DataManager$Companion.shared(DataManager.kt:45)
at com.Applikation.progressplay.Android.ProgressPlayApplication.onCreate(ProgressPlayApplication.kt:22)
at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1119)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5740)
at android.app.ActivityThread.-wrap1(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1656)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6494)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
DataManager.kt Line 183:
serverErrors.put("em_DailyDepositLimitIsBelowZero" , Resources.getSystem().getString(R.string.daily_deposit_limit))
Any help or advice would be welcome.
Simply use getString() instead of Resources.getSystem().getString()
I have a problem with my app where I entered a login button with facebook.
When I use the app and on facebook developer options I have development mode, I have no problems,the app is working properly.
But from the moment I put it in release on facebook developer options, the app crashes as soon as I click on login
I've already put a key release hash on facebook developer, and I've made other attempts, but I can't understand the problem.
java.lang.IllegalStateException: Could not execute method for android:onClick
at android.support.v7.app.AppCompatViewInflater$DeclaredOnClickListener.onClick(AppCompatViewInflater.java:390)
at android.view.View.performClick(View.java:6663)
at android.view.View.performClickInternal(View.java:6635)
at android.view.View.access$3100(View.java:794)
at android.view.View$PerformClick.run(View.java:26199)
at android.os.Handler.handleCallback(Handler.java:907)
at android.os.Handler.dispatchMessage(Handler.java:105)
at android.os.Looper.loop(Looper.java:216)
at android.app.ActivityThread.main(ActivityThread.java:7625)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:524)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:987)
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Method.invoke(Native Method)
at android.support.v7.app.AppCompatViewInflater$DeclaredOnClickListener.onClick(AppCompatViewInflater.java:385)
at android.view.View.performClick(View.java:6663)
at android.view.View.performClickInternal(View.java:6635)
at android.view.View.access$3100(View.java:794)
at android.view.View$PerformClick.run(View.java:26199)
at android.os.Handler.handleCallback(Handler.java:907)
at android.os.Handler.dispatchMessage(Handler.java:105)
at android.os.Looper.loop(Looper.java:216)
at android.app.ActivityThread.main(ActivityThread.java:7625)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:524)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:987)
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'long java.util.Date.getTime()' on a null object reference
at java.util.Calendar.setTime(Calendar.java:1749)
at java.text.SimpleDateFormat.format(SimpleDateFormat.java:984)
at java.text.SimpleDateFormat.format(SimpleDateFormat.java:977)
at java.text.DateFormat.format(DateFormat.java:341)
at com.example.tpistis.tauros.LoginActivity.registra_cliente(LoginActivity.java:270)
at com.example.tpistis.tauros.LoginActivity.apri_app(LoginActivity.java:242)
at java.lang.reflect.Method.invoke(Native Method)
at android.support.v7.app.AppCompatViewInflater$DeclaredOnClickListener.onClick(AppCompatViewInflater.java:385)
at android.view.View.performClick(View.java:6663)
at android.view.View.performClickInternal(View.java:6635)
at android.view.View.access$3100(View.java:794)
at android.view.View$PerformClick.run(View.java:26199)
at android.os.Handler.handleCallback(Handler.java:907)
at android.os.Handler.dispatchMessage(Handler.java:105)
at android.os.Looper.loop(Looper.java:216)
at android.app.ActivityThread.main(ActivityThread.java:7625)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:524)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:987)
For those who were looking for an answer, the problem was that on FacebookDevoloper I did not have the privileges to be able to acquire the date of birth, basically you can only acquire name and last name, then the app crashes.
I'm having what I believe to be dex issues, which is something pretty foreign to me. My app crashes when it tries to instantiate an OkHttpClient. I see that a lot of people have this issue, but all the common solutions (which I mention below) haven't helped. Here's my error log:
05-06 22:43:27.912 8714-8714/com.clockwise.epochsoftware.clockwise E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.clockwise.epochsoftware.clockwise, PID: 8714
java.lang.NoClassDefFoundError: Failed resolution of: Lokhttp3/OkHttpClient;
at com.clockwise.epochsoftware.clockwise.ApplicationLoader.getLatestRelease(ApplicationLoader.java:123)
at com.clockwise.epochsoftware.clockwise.ApplicationLoader.init(ApplicationLoader.java:94)
at com.clockwise.epochsoftware.clockwise.ApplicationLoader.onCreate(ApplicationLoader.java:250)
at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1119)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5740)
at android.app.ActivityThread.-wrap1(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1656)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6494)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
Caused by: java.lang.ClassNotFoundException: okhttp3.OkHttpClient
at java.lang.VMClassLoader.findLoadedClass(Native Method)
at java.lang.ClassLoader.findLoadedClass(ClassLoader.java:738)
at java.lang.ClassLoader.loadClass(ClassLoader.java:363)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
at com.clockwise.epochsoftware.clockwise.ApplicationLoader.getLatestRelease(ApplicationLoader.java:123)
at com.clockwise.epochsoftware.clockwise.ApplicationLoader.init(ApplicationLoader.java:94)
at com.clockwise.epochsoftware.clockwise.ApplicationLoader.onCreate(ApplicationLoader.java:250)
at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1119)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5740)
at android.app.ActivityThread.-wrap1(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1656)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6494)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
Caused by: java.lang.NoClassDefFoundError: Failed resolution of: Lokhttp3/Call$Factory;
at com.clockwise.epochsoftware.clockwise.ApplicationLoader.getLatestRelease(ApplicationLoader.java:123)
at com.clockwise.epochsoftware.clockwise.ApplicationLoader.init(ApplicationLoader.java:94)
at com.clockwise.epochsoftware.clockwise.ApplicationLoader.onCreate(ApplicationLoader.java:250)
at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1119)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5740)
at android.app.ActivityThread.-wrap1(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1656)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6494)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
Caused by: java.lang.ClassNotFoundException: Didn't find class "okhttp3.Call$Factory" on path: DexPathList[[zip file "/data/app/com.clockwise.epochsoftware.clockwise-e7jhExlmJXSclbvr60izkA==/base.apk"],nativeLibraryDirectories=[/data/app/com.clockwise.epochsoftware.clockwise-e7jhExlmJXSclbvr60izkA==/lib/arm64, /data/app/com.clockwise.epochsoftware.clockwise-e7jhExlmJXSclbvr60izkA==/base.apk!/lib/arm64-v8a, /system/lib64]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:125)
at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
at com.clockwise.epochsoftware.clockwise.ApplicationLoader.getLatestRelease(ApplicationLoader.java:123)
at com.clockwise.epochsoftware.clockwise.ApplicationLoader.init(ApplicationLoader.java:94)
at com.clockwise.epochsoftware.clockwise.ApplicationLoader.onCreate(ApplicationLoader.java:250)
at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1119)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5740)
at android.app.ActivityThread.-wrap1(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1656)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6494)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
I see multiple solutions about enabling multidexing, but my app already has multidexing enabled and my manifest also has largeHeap set to true. I've also tried this gradle solution, but it hasn't helped:
dexOptions{
preDexLibraries false
javaMaxHeapSize "4g"
}
Other solutions say to disable instant run, but it's already disabled. Anyone have any suggestions? Please let me know if I need to add anything else to this post.
I am trying to run a simple app using the deep learning library dl4j.
I am working on Android Studio and using Gradle.
During runtime, I get the following exception:
08-15 13:23:00.601 4868-4868/com.mi.dl E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.mi.dl, PID: 4868
java.lang.IllegalStateException: Could not execute method for android:onClick
at android.support.v7.app.AppCompatViewInflater$DeclaredOnClickListener.onClick(AppCompatViewInflater.java:293)
at android.view.View.performClick(View.java)
at android.view.View$PerformClick.run(View.java)
at android.os.Handler.handleCallback(Handler.java)
at android.os.Handler.dispatchMessage(Handler.java)
at android.os.Looper.loop(Looper.java)
at android.app.ActivityThread.main(ActivityThread.java)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java)
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at android.support.v7.app.AppCompatViewInflater$DeclaredOnClickListener.onClick(AppCompatViewInflater.java:288)
at android.view.View.performClick(View.java)
at android.view.View$PerformClick.run(View.java)
at android.os.Handler.handleCallback(Handler.java)
at android.os.Handler.dispatchMessage(Handler.java)
at android.os.Looper.loop(Looper.java)
at android.app.ActivityThread.main(ActivityThread.java)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java)
Caused by: java.lang.ExceptionInInitializerError
at org.deeplearning4j.nn.conf.NeuralNetConfiguration$Builder.seed(NeuralNetConfiguration.java:485)
at com.mi.dl.MLPClassifierLinear.main(MLPClassifierLinear.java:79)
at com.mi.dl.MyActivity.sendMessage(MyActivity.java:70)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at android.support.v7.app.AppCompatViewInflater$DeclaredOnClickListener.onClick(AppCompatViewInflater.java:288)
at android.view.View.performClick(View.java)
at android.view.View$PerformClick.run(View.java)
at android.os.Handler.handleCallback(Handler.java)
at android.os.Handler.dispatchMessage(Handler.java)
at android.os.Looper.loop(Looper.java)
at android.app.ActivityThread.main(ActivityThread.java)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java)
Caused by: java.lang.RuntimeException: org.nd4j.linalg.factory.Nd4jBackend$NoAvailableBackendException: Please ensure that you have an nd4j backend on your classpath. Please see: http://nd4j.org/getstarted.html
at org.nd4j.linalg.factory.Nd4j.initContext(Nd4j.java:5151)
at org.nd4j.linalg.factory.Nd4j.<clinit>(Nd4j.java:169)
at org.deeplearning4j.nn.conf.NeuralNetConfiguration$Builder.seed(NeuralNetConfiguration.java:485)
at com.mi.dl.MLPClassifierLinear.main(MLPClassifierLinear.java:79)
at com.mi.dl.MyActivity.sendMessage(MyActivity.java:70)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at android.support.v7.app.AppCompatViewInflater$DeclaredOnClickListener.onClick(AppCompatViewInflater.java:288)
at android.view.View.performClick(View.java)
at android.view.View$PerformClick.run(View.java)
at android.os.Handler.handleCallback(Handler.java)
at android.os.Handler.dispatchMessage(Handler.java)
at android.os.Looper.loop(Looper.java)
at android.app.ActivityThread.main(ActivityThread.java)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java)
Caused by: org.nd4j.linalg.factory.Nd4jBackend$NoAvailableBackendException: Please ensure that you have an nd4j backend on your classpath. Please see: http://nd4j.org/getstarted.html
at org.nd4j.linalg.factory.Nd4jBackend.load(Nd4jBackend.java:178)
at org.nd4j.linalg.factory.Nd4j.initContext(Nd4j.java:5148)
at org.nd4j.linalg.factory.Nd4j.<clinit>(Nd4j.java:169)
at org.deeplearning4j.nn.conf.NeuralNetConfiguration$Builder.seed(NeuralNetConfiguration.java:485)
at com.mi.dl.MLPClassifierLinear.main(MLPClassifierLinear.java:79)
at com.mi.dl.MyActivity.sendMessage(MyActivity.java:70)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at android.support.v7.app.AppCompatViewInflater$DeclaredOnClickListener.onClick(AppCompatViewInflater.java:288)
at android.view.View.performClick(View.java)
at android.view.View$PerformClick.run(View.java)
at android.os.Handler.handleCallback(Handler.java)
at android.os.Handler.dispatchMessage(Handler.java)
at android.os.Looper.loop(Looper.java)
at android.app.ActivityThread.main(ActivityThread.java)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java)
in the build.gradle file, I have the following dependency:
compile 'org.nd4j:nd4j-native-platform:0.5.0'
but I have also tried different backends.
The dl4j team said Android is not supported yet, but I would still like to try to make it work, so any help would be appreciated.