question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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:closed
  • Created 3 years ago
  • Reactions:7
  • Comments:10

github_iconTop GitHub Comments

3reactions
iSergioMejiacommented, Oct 21, 2020

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 the OnCreate of my activity. Apparently there’s a connection between these two things. I hope it works for any of you.

1reaction
longGrcommented, Dec 2, 2020

Had this issue on version 6.1.8. A quick fix for me was to use osm version 6.1.4:

implementation 'org.osmdroid:osmdroid-android:6.1.4'
Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found