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.basic4ppc.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: 160
Last edited:

bus1963

Member
Licensed User
Longtime User
I definitely can not save files in the folder / device
...and now...?
Where is the folder which the Sub responsive?
 
Upvote 0

bus1963

Member
Licensed User
Longtime User
I have on my phone the following folders:
/ device
0 Internal memory
ext_sd external sdcard

in which memory or folder must furnaces, the text file are ...
 
Upvote 0

parijs

Active Member
Licensed User
Longtime User
copy
File.MakeDir(File.DirRootExternal,"Test1")
in Activity_Create
run
and look where it is
 
Upvote 0

bus1963

Member
Licensed User
Longtime User
I do not see any of the three messages within the sub.
After the button press no display or reactively more
 
Upvote 0

bus1963

Member
Licensed User
Longtime User
First, good night and thank you so much that you took as much time for me!

I would be very happy if you tomorrow maybe could give me some assistance because it still does not run.
as I said, after pressing the button there is no reaction.

Thanks for the help
 
Upvote 0

bus1963

Member
Licensed User
Longtime User
Hello and thank you for your work.

my app is congestion on development.

I tried your code, pragramm says that the file exists.
Then comes the button and press again when no response ...
 
Upvote 0

parijs

Active Member
Licensed User
Longtime User
I have make a new in db and the app Status = Development
But the fist time i make a App Console I had to wait 5 or 6 days for it was activated
The code is oke
Look by running debug mode step by step if you landing in Manager_AccountReady
 
Upvote 0

parijs

Active Member
Licensed User
Longtime User
even if i use your
Dim key As String = "x9t0ymypxxxxx"
Dim secret As String = "5xm9h1hdaxxxxxxx"
from your first post my phone opens dropbox with a mention "no access to dropbox"
 
Upvote 0

bus1963

Member
Licensed User
Longtime User
I do not get into landing in Manager_AccountReady .. no reaction, no error message
The logs only show me the installation of the packages - nothing else. also unfiltered

I use way B4A 4.00
 
Upvote 0

parijs

Active Member
Licensed User
Longtime User
I use B4A 4.30 but must be working from V3.0 - Works with Dropbox SDK v3.0 v3.1.

I have make a new dropbox account and set a new "first" Dropbox API app, and in 1 min works and Status Development.

Try to make a new Dropbox API app and get the new key and secret
Set:
Files and datastores
Yes My app only needs access to files it creates.
set a name for the App folder name "SQPM"
and try
 
Upvote 0
Top