Attempt to invoke virtual method 'java.lang.String java.io.File.getAbsolutePath()' on a null object reference
See original GitHub issue[X] Question [X] Bug [ ] Improvement [ ] Build system related [ ] Performance [ ] Documentation
Description and/or steps/code to reproduce the problem
Error on this line
Context ctx = getApplicationContext();
--> Configuration.getInstance().load(ctx, PreferenceManager.getDefaultSharedPreferences(ctx));
When i re-open activity
2020-08-31 19:15:00.663 29859-29859/? E/com.urban.map: Unknown bits set in runtime_flags: 0x8000
2020-08-31 19:15:12.831 29859-29859/com.urban.map E/RecyclerView: No adapter attached; skipping layout
2020-08-31 19:15:14.418 29859-29859/com.urban.map E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.urban.map, PID: 29859
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.urban.map/com.urban.map.activites.MapsActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String java.io.File.getAbsolutePath()' on a null object reference
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3270)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3409)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:83)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2016)
at android.os.Handler.dispatchMessage(Handler.java:107)
at android.os.Looper.loop(Looper.java:214)
at android.app.ActivityThread.main(ActivityThread.java:7356)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:491)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String java.io.File.getAbsolutePath()' on a null object reference
at org.osmdroid.config.DefaultConfigurationProvider.load(DefaultConfigurationProvider.java:337)
at com.urban.map.activites.MapsActivity.onCreate(MapsActivity.java:34)
at android.app.Activity.performCreate(Activity.java:7824)
at android.app.Activity.performCreate(Activity.java:7813)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1307)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3245)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3409)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:83)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2016)
at android.os.Handler.dispatchMessage(Handler.java:107)
at android.os.Looper.loop(Looper.java:214)
at android.app.ActivityThread.main(ActivityThread.java:7356)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:491)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)
Environment
compileSdkVersion 29
buildToolsVersion "29.0.2"
Version of osmdroid the issue relates to:
6.1.2
Issue Analytics
- State:
- Created 3 years ago
- Reactions:7
- Comments:10
Top Results From Across the Web
Attempt to invoke virtual method 'java.lang.String java.io.File ...
Attempt to invoke virtual method 'java.lang.String java.io.File.getCanonicalPath()' on a null object reference.
Read more >File - Android Developers
By default the classes in the java.io package always resolve relative pathnames against the current user directory. This directory is named by the...
Read more >Fixed Error android error attempt to invoke virtual method
Android App Development Tutorial in Android Studio in Java 2021 for ... or attempt to invoke virtual method on a null object reference...
Read more >"Attempt to invoke virtual method 'java.lang.String android ...
Context.getPackageName()' on a null object reference" when authenticting user on Android. Authenticating the user (using azure authentication ...
Read more >attempt to invoke virtual method on a null object reference
it looks like bmp is null due to resourceId being zero. And you did not show any code that sets resourceId...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Hello! I don’t know if this will work for all of you but I got the same error, and in the end was because I didn’t call the
setContentView(...)
function in theOnCreate
of my activity. Apparently there’s a connection between these two things. I hope it works for any of you.Had this issue on version 6.1.8. A quick fix for me was to use osm version 6.1.4: