Android Question Dropbox NullPointerExeption

bus1963

Member
Licensed User
Longtime User
Hi hardworking volunteers.

Have a problem with my little program you want to download a Daten.csv in the dropbox.

The error occurs during the execution of the -> manager.FileUpload - line
Did the folder changed as well as the file itself ... does not help .. !!

The error message:
Installing file.
PackageAdded: package:SQ.PM
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
** Activity (main) Pause, UserClosed = false **
** Activity (main) Resume **
hasLinkedAccount()->Use Dropbox datastores
java.lang.NullPointerException: Attempt to invoke virtual method 'boolean com.dropbox.sync.android.DbxFileSystem.exists(com.dropbox.sync.android.DbxPath)' on a null object reference
at anywheresoftware.b4a.dropbox.DbxAccountManagerWrapper.getFile(DbxAccountManagerWrapper.java:208)
at anywheresoftware.b4a.dropbox.DbxAccountManagerWrapper.UploadFile(DbxAccountManagerWrapper.java:227)
at SQ.PM.main._manager_accountready(main.java:394)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:175)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:159)
at anywheresoftware.b4a.dropbox.DbxAccountManagerWrapper.LinkAccount(DbxAccountManagerWrapper.java:107)
at SQ.PM.main._button1_click(main.java:347)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:175)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:163)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:159)
at anywheresoftware.b4a.objects.ViewWrapper$1.onClick(ViewWrapper.java:77)
at android.view.View.performClick(View.java:4785)
at android.view.View$PerformClick.run(View.java:19858)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:155)
at android.app.ActivityThread.main(ActivityThread.java:5696)
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:1028)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:823)

My Code:

B4X:
#Region  Project Attributes
    #ApplicationLabel: SQPM
    #VersionCode: 1
    #VersionName:
    'SupportedOrientations possible values: unspecified, landscape or portrait.
    #SupportedOrientations: unspecified
    #CanInstallToExternalStorage: False
#End Region

#Region  Activity Attributes
    #FullScreen: False
    #IncludeTitle: True
#End Region

Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'These variables can be accessed from all modules.
  
Dim manager As DbxAccountManager  
Dim key As String = "x9t0ymypxxxxx"
Dim secret As String = "5xm9h1hdaxxxxxxx"

End Sub

Sub Globals
    'These global variables will be redeclared each time the activity is created.
    'These variables can only be accessed from this module.

    Private Button1 As Button

End Sub

Sub Activity_Create(FirstTime As Boolean)

        If FirstTime Then
            manager.Initialize(key, secret, "manager" ,True)
          End If

        Activity.LoadLayout("Main")

End Sub

Sub Manager_AccountReady (Success As Boolean)
  
    If Success Then

        ToastMessageShow("Link to Dropbox successfull ...",False )

        manager.UploadFile(File.DirDefaultExternal,"Svenner.txt","/","Svenner.txt")
        Msgbox("Daten gesendet","UP OK")
      
    Else
  
         ToastMessageShow("Unable to Link to Dropbox  ...",False )
      
    End If

End Sub

Sub Button1_Click

    manager.LinkAccount

End Sub

My Manifest-Code:

'This code will be applied to the manifest file during compilation.
'You do not need to modify it in most cases.
'See this link for for more information: http://www.b4x.com/forum/showthread.php?p=78136
AddManifestText(
<uses-sdk android:minSdkVersion="5" android:targetSdkVersion="14"/>
<supports-screens android:largeScreens="true"
android:normalScreens="true"
android:smallScreens="true"
android:anyDensity="true"/>)
SetApplicationAttribute(android:icon, "@drawable/icon")
SetApplicationAttribute(android:label, "$LABEL$")
SetApplicationAttribute(android:theme, "@android:style/Theme.Holo")
AddApplicationText(
<activity android:name="com.dropbox.sync.android.DbxAuthActivity" />
<activity
android:name="com.dropbox.client2.android.AuthActivity"
android:launchMode="singleTask" >
<intent-filter>
<data android:scheme="db-x9t0ymypxxxxxxx" /> <!-- NEED TO UPDATE -->
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.BROWSABLE" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<service
android:name="com.dropbox.sync.android.DbxSyncService"
android:enabled="true"
android:exported="false"
android:label="Dropbox Sync" />
)
'End of default text.

Here are the PMSQ file for testing:
I sit now been 3 days in this problem and can not find the error.
In advance thanks for the help.
 

Attachments

  • PMSQ.zip
    7.8 KB · Views: 277
Last edited:

bus1963

Member
Licensed User
Longtime User
Hello parijs,

I can only say ... thank you thank you thank you .. !!
It runs perfectly !! I still can not believe it.
I thank you that you have not given up ... now I can go on.

This is a really good forum and I thank all who have tried to help me.
1000 thanks

I'm happy ... thanks
 
Upvote 0
Top