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: 214
Last edited:

bus1963

Member
Licensed User
Longtime User
Hi Erel and thank you for your answer.
Now I have the right Lib (also need at initialization no longer Tru / False specify). ok!
Now I have the problem that my Button1 shows no reaction.
I think the manager.linkAccount has no function ... ?? !!
Why this now ...?

you can look again ..

Thank-You
 
Upvote 0

bus1963

Member
Licensed User
Longtime User
Hello again ...

my app still does not work! ... unfortunately ...
Could it be due to my phone? (HTC ONE M8)
I changed the folder, the upload and the download tasted ... nothing works ...
It is to despair ... always comes the error:

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

Could it be because the some Orner exists / does not exist?
Where the base folder of Dropbox is on the phone?
"/" As path information is not enough ...
can someone write the exact long path ... please me.

Thank you again ..
 
Upvote 0

bus1963

Member
Licensed User
Longtime User
I have the latest Dropbox sync lib and latest android sdk dropbox loaded and inserted ......'m really despair at
 
Upvote 0

parijs

Active Member
Licensed User
Longtime User
Hi bus

I have test your code

I had to change two things

manager.Initialize(key, secret, "manager" ,True)
to
manager.Initialize(key, secret, "manager")

and

manager.UploadFile(File.DirDefaultExternal,"Svenner.txt","/","Svenner.txt")
to
manager.UploadFile(File.DirRootExternal,"Svenner.txt","/","Svenner.txt")

and it works

the file was in the dir that I had given in dropbox
 
Upvote 0

bus1963

Member
Licensed User
Longtime User
Hello and thanks for the reply.
Which sdk sync and what do you use?

Libs I enabled the program: Core 4.01 and Dropbox sync 3.31
I can not take away when initializing the boolean value
then I get an error: too few arguments!
The upload line I've changed to:

Sub Manager_AccountReady (Success As Boolean)
Log ("Account Ready" & Success)
If Success Then
manager.UploadFile (File.DirRootExternal, "Svenner.txt", "/", "Svenner.txt")
End If
End Sub

It does not work !!
I have been taking the folders in the phone have only one folder: android / data / com.dropbbox.android / and not com dropbox.sync.android

Can there be the problem ..

Please re for help
 
Upvote 0

bus1963

Member
Licensed User
Longtime User
and i have drop in the Lib Folder on B4A Program the: dropbox-sync-sdk-android 3.1.2

My ideacounter is 0 :(
 
Upvote 0

bus1963

Member
Licensed User
Longtime User
I now have the Dropbox sync again changed to the version 3.00.
The problem with the initialization line is now gone!

Although now I get no error message, but the
Sub Manager_AccountReady (Success As Boolean) is not executed.
... no error message - no uploading to Dropbox.

What could now be even more flawed?

Please suggestions ...
 
Upvote 0

bus1963

Member
Licensed User
Longtime User
I always thought would File.DirRootExternal = / sdcard /
 
Upvote 0

parijs

Active Member
Licensed User
Longtime User
I have it on my card and on my phone not the same text and the Svenner.txt was comming from my phone
 
Upvote 0

bus1963

Member
Licensed User
Longtime User
I just tried it.
When either is not writable or not enough disk space to copy
 
Upvote 0
Top